documentation.d.ts 3.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645
  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. readonly 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 readonly 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 LogLevels: 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 readonly 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. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. /**
  483. * Returns client's state
  484. */
  485. readonly readyState: number;
  486. /**
  487. * Returns client's status
  488. */
  489. readonly status: number;
  490. /**
  491. * Returns client's status as a text
  492. */
  493. readonly statusText: string;
  494. /**
  495. * Returns client's response
  496. */
  497. readonly response: any;
  498. /**
  499. * Returns client's response url
  500. */
  501. readonly responseURL: string;
  502. /**
  503. * Returns client's response as text
  504. */
  505. readonly responseText: string;
  506. /**
  507. * Gets or sets the expected response type
  508. */
  509. responseType: XMLHttpRequestResponseType;
  510. /** @hidden */
  511. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  512. /** @hidden */
  513. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  514. /**
  515. * Cancels any network activity
  516. */
  517. abort(): void;
  518. /**
  519. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  520. * @param body defines an optional request body
  521. */
  522. send(body?: Document | BodyInit | null): void;
  523. /**
  524. * Sets the request method, request URL
  525. * @param method defines the method to use (GET, POST, etc..)
  526. * @param url defines the url to connect with
  527. */
  528. open(method: string, url: string): void;
  529. /**
  530. * Sets the value of a request header.
  531. * @param name The name of the header whose value is to be set
  532. * @param value The value to set as the body of the header
  533. */
  534. setRequestHeader(name: string, value: string): void;
  535. /**
  536. * Get the string containing the text of a particular header's value.
  537. * @param name The name of the header
  538. * @returns The string containing the text of the given header name
  539. */
  540. getResponseHeader(name: string): Nullable<string>;
  541. }
  542. }
  543. declare module BABYLON {
  544. /**
  545. * File request interface
  546. */
  547. export interface IFileRequest {
  548. /**
  549. * Raised when the request is complete (success or error).
  550. */
  551. onCompleteObservable: Observable<IFileRequest>;
  552. /**
  553. * Aborts the request for a file.
  554. */
  555. abort: () => void;
  556. }
  557. }
  558. declare module BABYLON {
  559. /**
  560. * Define options used to create a render target texture
  561. */
  562. export class RenderTargetCreationOptions {
  563. /**
  564. * Specifies is mipmaps must be generated
  565. */
  566. generateMipMaps?: boolean;
  567. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  568. generateDepthBuffer?: boolean;
  569. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  570. generateStencilBuffer?: boolean;
  571. /** Defines texture type (int by default) */
  572. type?: number;
  573. /** Defines sampling mode (trilinear by default) */
  574. samplingMode?: number;
  575. /** Defines format (RGBA by default) */
  576. format?: number;
  577. }
  578. }
  579. declare module BABYLON {
  580. /**
  581. * @hidden
  582. **/
  583. export class _TimeToken {
  584. _startTimeQuery: Nullable<WebGLQuery>;
  585. _endTimeQuery: Nullable<WebGLQuery>;
  586. _timeElapsedQuery: Nullable<WebGLQuery>;
  587. _timeElapsedQueryEnded: boolean;
  588. }
  589. }
  590. declare module BABYLON {
  591. /** Defines the cross module used constants to avoid circular dependncies */
  592. export class Constants {
  593. /** Defines that alpha blending is disabled */
  594. static readonly ALPHA_DISABLE: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  596. static readonly ALPHA_ADD: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  598. static readonly ALPHA_COMBINE: number;
  599. /** Defines that alpha blending is DEST - SRC * DEST */
  600. static readonly ALPHA_SUBTRACT: number;
  601. /** Defines that alpha blending is SRC * DEST */
  602. static readonly ALPHA_MULTIPLY: number;
  603. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  604. static readonly ALPHA_MAXIMIZED: number;
  605. /** Defines that alpha blending is SRC + DEST */
  606. static readonly ALPHA_ONEONE: number;
  607. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  608. static readonly ALPHA_PREMULTIPLIED: number;
  609. /**
  610. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  611. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  612. */
  613. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  614. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  615. static readonly ALPHA_INTERPOLATE: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  618. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_SCREENMODE: number;
  621. /**
  622. * Defines that alpha blending is SRC + DST
  623. * Alpha will be set to SRC ALPHA + DST ALPHA
  624. */
  625. static readonly ALPHA_ONEONE_ONEONE: number;
  626. /**
  627. * Defines that alpha blending is SRC * DST ALPHA + DST
  628. * Alpha will be set to 0
  629. */
  630. static readonly ALPHA_ALPHATOCOLOR: number;
  631. /**
  632. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  633. */
  634. static readonly ALPHA_REVERSEONEMINUS: number;
  635. /**
  636. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  637. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  638. */
  639. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  640. /**
  641. * Defines that alpha blending is SRC + DST
  642. * Alpha will be set to SRC ALPHA
  643. */
  644. static readonly ALPHA_ONEONE_ONEZERO: number;
  645. /**
  646. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  647. * Alpha will be set to DST ALPHA
  648. */
  649. static readonly ALPHA_EXCLUSION: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** 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 */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** 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 */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** 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 */
  686. static readonly GEQUAL: number;
  687. /** 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 */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = nearest */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * 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.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module BABYLON {
  1044. /**
  1045. * This represents the required contract to create a new type of texture loader.
  1046. */
  1047. export interface IInternalTextureLoader {
  1048. /**
  1049. * Defines wether the loader supports cascade loading the different faces.
  1050. */
  1051. supportCascades: boolean;
  1052. /**
  1053. * This returns if the loader support the current file information.
  1054. * @param extension defines the file extension of the file being loaded
  1055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1056. * @param fallback defines the fallback internal texture if any
  1057. * @param isBase64 defines whether the texture is encoded as a base64
  1058. * @param isBuffer defines whether the texture data are stored as a buffer
  1059. * @returns true if the loader can load the specified file
  1060. */
  1061. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1062. /**
  1063. * Transform the url before loading if required.
  1064. * @param rootUrl the url of the texture
  1065. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1066. * @returns the transformed texture
  1067. */
  1068. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1069. /**
  1070. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1071. * @param rootUrl the url of the texture
  1072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1073. * @returns the fallback texture
  1074. */
  1075. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1076. /**
  1077. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param createPolynomials will be true if polynomials have been requested
  1081. * @param onLoad defines the callback to trigger once the texture is ready
  1082. * @param onError defines the callback to trigger in case of error
  1083. */
  1084. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1085. /**
  1086. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param callback defines the method to call once ready to upload
  1090. */
  1091. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1092. }
  1093. }
  1094. declare module BABYLON {
  1095. /**
  1096. * Class used to store and describe the pipeline context associated with an effect
  1097. */
  1098. export interface IPipelineContext {
  1099. /**
  1100. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1101. */
  1102. isAsync: boolean;
  1103. /**
  1104. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1105. */
  1106. isReady: boolean;
  1107. /** @hidden */
  1108. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1109. }
  1110. }
  1111. declare module BABYLON {
  1112. /**
  1113. * Class used to store gfx data (like WebGLBuffer)
  1114. */
  1115. export class DataBuffer {
  1116. /**
  1117. * Gets or sets the number of objects referencing this buffer
  1118. */
  1119. references: number;
  1120. /** Gets or sets the size of the underlying buffer */
  1121. capacity: number;
  1122. /**
  1123. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1124. */
  1125. is32Bits: boolean;
  1126. /**
  1127. * Gets the underlying buffer
  1128. */
  1129. readonly underlyingResource: any;
  1130. }
  1131. }
  1132. declare module BABYLON {
  1133. /** @hidden */
  1134. export interface IShaderProcessor {
  1135. attributeProcessor?: (attribute: string) => string;
  1136. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1137. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1138. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1139. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1140. lineProcessor?: (line: string, isFragment: boolean) => string;
  1141. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1142. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1143. }
  1144. }
  1145. declare module BABYLON {
  1146. /** @hidden */
  1147. export interface ProcessingOptions {
  1148. defines: string[];
  1149. indexParameters: any;
  1150. isFragment: boolean;
  1151. shouldUseHighPrecisionShader: boolean;
  1152. supportsUniformBuffers: boolean;
  1153. shadersRepository: string;
  1154. includesShadersStore: {
  1155. [key: string]: string;
  1156. };
  1157. processor?: IShaderProcessor;
  1158. version: string;
  1159. platformName: string;
  1160. lookForClosingBracketForUniformBuffer?: boolean;
  1161. }
  1162. }
  1163. declare module BABYLON {
  1164. /** @hidden */
  1165. export class ShaderCodeNode {
  1166. line: string;
  1167. children: ShaderCodeNode[];
  1168. additionalDefineKey?: string;
  1169. additionalDefineValue?: string;
  1170. isValid(preprocessors: {
  1171. [key: string]: string;
  1172. }): boolean;
  1173. process(preprocessors: {
  1174. [key: string]: string;
  1175. }, options: ProcessingOptions): string;
  1176. }
  1177. }
  1178. declare module BABYLON {
  1179. /** @hidden */
  1180. export class ShaderCodeCursor {
  1181. private _lines;
  1182. lineIndex: number;
  1183. readonly currentLine: string;
  1184. readonly canRead: boolean;
  1185. lines: string[];
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1191. process(preprocessors: {
  1192. [key: string]: string;
  1193. }, options: ProcessingOptions): string;
  1194. }
  1195. }
  1196. declare module BABYLON {
  1197. /** @hidden */
  1198. export class ShaderDefineExpression {
  1199. isTrue(preprocessors: {
  1200. [key: string]: string;
  1201. }): boolean;
  1202. }
  1203. }
  1204. declare module BABYLON {
  1205. /** @hidden */
  1206. export class ShaderCodeTestNode extends ShaderCodeNode {
  1207. testExpression: ShaderDefineExpression;
  1208. isValid(preprocessors: {
  1209. [key: string]: string;
  1210. }): boolean;
  1211. }
  1212. }
  1213. declare module BABYLON {
  1214. /** @hidden */
  1215. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1216. define: string;
  1217. not: boolean;
  1218. constructor(define: string, not?: boolean);
  1219. isTrue(preprocessors: {
  1220. [key: string]: string;
  1221. }): boolean;
  1222. }
  1223. }
  1224. declare module BABYLON {
  1225. /** @hidden */
  1226. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1227. leftOperand: ShaderDefineExpression;
  1228. rightOperand: ShaderDefineExpression;
  1229. isTrue(preprocessors: {
  1230. [key: string]: string;
  1231. }): boolean;
  1232. }
  1233. }
  1234. declare module BABYLON {
  1235. /** @hidden */
  1236. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module BABYLON {
  1245. /** @hidden */
  1246. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. operand: string;
  1249. testValue: string;
  1250. constructor(define: string, operand: string, testValue: string);
  1251. isTrue(preprocessors: {
  1252. [key: string]: string;
  1253. }): boolean;
  1254. }
  1255. }
  1256. declare module BABYLON {
  1257. /**
  1258. * Class used to enable access to offline support
  1259. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1260. */
  1261. export interface IOfflineProvider {
  1262. /**
  1263. * Gets a boolean indicating if scene must be saved in the database
  1264. */
  1265. enableSceneOffline: boolean;
  1266. /**
  1267. * Gets a boolean indicating if textures must be saved in the database
  1268. */
  1269. enableTexturesOffline: boolean;
  1270. /**
  1271. * Open the offline support and make it available
  1272. * @param successCallback defines the callback to call on success
  1273. * @param errorCallback defines the callback to call on error
  1274. */
  1275. open(successCallback: () => void, errorCallback: () => void): void;
  1276. /**
  1277. * Loads an image from the offline support
  1278. * @param url defines the url to load from
  1279. * @param image defines the target DOM image
  1280. */
  1281. loadImage(url: string, image: HTMLImageElement): void;
  1282. /**
  1283. * Loads a file from offline support
  1284. * @param url defines the URL to load from
  1285. * @param sceneLoaded defines a callback to call on success
  1286. * @param progressCallBack defines a callback to call when progress changed
  1287. * @param errorCallback defines a callback to call on error
  1288. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1289. */
  1290. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /**
  1295. * Class used to help managing file picking and drag'n'drop
  1296. * File Storage
  1297. */
  1298. export class FilesInputStore {
  1299. /**
  1300. * List of files ready to be loaded
  1301. */
  1302. static FilesToLoad: {
  1303. [key: string]: File;
  1304. };
  1305. }
  1306. }
  1307. declare module BABYLON {
  1308. /**
  1309. * Class used to define a retry strategy when error happens while loading assets
  1310. */
  1311. export class RetryStrategy {
  1312. /**
  1313. * Function used to defines an exponential back off strategy
  1314. * @param maxRetries defines the maximum number of retries (3 by default)
  1315. * @param baseInterval defines the interval between retries
  1316. * @returns the strategy function to use
  1317. */
  1318. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1319. }
  1320. }
  1321. declare module BABYLON {
  1322. /**
  1323. * @ignore
  1324. * Application error to support additional information when loading a file
  1325. */
  1326. export abstract class BaseError extends Error {
  1327. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1328. }
  1329. }
  1330. declare module BABYLON {
  1331. /** @ignore */
  1332. export class LoadFileError extends BaseError {
  1333. request?: WebRequest;
  1334. file?: File;
  1335. /**
  1336. * Creates a new LoadFileError
  1337. * @param message defines the message of the error
  1338. * @param request defines the optional web request
  1339. * @param file defines the optional file
  1340. */
  1341. constructor(message: string, object?: WebRequest | File);
  1342. }
  1343. /** @ignore */
  1344. export class RequestFileError extends BaseError {
  1345. request: WebRequest;
  1346. /**
  1347. * Creates a new LoadFileError
  1348. * @param message defines the message of the error
  1349. * @param request defines the optional web request
  1350. */
  1351. constructor(message: string, request: WebRequest);
  1352. }
  1353. /** @ignore */
  1354. export class ReadFileError extends BaseError {
  1355. file: File;
  1356. /**
  1357. * Creates a new ReadFileError
  1358. * @param message defines the message of the error
  1359. * @param file defines the optional file
  1360. */
  1361. constructor(message: string, file: File);
  1362. }
  1363. /**
  1364. * @hidden
  1365. */
  1366. export class FileTools {
  1367. /**
  1368. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1369. */
  1370. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1371. /**
  1372. * Gets or sets the base URL to use to load assets
  1373. */
  1374. static BaseUrl: string;
  1375. /**
  1376. * Default behaviour for cors in the application.
  1377. * It can be a string if the expected behavior is identical in the entire app.
  1378. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1379. */
  1380. static CorsBehavior: string | ((url: string | string[]) => string);
  1381. /**
  1382. * Gets or sets a function used to pre-process url before using them to load assets
  1383. */
  1384. static PreprocessUrl: (url: string) => string;
  1385. /**
  1386. * Removes unwanted characters from an url
  1387. * @param url defines the url to clean
  1388. * @returns the cleaned url
  1389. */
  1390. private static _CleanUrl;
  1391. /**
  1392. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1393. * @param url define the url we are trying
  1394. * @param element define the dom element where to configure the cors policy
  1395. */
  1396. static SetCorsBehavior(url: string | string[], element: {
  1397. crossOrigin: string | null;
  1398. }): void;
  1399. /**
  1400. * Loads an image as an HTMLImageElement.
  1401. * @param input url string, ArrayBuffer, or Blob to load
  1402. * @param onLoad callback called when the image successfully loads
  1403. * @param onError callback called when the image fails to load
  1404. * @param offlineProvider offline provider for caching
  1405. * @param mimeType optional mime type
  1406. * @returns the HTMLImageElement of the loaded image
  1407. */
  1408. 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>;
  1409. /**
  1410. * Reads a file from a File object
  1411. * @param file defines the file to load
  1412. * @param onSuccess defines the callback to call when data is loaded
  1413. * @param onProgress defines the callback to call during loading process
  1414. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1415. * @param onError defines the callback to call when an error occurs
  1416. * @returns a file request object
  1417. */
  1418. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1419. /**
  1420. * Loads a file from a url
  1421. * @param url url to load
  1422. * @param onSuccess callback called when the file successfully loads
  1423. * @param onProgress callback called while file is loading (if the server supports this mode)
  1424. * @param offlineProvider defines the offline provider for caching
  1425. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1426. * @param onError callback called when the file fails to load
  1427. * @returns a file request object
  1428. */
  1429. 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;
  1430. /**
  1431. * Loads a file
  1432. * @param url url to load
  1433. * @param onSuccess callback called when the file successfully loads
  1434. * @param onProgress callback called while file is loading (if the server supports this mode)
  1435. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1436. * @param onError callback called when the file fails to load
  1437. * @param onOpened callback called when the web request is opened
  1438. * @returns a file request object
  1439. */
  1440. 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;
  1441. /**
  1442. * Checks if the loaded document was accessed via `file:`-Protocol.
  1443. * @returns boolean
  1444. */
  1445. static IsFileURL(): boolean;
  1446. }
  1447. }
  1448. declare module BABYLON {
  1449. /** @hidden */
  1450. export class ShaderProcessor {
  1451. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1452. private static _ProcessPrecision;
  1453. private static _ExtractOperation;
  1454. private static _BuildSubExpression;
  1455. private static _BuildExpression;
  1456. private static _MoveCursorWithinIf;
  1457. private static _MoveCursor;
  1458. private static _EvaluatePreProcessors;
  1459. private static _PreparePreProcessors;
  1460. private static _ProcessShaderConversion;
  1461. private static _ProcessIncludes;
  1462. }
  1463. }
  1464. declare module BABYLON {
  1465. /**
  1466. * @hidden
  1467. */
  1468. export interface IColor4Like {
  1469. r: float;
  1470. g: float;
  1471. b: float;
  1472. a: float;
  1473. }
  1474. /**
  1475. * @hidden
  1476. */
  1477. export interface IColor3Like {
  1478. r: float;
  1479. g: float;
  1480. b: float;
  1481. }
  1482. /**
  1483. * @hidden
  1484. */
  1485. export interface IVector4Like {
  1486. x: float;
  1487. y: float;
  1488. z: float;
  1489. w: float;
  1490. }
  1491. /**
  1492. * @hidden
  1493. */
  1494. export interface IVector3Like {
  1495. x: float;
  1496. y: float;
  1497. z: float;
  1498. }
  1499. /**
  1500. * @hidden
  1501. */
  1502. export interface IVector2Like {
  1503. x: float;
  1504. y: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IMatrixLike {
  1510. toArray(): DeepImmutable<Float32Array>;
  1511. updateFlag: int;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IViewportLike {
  1517. x: float;
  1518. y: float;
  1519. width: float;
  1520. height: float;
  1521. }
  1522. /**
  1523. * @hidden
  1524. */
  1525. export interface IPlaneLike {
  1526. normal: IVector3Like;
  1527. d: float;
  1528. normalize(): void;
  1529. }
  1530. }
  1531. declare module BABYLON {
  1532. /**
  1533. * Interface used to define common properties for effect fallbacks
  1534. */
  1535. export interface IEffectFallbacks {
  1536. /**
  1537. * Removes the defines that should be removed when falling back.
  1538. * @param currentDefines defines the current define statements for the shader.
  1539. * @param effect defines the current effect we try to compile
  1540. * @returns The resulting defines with defines of the current rank removed.
  1541. */
  1542. reduce(currentDefines: string, effect: Effect): string;
  1543. /**
  1544. * Removes the fallback from the bound mesh.
  1545. */
  1546. unBindMesh(): void;
  1547. /**
  1548. * Checks to see if more fallbacks are still availible.
  1549. */
  1550. hasMoreFallbacks: boolean;
  1551. }
  1552. }
  1553. declare module BABYLON {
  1554. /**
  1555. * Class used to evalaute queries containing `and` and `or` operators
  1556. */
  1557. export class AndOrNotEvaluator {
  1558. /**
  1559. * Evaluate a query
  1560. * @param query defines the query to evaluate
  1561. * @param evaluateCallback defines the callback used to filter result
  1562. * @returns true if the query matches
  1563. */
  1564. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1565. private static _HandleParenthesisContent;
  1566. private static _SimplifyNegation;
  1567. }
  1568. }
  1569. declare module BABYLON {
  1570. /**
  1571. * Class used to store custom tags
  1572. */
  1573. export class Tags {
  1574. /**
  1575. * Adds support for tags on the given object
  1576. * @param obj defines the object to use
  1577. */
  1578. static EnableFor(obj: any): void;
  1579. /**
  1580. * Removes tags support
  1581. * @param obj defines the object to use
  1582. */
  1583. static DisableFor(obj: any): void;
  1584. /**
  1585. * Gets a boolean indicating if the given object has tags
  1586. * @param obj defines the object to use
  1587. * @returns a boolean
  1588. */
  1589. static HasTags(obj: any): boolean;
  1590. /**
  1591. * Gets the tags available on a given object
  1592. * @param obj defines the object to use
  1593. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1594. * @returns the tags
  1595. */
  1596. static GetTags(obj: any, asString?: boolean): any;
  1597. /**
  1598. * Adds tags to an object
  1599. * @param obj defines the object to use
  1600. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1601. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1602. */
  1603. static AddTagsTo(obj: any, tagsString: string): void;
  1604. /**
  1605. * @hidden
  1606. */
  1607. static _AddTagTo(obj: any, tag: string): void;
  1608. /**
  1609. * Removes specific tags from a specific object
  1610. * @param obj defines the object to use
  1611. * @param tagsString defines the tags to remove
  1612. */
  1613. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1614. /**
  1615. * @hidden
  1616. */
  1617. static _RemoveTagFrom(obj: any, tag: string): void;
  1618. /**
  1619. * Defines if tags hosted on an object match a given query
  1620. * @param obj defines the object to use
  1621. * @param tagsQuery defines the tag query
  1622. * @returns a boolean
  1623. */
  1624. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1625. }
  1626. }
  1627. declare module BABYLON {
  1628. /**
  1629. * Scalar computation library
  1630. */
  1631. export class Scalar {
  1632. /**
  1633. * Two pi constants convenient for computation.
  1634. */
  1635. static TwoPi: number;
  1636. /**
  1637. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. * @param a number
  1639. * @param b number
  1640. * @param epsilon (default = 1.401298E-45)
  1641. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1642. */
  1643. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1644. /**
  1645. * Returns a string : the upper case translation of the number i to hexadecimal.
  1646. * @param i number
  1647. * @returns the upper case translation of the number i to hexadecimal.
  1648. */
  1649. static ToHex(i: number): string;
  1650. /**
  1651. * Returns -1 if value is negative and +1 is value is positive.
  1652. * @param value the value
  1653. * @returns the value itself if it's equal to zero.
  1654. */
  1655. static Sign(value: number): number;
  1656. /**
  1657. * Returns the value itself if it's between min and max.
  1658. * Returns min if the value is lower than min.
  1659. * Returns max if the value is greater than max.
  1660. * @param value the value to clmap
  1661. * @param min the min value to clamp to (default: 0)
  1662. * @param max the max value to clamp to (default: 1)
  1663. * @returns the clamped value
  1664. */
  1665. static Clamp(value: number, min?: number, max?: number): number;
  1666. /**
  1667. * the log2 of value.
  1668. * @param value the value to compute log2 of
  1669. * @returns the log2 of value.
  1670. */
  1671. static Log2(value: number): number;
  1672. /**
  1673. * Loops the value, so that it is never larger than length and never smaller than 0.
  1674. *
  1675. * This is similar to the modulo operator but it works with floating point numbers.
  1676. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1677. * With t = 5 and length = 2.5, the result would be 0.0.
  1678. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1679. * @param value the value
  1680. * @param length the length
  1681. * @returns the looped value
  1682. */
  1683. static Repeat(value: number, length: number): number;
  1684. /**
  1685. * Normalize the value between 0.0 and 1.0 using min and max values
  1686. * @param value value to normalize
  1687. * @param min max to normalize between
  1688. * @param max min to normalize between
  1689. * @returns the normalized value
  1690. */
  1691. static Normalize(value: number, min: number, max: number): number;
  1692. /**
  1693. * Denormalize the value from 0.0 and 1.0 using min and max values
  1694. * @param normalized value to denormalize
  1695. * @param min max to denormalize between
  1696. * @param max min to denormalize between
  1697. * @returns the denormalized value
  1698. */
  1699. static Denormalize(normalized: number, min: number, max: number): number;
  1700. /**
  1701. * Calculates the shortest difference between two given angles given in degrees.
  1702. * @param current current angle in degrees
  1703. * @param target target angle in degrees
  1704. * @returns the delta
  1705. */
  1706. static DeltaAngle(current: number, target: number): number;
  1707. /**
  1708. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1709. * @param tx value
  1710. * @param length length
  1711. * @returns The returned value will move back and forth between 0 and length
  1712. */
  1713. static PingPong(tx: number, length: number): number;
  1714. /**
  1715. * Interpolates between min and max with smoothing at the limits.
  1716. *
  1717. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1718. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1719. * @param from from
  1720. * @param to to
  1721. * @param tx value
  1722. * @returns the smooth stepped value
  1723. */
  1724. static SmoothStep(from: number, to: number, tx: number): number;
  1725. /**
  1726. * Moves a value current towards target.
  1727. *
  1728. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1729. * Negative values of maxDelta pushes the value away from target.
  1730. * @param current current value
  1731. * @param target target value
  1732. * @param maxDelta max distance to move
  1733. * @returns resulting value
  1734. */
  1735. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1736. /**
  1737. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1738. *
  1739. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1740. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1741. * @param current current value
  1742. * @param target target value
  1743. * @param maxDelta max distance to move
  1744. * @returns resulting angle
  1745. */
  1746. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1747. /**
  1748. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1749. * @param start start value
  1750. * @param end target value
  1751. * @param amount amount to lerp between
  1752. * @returns the lerped value
  1753. */
  1754. static Lerp(start: number, end: number, amount: number): number;
  1755. /**
  1756. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1757. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1758. * @param start start value
  1759. * @param end target value
  1760. * @param amount amount to lerp between
  1761. * @returns the lerped value
  1762. */
  1763. static LerpAngle(start: number, end: number, amount: number): number;
  1764. /**
  1765. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1766. * @param a start value
  1767. * @param b target value
  1768. * @param value value between a and b
  1769. * @returns the inverseLerp value
  1770. */
  1771. static InverseLerp(a: number, b: number, value: number): number;
  1772. /**
  1773. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1774. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1775. * @param value1 spline value
  1776. * @param tangent1 spline value
  1777. * @param value2 spline value
  1778. * @param tangent2 spline value
  1779. * @param amount input value
  1780. * @returns hermite result
  1781. */
  1782. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1783. /**
  1784. * Returns a random float number between and min and max values
  1785. * @param min min value of random
  1786. * @param max max value of random
  1787. * @returns random value
  1788. */
  1789. static RandomRange(min: number, max: number): number;
  1790. /**
  1791. * This function returns percentage of a number in a given range.
  1792. *
  1793. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1794. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1795. * @param number to convert to percentage
  1796. * @param min min range
  1797. * @param max max range
  1798. * @returns the percentage
  1799. */
  1800. static RangeToPercent(number: number, min: number, max: number): number;
  1801. /**
  1802. * This function returns number that corresponds to the percentage in a given range.
  1803. *
  1804. * PercentToRange(0.34,0,100) will return 34.
  1805. * @param percent to convert to number
  1806. * @param min min range
  1807. * @param max max range
  1808. * @returns the number
  1809. */
  1810. static PercentToRange(percent: number, min: number, max: number): number;
  1811. /**
  1812. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1813. * @param angle The angle to normalize in radian.
  1814. * @return The converted angle.
  1815. */
  1816. static NormalizeRadians(angle: number): number;
  1817. }
  1818. }
  1819. declare module BABYLON {
  1820. /**
  1821. * Constant used to convert a value to gamma space
  1822. * @ignorenaming
  1823. */
  1824. export const ToGammaSpace: number;
  1825. /**
  1826. * Constant used to convert a value to linear space
  1827. * @ignorenaming
  1828. */
  1829. export const ToLinearSpace = 2.2;
  1830. /**
  1831. * Constant used to define the minimal number value in Babylon.js
  1832. * @ignorenaming
  1833. */
  1834. let Epsilon: number;
  1835. }
  1836. declare module BABYLON {
  1837. /**
  1838. * Class used to represent a viewport on screen
  1839. */
  1840. export class Viewport {
  1841. /** viewport left coordinate */
  1842. x: number;
  1843. /** viewport top coordinate */
  1844. y: number;
  1845. /**viewport width */
  1846. width: number;
  1847. /** viewport height */
  1848. height: number;
  1849. /**
  1850. * Creates a Viewport object located at (x, y) and sized (width, height)
  1851. * @param x defines viewport left coordinate
  1852. * @param y defines viewport top coordinate
  1853. * @param width defines the viewport width
  1854. * @param height defines the viewport height
  1855. */
  1856. constructor(
  1857. /** viewport left coordinate */
  1858. x: number,
  1859. /** viewport top coordinate */
  1860. y: number,
  1861. /**viewport width */
  1862. width: number,
  1863. /** viewport height */
  1864. height: number);
  1865. /**
  1866. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1867. * @param renderWidth defines the rendering width
  1868. * @param renderHeight defines the rendering height
  1869. * @returns a new Viewport
  1870. */
  1871. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1872. /**
  1873. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1874. * @param renderWidth defines the rendering width
  1875. * @param renderHeight defines the rendering height
  1876. * @param ref defines the target viewport
  1877. * @returns the current viewport
  1878. */
  1879. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1880. /**
  1881. * Returns a new Viewport copied from the current one
  1882. * @returns a new Viewport
  1883. */
  1884. clone(): Viewport;
  1885. }
  1886. }
  1887. declare module BABYLON {
  1888. /**
  1889. * Class containing a set of static utilities functions for arrays.
  1890. */
  1891. export class ArrayTools {
  1892. /**
  1893. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1894. * @param size the number of element to construct and put in the array
  1895. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1896. * @returns a new array filled with new objects
  1897. */
  1898. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class representing a vector containing 2 coordinates
  1904. */
  1905. export class Vector2 {
  1906. /** defines the first coordinate */
  1907. x: number;
  1908. /** defines the second coordinate */
  1909. y: number;
  1910. /**
  1911. * Creates a new Vector2 from the given x and y coordinates
  1912. * @param x defines the first coordinate
  1913. * @param y defines the second coordinate
  1914. */
  1915. constructor(
  1916. /** defines the first coordinate */
  1917. x?: number,
  1918. /** defines the second coordinate */
  1919. y?: number);
  1920. /**
  1921. * Gets a string with the Vector2 coordinates
  1922. * @returns a string with the Vector2 coordinates
  1923. */
  1924. toString(): string;
  1925. /**
  1926. * Gets class name
  1927. * @returns the string "Vector2"
  1928. */
  1929. getClassName(): string;
  1930. /**
  1931. * Gets current vector hash code
  1932. * @returns the Vector2 hash code as a number
  1933. */
  1934. getHashCode(): number;
  1935. /**
  1936. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1937. * @param array defines the source array
  1938. * @param index defines the offset in source array
  1939. * @returns the current Vector2
  1940. */
  1941. toArray(array: FloatArray, index?: number): Vector2;
  1942. /**
  1943. * Copy the current vector to an array
  1944. * @returns a new array with 2 elements: the Vector2 coordinates.
  1945. */
  1946. asArray(): number[];
  1947. /**
  1948. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1949. * @param source defines the source Vector2
  1950. * @returns the current updated Vector2
  1951. */
  1952. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1953. /**
  1954. * Sets the Vector2 coordinates with the given floats
  1955. * @param x defines the first coordinate
  1956. * @param y defines the second coordinate
  1957. * @returns the current updated Vector2
  1958. */
  1959. copyFromFloats(x: number, y: number): Vector2;
  1960. /**
  1961. * Sets the Vector2 coordinates with the given floats
  1962. * @param x defines the first coordinate
  1963. * @param y defines the second coordinate
  1964. * @returns the current updated Vector2
  1965. */
  1966. set(x: number, y: number): Vector2;
  1967. /**
  1968. * Add another vector with the current one
  1969. * @param otherVector defines the other vector
  1970. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1971. */
  1972. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1973. /**
  1974. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1975. * @param otherVector defines the other vector
  1976. * @param result defines the target vector
  1977. * @returns the unmodified current Vector2
  1978. */
  1979. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1980. /**
  1981. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1982. * @param otherVector defines the other vector
  1983. * @returns the current updated Vector2
  1984. */
  1985. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1988. * @param otherVector defines the other vector
  1989. * @returns a new Vector2
  1990. */
  1991. addVector3(otherVector: Vector3): Vector2;
  1992. /**
  1993. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2
  1996. */
  1997. subtract(otherVector: Vector2): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Multiplies in place the current Vector2 coordinates by the given ones
  2013. * @param otherVector defines the other vector
  2014. * @returns the current updated Vector2
  2015. */
  2016. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2017. /**
  2018. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2023. /**
  2024. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2032. * @param x defines the first coordinate
  2033. * @param y defines the second coordinate
  2034. * @returns a new Vector2
  2035. */
  2036. multiplyByFloats(x: number, y: number): Vector2;
  2037. /**
  2038. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @returns a new Vector2
  2041. */
  2042. divide(otherVector: Vector2): Vector2;
  2043. /**
  2044. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2045. * @param otherVector defines the other vector
  2046. * @param result defines the target vector
  2047. * @returns the unmodified current Vector2
  2048. */
  2049. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2050. /**
  2051. * Divides the current Vector2 coordinates by the given ones
  2052. * @param otherVector defines the other vector
  2053. * @returns the current updated Vector2
  2054. */
  2055. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2056. /**
  2057. * Gets a new Vector2 with current Vector2 negated coordinates
  2058. * @returns a new Vector2
  2059. */
  2060. negate(): Vector2;
  2061. /**
  2062. * Multiply the Vector2 coordinates by scale
  2063. * @param scale defines the scaling factor
  2064. * @returns the current updated Vector2
  2065. */
  2066. scaleInPlace(scale: number): Vector2;
  2067. /**
  2068. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2069. * @param scale defines the scaling factor
  2070. * @returns a new Vector2
  2071. */
  2072. scale(scale: number): Vector2;
  2073. /**
  2074. * Scale the current Vector2 values by a factor to a given Vector2
  2075. * @param scale defines the scale factor
  2076. * @param result defines the Vector2 object where to store the result
  2077. * @returns the unmodified current Vector2
  2078. */
  2079. scaleToRef(scale: number, result: Vector2): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Gets a boolean if two vectors are equals
  2089. * @param otherVector defines the other vector
  2090. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2091. */
  2092. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2093. /**
  2094. * Gets a boolean if two vectors are equals (using an epsilon value)
  2095. * @param otherVector defines the other vector
  2096. * @param epsilon defines the minimal distance to consider equality
  2097. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2098. */
  2099. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2100. /**
  2101. * Gets a new Vector2 from current Vector2 floored values
  2102. * @returns a new Vector2
  2103. */
  2104. floor(): Vector2;
  2105. /**
  2106. * Gets a new Vector2 from current Vector2 floored values
  2107. * @returns a new Vector2
  2108. */
  2109. fract(): Vector2;
  2110. /**
  2111. * Gets the length of the vector
  2112. * @returns the vector length (float)
  2113. */
  2114. length(): number;
  2115. /**
  2116. * Gets the vector squared length
  2117. * @returns the vector squared length (float)
  2118. */
  2119. lengthSquared(): number;
  2120. /**
  2121. * Normalize the vector
  2122. * @returns the current updated Vector2
  2123. */
  2124. normalize(): Vector2;
  2125. /**
  2126. * Gets a new Vector2 copied from the Vector2
  2127. * @returns a new Vector2
  2128. */
  2129. clone(): Vector2;
  2130. /**
  2131. * Gets a new Vector2(0, 0)
  2132. * @returns a new Vector2
  2133. */
  2134. static Zero(): Vector2;
  2135. /**
  2136. * Gets a new Vector2(1, 1)
  2137. * @returns a new Vector2
  2138. */
  2139. static One(): Vector2;
  2140. /**
  2141. * Gets a new Vector2 set from the given index element of the given array
  2142. * @param array defines the data source
  2143. * @param offset defines the offset in the data source
  2144. * @returns a new Vector2
  2145. */
  2146. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2147. /**
  2148. * Sets "result" from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @param result defines the target vector
  2152. */
  2153. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2154. /**
  2155. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2156. * @param value1 defines 1st point of control
  2157. * @param value2 defines 2nd point of control
  2158. * @param value3 defines 3rd point of control
  2159. * @param value4 defines 4th point of control
  2160. * @param amount defines the interpolation factor
  2161. * @returns a new Vector2
  2162. */
  2163. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2164. /**
  2165. * 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".
  2166. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2167. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2168. * @param value defines the value to clamp
  2169. * @param min defines the lower limit
  2170. * @param max defines the upper limit
  2171. * @returns a new Vector2
  2172. */
  2173. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2176. * @param value1 defines the 1st control point
  2177. * @param tangent1 defines the outgoing tangent
  2178. * @param value2 defines the 2nd control point
  2179. * @param tangent2 defines the incoming tangent
  2180. * @param amount defines the interpolation factor
  2181. * @returns a new Vector2
  2182. */
  2183. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2184. /**
  2185. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2186. * @param start defines the start vector
  2187. * @param end defines the end vector
  2188. * @param amount defines the interpolation factor
  2189. * @returns a new Vector2
  2190. */
  2191. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2192. /**
  2193. * Gets the dot product of the vector "left" and the vector "right"
  2194. * @param left defines first vector
  2195. * @param right defines second vector
  2196. * @returns the dot product (float)
  2197. */
  2198. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2199. /**
  2200. * Returns a new Vector2 equal to the normalized given vector
  2201. * @param vector defines the vector to normalize
  2202. * @returns a new Vector2
  2203. */
  2204. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2207. * @param left defines 1st vector
  2208. * @param right defines 2nd vector
  2209. * @returns a new Vector2
  2210. */
  2211. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2221. * @param vector defines the vector to transform
  2222. * @param transformation defines the matrix to apply
  2223. * @returns a new Vector2
  2224. */
  2225. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2226. /**
  2227. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @param result defines the target vector
  2231. */
  2232. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2233. /**
  2234. * Determines if a given vector is included in a triangle
  2235. * @param p defines the vector to test
  2236. * @param p0 defines 1st triangle point
  2237. * @param p1 defines 2nd triangle point
  2238. * @param p2 defines 3rd triangle point
  2239. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2240. */
  2241. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2242. /**
  2243. * Gets the distance between the vectors "value1" and "value2"
  2244. * @param value1 defines first vector
  2245. * @param value2 defines second vector
  2246. * @returns the distance between vectors
  2247. */
  2248. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2249. /**
  2250. * Returns the squared distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the squared distance between vectors
  2254. */
  2255. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns a new Vector2
  2261. */
  2262. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2263. /**
  2264. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2265. * @param p defines the middle point
  2266. * @param segA defines one point of the segment
  2267. * @param segB defines the other point of the segment
  2268. * @returns the shortest distance
  2269. */
  2270. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2271. }
  2272. /**
  2273. * Class used to store (x,y,z) vector representation
  2274. * A Vector3 is the main object used in 3D geometry
  2275. * It can represent etiher the coordinates of a point the space, either a direction
  2276. * Reminder: js uses a left handed forward facing system
  2277. */
  2278. export class Vector3 {
  2279. /**
  2280. * Defines the first coordinates (on X axis)
  2281. */
  2282. x: number;
  2283. /**
  2284. * Defines the second coordinates (on Y axis)
  2285. */
  2286. y: number;
  2287. /**
  2288. * Defines the third coordinates (on Z axis)
  2289. */
  2290. z: number;
  2291. private static _UpReadOnly;
  2292. private static _ZeroReadOnly;
  2293. /**
  2294. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2295. * @param x defines the first coordinates (on X axis)
  2296. * @param y defines the second coordinates (on Y axis)
  2297. * @param z defines the third coordinates (on Z axis)
  2298. */
  2299. constructor(
  2300. /**
  2301. * Defines the first coordinates (on X axis)
  2302. */
  2303. x?: number,
  2304. /**
  2305. * Defines the second coordinates (on Y axis)
  2306. */
  2307. y?: number,
  2308. /**
  2309. * Defines the third coordinates (on Z axis)
  2310. */
  2311. z?: number);
  2312. /**
  2313. * Creates a string representation of the Vector3
  2314. * @returns a string with the Vector3 coordinates.
  2315. */
  2316. toString(): string;
  2317. /**
  2318. * Gets the class name
  2319. * @returns the string "Vector3"
  2320. */
  2321. getClassName(): string;
  2322. /**
  2323. * Creates the Vector3 hash code
  2324. * @returns a number which tends to be unique between Vector3 instances
  2325. */
  2326. getHashCode(): number;
  2327. /**
  2328. * Creates an array containing three elements : the coordinates of the Vector3
  2329. * @returns a new array of numbers
  2330. */
  2331. asArray(): number[];
  2332. /**
  2333. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2334. * @param array defines the destination array
  2335. * @param index defines the offset in the destination array
  2336. * @returns the current Vector3
  2337. */
  2338. toArray(array: FloatArray, index?: number): Vector3;
  2339. /**
  2340. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2341. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2342. */
  2343. toQuaternion(): Quaternion;
  2344. /**
  2345. * Adds the given vector to the current Vector3
  2346. * @param otherVector defines the second operand
  2347. * @returns the current updated Vector3
  2348. */
  2349. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2350. /**
  2351. * Adds the given coordinates to the current Vector3
  2352. * @param x defines the x coordinate of the operand
  2353. * @param y defines the y coordinate of the operand
  2354. * @param z defines the z coordinate of the operand
  2355. * @returns the current updated Vector3
  2356. */
  2357. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2358. /**
  2359. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2360. * @param otherVector defines the second operand
  2361. * @returns the resulting Vector3
  2362. */
  2363. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2366. * @param otherVector defines the second operand
  2367. * @param result defines the Vector3 object where to store the result
  2368. * @returns the current Vector3
  2369. */
  2370. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2371. /**
  2372. * Subtract the given vector from the current Vector3
  2373. * @param otherVector defines the second operand
  2374. * @returns the current updated Vector3
  2375. */
  2376. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2377. /**
  2378. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2379. * @param otherVector defines the second operand
  2380. * @returns the resulting Vector3
  2381. */
  2382. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2383. /**
  2384. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2385. * @param otherVector defines the second operand
  2386. * @param result defines the Vector3 object where to store the result
  2387. * @returns the current Vector3
  2388. */
  2389. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2390. /**
  2391. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2392. * @param x defines the x coordinate of the operand
  2393. * @param y defines the y coordinate of the operand
  2394. * @param z defines the z coordinate of the operand
  2395. * @returns the resulting Vector3
  2396. */
  2397. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2398. /**
  2399. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2400. * @param x defines the x coordinate of the operand
  2401. * @param y defines the y coordinate of the operand
  2402. * @param z defines the z coordinate of the operand
  2403. * @param result defines the Vector3 object where to store the result
  2404. * @returns the current Vector3
  2405. */
  2406. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2407. /**
  2408. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2409. * @returns a new Vector3
  2410. */
  2411. negate(): Vector3;
  2412. /**
  2413. * Multiplies the Vector3 coordinates by the float "scale"
  2414. * @param scale defines the multiplier factor
  2415. * @returns the current updated Vector3
  2416. */
  2417. scaleInPlace(scale: number): Vector3;
  2418. /**
  2419. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2420. * @param scale defines the multiplier factor
  2421. * @returns a new Vector3
  2422. */
  2423. scale(scale: number): Vector3;
  2424. /**
  2425. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2426. * @param scale defines the multiplier factor
  2427. * @param result defines the Vector3 object where to store the result
  2428. * @returns the current Vector3
  2429. */
  2430. scaleToRef(scale: number, result: Vector3): Vector3;
  2431. /**
  2432. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2433. * @param scale defines the scale factor
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the unmodified current Vector3
  2436. */
  2437. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2438. /**
  2439. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2440. * @param otherVector defines the second operand
  2441. * @returns true if both vectors are equals
  2442. */
  2443. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2444. /**
  2445. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2446. * @param otherVector defines the second operand
  2447. * @param epsilon defines the minimal distance to define values as equals
  2448. * @returns true if both vectors are distant less than epsilon
  2449. */
  2450. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2451. /**
  2452. * Returns true if the current Vector3 coordinates equals the given floats
  2453. * @param x defines the x coordinate of the operand
  2454. * @param y defines the y coordinate of the operand
  2455. * @param z defines the z coordinate of the operand
  2456. * @returns true if both vectors are equals
  2457. */
  2458. equalsToFloats(x: number, y: number, z: number): boolean;
  2459. /**
  2460. * Multiplies the current Vector3 coordinates by the given ones
  2461. * @param otherVector defines the second operand
  2462. * @returns the current updated Vector3
  2463. */
  2464. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2465. /**
  2466. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2467. * @param otherVector defines the second operand
  2468. * @returns the new Vector3
  2469. */
  2470. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2471. /**
  2472. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2473. * @param otherVector defines the second operand
  2474. * @param result defines the Vector3 object where to store the result
  2475. * @returns the current Vector3
  2476. */
  2477. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2478. /**
  2479. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2480. * @param x defines the x coordinate of the operand
  2481. * @param y defines the y coordinate of the operand
  2482. * @param z defines the z coordinate of the operand
  2483. * @returns the new Vector3
  2484. */
  2485. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2486. /**
  2487. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2488. * @param otherVector defines the second operand
  2489. * @returns the new Vector3
  2490. */
  2491. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2494. * @param otherVector defines the second operand
  2495. * @param result defines the Vector3 object where to store the result
  2496. * @returns the current Vector3
  2497. */
  2498. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2499. /**
  2500. * Divides the current Vector3 coordinates by the given ones.
  2501. * @param otherVector defines the second operand
  2502. * @returns the current updated Vector3
  2503. */
  2504. divideInPlace(otherVector: Vector3): Vector3;
  2505. /**
  2506. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2507. * @param other defines the second operand
  2508. * @returns the current updated Vector3
  2509. */
  2510. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2513. * @param other defines the second operand
  2514. * @returns the current updated Vector3
  2515. */
  2516. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2519. * @param x defines the x coordinate of the operand
  2520. * @param y defines the y coordinate of the operand
  2521. * @param z defines the z coordinate of the operand
  2522. * @returns the current updated Vector3
  2523. */
  2524. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2525. /**
  2526. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2527. * @param x defines the x coordinate of the operand
  2528. * @param y defines the y coordinate of the operand
  2529. * @param z defines the z coordinate of the operand
  2530. * @returns the current updated Vector3
  2531. */
  2532. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2533. /**
  2534. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2535. * Check if is non uniform within a certain amount of decimal places to account for this
  2536. * @param epsilon the amount the values can differ
  2537. * @returns if the the vector is non uniform to a certain number of decimal places
  2538. */
  2539. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2540. /**
  2541. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2542. */
  2543. readonly isNonUniform: boolean;
  2544. /**
  2545. * Gets a new Vector3 from current Vector3 floored values
  2546. * @returns a new Vector3
  2547. */
  2548. floor(): Vector3;
  2549. /**
  2550. * Gets a new Vector3 from current Vector3 floored values
  2551. * @returns a new Vector3
  2552. */
  2553. fract(): Vector3;
  2554. /**
  2555. * Gets the length of the Vector3
  2556. * @returns the length of the Vector3
  2557. */
  2558. length(): number;
  2559. /**
  2560. * Gets the squared length of the Vector3
  2561. * @returns squared length of the Vector3
  2562. */
  2563. lengthSquared(): number;
  2564. /**
  2565. * Normalize the current Vector3.
  2566. * Please note that this is an in place operation.
  2567. * @returns the current updated Vector3
  2568. */
  2569. normalize(): Vector3;
  2570. /**
  2571. * Reorders the x y z properties of the vector in place
  2572. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2573. * @returns the current updated vector
  2574. */
  2575. reorderInPlace(order: string): this;
  2576. /**
  2577. * Rotates the vector around 0,0,0 by a quaternion
  2578. * @param quaternion the rotation quaternion
  2579. * @param result vector to store the result
  2580. * @returns the resulting vector
  2581. */
  2582. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2583. /**
  2584. * Rotates a vector around a given point
  2585. * @param quaternion the rotation quaternion
  2586. * @param point the point to rotate around
  2587. * @param result vector to store the result
  2588. * @returns the resulting vector
  2589. */
  2590. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2591. /**
  2592. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2593. * The cross product is then orthogonal to both current and "other"
  2594. * @param other defines the right operand
  2595. * @returns the cross product
  2596. */
  2597. cross(other: Vector3): Vector3;
  2598. /**
  2599. * Normalize the current Vector3 with the given input length.
  2600. * Please note that this is an in place operation.
  2601. * @param len the length of the vector
  2602. * @returns the current updated Vector3
  2603. */
  2604. normalizeFromLength(len: number): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 to a new vector
  2607. * @returns the new Vector3
  2608. */
  2609. normalizeToNew(): Vector3;
  2610. /**
  2611. * Normalize the current Vector3 to the reference
  2612. * @param reference define the Vector3 to update
  2613. * @returns the updated Vector3
  2614. */
  2615. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2616. /**
  2617. * Creates a new Vector3 copied from the current Vector3
  2618. * @returns the new Vector3
  2619. */
  2620. clone(): Vector3;
  2621. /**
  2622. * Copies the given vector coordinates to the current Vector3 ones
  2623. * @param source defines the source Vector3
  2624. * @returns the current updated Vector3
  2625. */
  2626. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2627. /**
  2628. * Copies the given floats to the current Vector3 coordinates
  2629. * @param x defines the x coordinate of the operand
  2630. * @param y defines the y coordinate of the operand
  2631. * @param z defines the z coordinate of the operand
  2632. * @returns the current updated Vector3
  2633. */
  2634. copyFromFloats(x: number, y: number, z: number): Vector3;
  2635. /**
  2636. * Copies the given floats to the current Vector3 coordinates
  2637. * @param x defines the x coordinate of the operand
  2638. * @param y defines the y coordinate of the operand
  2639. * @param z defines the z coordinate of the operand
  2640. * @returns the current updated Vector3
  2641. */
  2642. set(x: number, y: number, z: number): Vector3;
  2643. /**
  2644. * Copies the given float to the current Vector3 coordinates
  2645. * @param v defines the x, y and z coordinates of the operand
  2646. * @returns the current updated Vector3
  2647. */
  2648. setAll(v: number): Vector3;
  2649. /**
  2650. * Get the clip factor between two vectors
  2651. * @param vector0 defines the first operand
  2652. * @param vector1 defines the second operand
  2653. * @param axis defines the axis to use
  2654. * @param size defines the size along the axis
  2655. * @returns the clip factor
  2656. */
  2657. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2658. /**
  2659. * Get angle between two vectors
  2660. * @param vector0 angle between vector0 and vector1
  2661. * @param vector1 angle between vector0 and vector1
  2662. * @param normal direction of the normal
  2663. * @return the angle between vector0 and vector1
  2664. */
  2665. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2666. /**
  2667. * Returns a new Vector3 set from the index "offset" of the given array
  2668. * @param array defines the source array
  2669. * @param offset defines the offset in the source array
  2670. * @returns the new Vector3
  2671. */
  2672. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2673. /**
  2674. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2675. * @param array defines the source array
  2676. * @param offset defines the offset in the source array
  2677. * @returns the new Vector3
  2678. * @deprecated Please use FromArray instead.
  2679. */
  2680. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2681. /**
  2682. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2683. * @param array defines the source array
  2684. * @param offset defines the offset in the source array
  2685. * @param result defines the Vector3 where to store the result
  2686. */
  2687. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2688. /**
  2689. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2690. * @param array defines the source array
  2691. * @param offset defines the offset in the source array
  2692. * @param result defines the Vector3 where to store the result
  2693. * @deprecated Please use FromArrayToRef instead.
  2694. */
  2695. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2696. /**
  2697. * Sets the given vector "result" with the given floats.
  2698. * @param x defines the x coordinate of the source
  2699. * @param y defines the y coordinate of the source
  2700. * @param z defines the z coordinate of the source
  2701. * @param result defines the Vector3 where to store the result
  2702. */
  2703. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2704. /**
  2705. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2706. * @returns a new empty Vector3
  2707. */
  2708. static Zero(): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2711. * @returns a new unit Vector3
  2712. */
  2713. static One(): Vector3;
  2714. /**
  2715. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2716. * @returns a new up Vector3
  2717. */
  2718. static Up(): Vector3;
  2719. /**
  2720. * Gets a up Vector3 that must not be updated
  2721. */
  2722. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2723. /**
  2724. * Gets a zero Vector3 that must not be updated
  2725. */
  2726. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2727. /**
  2728. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2729. * @returns a new down Vector3
  2730. */
  2731. static Down(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2734. * @returns a new forward Vector3
  2735. */
  2736. static Forward(): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2739. * @returns a new forward Vector3
  2740. */
  2741. static Backward(): Vector3;
  2742. /**
  2743. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2744. * @returns a new right Vector3
  2745. */
  2746. static Right(): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2749. * @returns a new left Vector3
  2750. */
  2751. static Left(): Vector3;
  2752. /**
  2753. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2754. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2755. * @param vector defines the Vector3 to transform
  2756. * @param transformation defines the transformation matrix
  2757. * @returns the transformed Vector3
  2758. */
  2759. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2760. /**
  2761. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2762. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2763. * @param vector defines the Vector3 to transform
  2764. * @param transformation defines the transformation matrix
  2765. * @param result defines the Vector3 where to store the result
  2766. */
  2767. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2768. /**
  2769. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2770. * This method computes tranformed coordinates only, not transformed direction vectors
  2771. * @param x define the x coordinate of the source vector
  2772. * @param y define the y coordinate of the source vector
  2773. * @param z define the z coordinate of the source vector
  2774. * @param transformation defines the transformation matrix
  2775. * @param result defines the Vector3 where to store the result
  2776. */
  2777. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2778. /**
  2779. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2780. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2781. * @param vector defines the Vector3 to transform
  2782. * @param transformation defines the transformation matrix
  2783. * @returns the new Vector3
  2784. */
  2785. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2786. /**
  2787. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2788. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2789. * @param vector defines the Vector3 to transform
  2790. * @param transformation defines the transformation matrix
  2791. * @param result defines the Vector3 where to store the result
  2792. */
  2793. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2794. /**
  2795. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2796. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2797. * @param x define the x coordinate of the source vector
  2798. * @param y define the y coordinate of the source vector
  2799. * @param z define the z coordinate of the source vector
  2800. * @param transformation defines the transformation matrix
  2801. * @param result defines the Vector3 where to store the result
  2802. */
  2803. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2804. /**
  2805. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2806. * @param value1 defines the first control point
  2807. * @param value2 defines the second control point
  2808. * @param value3 defines the third control point
  2809. * @param value4 defines the fourth control point
  2810. * @param amount defines the amount on the spline to use
  2811. * @returns the new Vector3
  2812. */
  2813. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2814. /**
  2815. * 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"
  2816. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2817. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2818. * @param value defines the current value
  2819. * @param min defines the lower range value
  2820. * @param max defines the upper range value
  2821. * @returns the new Vector3
  2822. */
  2823. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2824. /**
  2825. * 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"
  2826. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2827. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2828. * @param value defines the current value
  2829. * @param min defines the lower range value
  2830. * @param max defines the upper range value
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2834. /**
  2835. * Checks if a given vector is inside a specific range
  2836. * @param v defines the vector to test
  2837. * @param min defines the minimum range
  2838. * @param max defines the maximum range
  2839. */
  2840. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2841. /**
  2842. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2843. * @param value1 defines the first control point
  2844. * @param tangent1 defines the first tangent vector
  2845. * @param value2 defines the second control point
  2846. * @param tangent2 defines the second tangent vector
  2847. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2848. * @returns the new Vector3
  2849. */
  2850. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2851. /**
  2852. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2853. * @param start defines the start value
  2854. * @param end defines the end value
  2855. * @param amount max defines amount between both (between 0 and 1)
  2856. * @returns the new Vector3
  2857. */
  2858. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2859. /**
  2860. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2861. * @param start defines the start value
  2862. * @param end defines the end value
  2863. * @param amount max defines amount between both (between 0 and 1)
  2864. * @param result defines the Vector3 where to store the result
  2865. */
  2866. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2867. /**
  2868. * Returns the dot product (float) between the vectors "left" and "right"
  2869. * @param left defines the left operand
  2870. * @param right defines the right operand
  2871. * @returns the dot product
  2872. */
  2873. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2874. /**
  2875. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2876. * The cross product is then orthogonal to both "left" and "right"
  2877. * @param left defines the left operand
  2878. * @param right defines the right operand
  2879. * @returns the cross product
  2880. */
  2881. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2882. /**
  2883. * Sets the given vector "result" with the cross product of "left" and "right"
  2884. * The cross product is then orthogonal to both "left" and "right"
  2885. * @param left defines the left operand
  2886. * @param right defines the right operand
  2887. * @param result defines the Vector3 where to store the result
  2888. */
  2889. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2890. /**
  2891. * Returns a new Vector3 as the normalization of the given vector
  2892. * @param vector defines the Vector3 to normalize
  2893. * @returns the new Vector3
  2894. */
  2895. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2896. /**
  2897. * Sets the given vector "result" with the normalization of the given first vector
  2898. * @param vector defines the Vector3 to normalize
  2899. * @param result defines the Vector3 where to store the result
  2900. */
  2901. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2902. /**
  2903. * Project a Vector3 onto screen space
  2904. * @param vector defines the Vector3 to project
  2905. * @param world defines the world matrix to use
  2906. * @param transform defines the transform (view x projection) matrix to use
  2907. * @param viewport defines the screen viewport to use
  2908. * @returns the new Vector3
  2909. */
  2910. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2911. /** @hidden */
  2912. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2913. /**
  2914. * Unproject from screen space to object space
  2915. * @param source defines the screen space Vector3 to use
  2916. * @param viewportWidth defines the current width of the viewport
  2917. * @param viewportHeight defines the current height of the viewport
  2918. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2919. * @param transform defines the transform (view x projection) matrix to use
  2920. * @returns the new Vector3
  2921. */
  2922. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2923. /**
  2924. * Unproject from screen space to object space
  2925. * @param source defines the screen space Vector3 to use
  2926. * @param viewportWidth defines the current width of the viewport
  2927. * @param viewportHeight defines the current height of the viewport
  2928. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2929. * @param view defines the view matrix to use
  2930. * @param projection defines the projection matrix to use
  2931. * @returns the new Vector3
  2932. */
  2933. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2934. /**
  2935. * Unproject from screen space to object space
  2936. * @param source defines the screen space Vector3 to use
  2937. * @param viewportWidth defines the current width of the viewport
  2938. * @param viewportHeight defines the current height of the viewport
  2939. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2940. * @param view defines the view matrix to use
  2941. * @param projection defines the projection matrix to use
  2942. * @param result defines the Vector3 where to store the result
  2943. */
  2944. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2945. /**
  2946. * Unproject from screen space to object space
  2947. * @param sourceX defines the screen space x coordinate to use
  2948. * @param sourceY defines the screen space y coordinate to use
  2949. * @param sourceZ defines the screen space z coordinate to use
  2950. * @param viewportWidth defines the current width of the viewport
  2951. * @param viewportHeight defines the current height of the viewport
  2952. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2953. * @param view defines the view matrix to use
  2954. * @param projection defines the projection matrix to use
  2955. * @param result defines the Vector3 where to store the result
  2956. */
  2957. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2958. /**
  2959. * Gets the minimal coordinate values between two Vector3
  2960. * @param left defines the first operand
  2961. * @param right defines the second operand
  2962. * @returns the new Vector3
  2963. */
  2964. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2965. /**
  2966. * Gets the maximal coordinate values between two Vector3
  2967. * @param left defines the first operand
  2968. * @param right defines the second operand
  2969. * @returns the new Vector3
  2970. */
  2971. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2972. /**
  2973. * Returns the distance between the vectors "value1" and "value2"
  2974. * @param value1 defines the first operand
  2975. * @param value2 defines the second operand
  2976. * @returns the distance
  2977. */
  2978. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2979. /**
  2980. * Returns the squared distance between the vectors "value1" and "value2"
  2981. * @param value1 defines the first operand
  2982. * @param value2 defines the second operand
  2983. * @returns the squared distance
  2984. */
  2985. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2986. /**
  2987. * Returns a new Vector3 located at the center between "value1" and "value2"
  2988. * @param value1 defines the first operand
  2989. * @param value2 defines the second operand
  2990. * @returns the new Vector3
  2991. */
  2992. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2993. /**
  2994. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2995. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2996. * to something in order to rotate it from its local system to the given target system
  2997. * Note: axis1, axis2 and axis3 are normalized during this operation
  2998. * @param axis1 defines the first axis
  2999. * @param axis2 defines the second axis
  3000. * @param axis3 defines the third axis
  3001. * @returns a new Vector3
  3002. */
  3003. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3004. /**
  3005. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3006. * @param axis1 defines the first axis
  3007. * @param axis2 defines the second axis
  3008. * @param axis3 defines the third axis
  3009. * @param ref defines the Vector3 where to store the result
  3010. */
  3011. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3012. }
  3013. /**
  3014. * Vector4 class created for EulerAngle class conversion to Quaternion
  3015. */
  3016. export class Vector4 {
  3017. /** x value of the vector */
  3018. x: number;
  3019. /** y value of the vector */
  3020. y: number;
  3021. /** z value of the vector */
  3022. z: number;
  3023. /** w value of the vector */
  3024. w: number;
  3025. /**
  3026. * Creates a Vector4 object from the given floats.
  3027. * @param x x value of the vector
  3028. * @param y y value of the vector
  3029. * @param z z value of the vector
  3030. * @param w w value of the vector
  3031. */
  3032. constructor(
  3033. /** x value of the vector */
  3034. x: number,
  3035. /** y value of the vector */
  3036. y: number,
  3037. /** z value of the vector */
  3038. z: number,
  3039. /** w value of the vector */
  3040. w: number);
  3041. /**
  3042. * Returns the string with the Vector4 coordinates.
  3043. * @returns a string containing all the vector values
  3044. */
  3045. toString(): string;
  3046. /**
  3047. * Returns the string "Vector4".
  3048. * @returns "Vector4"
  3049. */
  3050. getClassName(): string;
  3051. /**
  3052. * Returns the Vector4 hash code.
  3053. * @returns a unique hash code
  3054. */
  3055. getHashCode(): number;
  3056. /**
  3057. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3058. * @returns the resulting array
  3059. */
  3060. asArray(): number[];
  3061. /**
  3062. * Populates the given array from the given index with the Vector4 coordinates.
  3063. * @param array array to populate
  3064. * @param index index of the array to start at (default: 0)
  3065. * @returns the Vector4.
  3066. */
  3067. toArray(array: FloatArray, index?: number): Vector4;
  3068. /**
  3069. * Adds the given vector to the current Vector4.
  3070. * @param otherVector the vector to add
  3071. * @returns the updated Vector4.
  3072. */
  3073. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3074. /**
  3075. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3076. * @param otherVector the vector to add
  3077. * @returns the resulting vector
  3078. */
  3079. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3080. /**
  3081. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3082. * @param otherVector the vector to add
  3083. * @param result the vector to store the result
  3084. * @returns the current Vector4.
  3085. */
  3086. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3087. /**
  3088. * Subtract in place the given vector from the current Vector4.
  3089. * @param otherVector the vector to subtract
  3090. * @returns the updated Vector4.
  3091. */
  3092. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3093. /**
  3094. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the new vector with the result
  3097. */
  3098. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3101. * @param otherVector the vector to subtract
  3102. * @param result the vector to store the result
  3103. * @returns the current Vector4.
  3104. */
  3105. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3106. /**
  3107. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3108. */
  3109. /**
  3110. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3111. * @param x value to subtract
  3112. * @param y value to subtract
  3113. * @param z value to subtract
  3114. * @param w value to subtract
  3115. * @returns new vector containing the result
  3116. */
  3117. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3118. /**
  3119. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3120. * @param x value to subtract
  3121. * @param y value to subtract
  3122. * @param z value to subtract
  3123. * @param w value to subtract
  3124. * @param result the vector to store the result in
  3125. * @returns the current Vector4.
  3126. */
  3127. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3128. /**
  3129. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3130. * @returns a new vector with the negated values
  3131. */
  3132. negate(): Vector4;
  3133. /**
  3134. * Multiplies the current Vector4 coordinates by scale (float).
  3135. * @param scale the number to scale with
  3136. * @returns the updated Vector4.
  3137. */
  3138. scaleInPlace(scale: number): Vector4;
  3139. /**
  3140. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3141. * @param scale the number to scale with
  3142. * @returns a new vector with the result
  3143. */
  3144. scale(scale: number): Vector4;
  3145. /**
  3146. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3147. * @param scale the number to scale with
  3148. * @param result a vector to store the result in
  3149. * @returns the current Vector4.
  3150. */
  3151. scaleToRef(scale: number, result: Vector4): Vector4;
  3152. /**
  3153. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3154. * @param scale defines the scale factor
  3155. * @param result defines the Vector4 object where to store the result
  3156. * @returns the unmodified current Vector4
  3157. */
  3158. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3159. /**
  3160. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3161. * @param otherVector the vector to compare against
  3162. * @returns true if they are equal
  3163. */
  3164. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3165. /**
  3166. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3167. * @param otherVector vector to compare against
  3168. * @param epsilon (Default: very small number)
  3169. * @returns true if they are equal
  3170. */
  3171. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3172. /**
  3173. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3174. * @param x x value to compare against
  3175. * @param y y value to compare against
  3176. * @param z z value to compare against
  3177. * @param w w value to compare against
  3178. * @returns true if equal
  3179. */
  3180. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3181. /**
  3182. * Multiplies in place the current Vector4 by the given one.
  3183. * @param otherVector vector to multiple with
  3184. * @returns the updated Vector4.
  3185. */
  3186. multiplyInPlace(otherVector: Vector4): Vector4;
  3187. /**
  3188. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3189. * @param otherVector vector to multiple with
  3190. * @returns resulting new vector
  3191. */
  3192. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3193. /**
  3194. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3195. * @param otherVector vector to multiple with
  3196. * @param result vector to store the result
  3197. * @returns the current Vector4.
  3198. */
  3199. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3200. /**
  3201. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3202. * @param x x value multiply with
  3203. * @param y y value multiply with
  3204. * @param z z value multiply with
  3205. * @param w w value multiply with
  3206. * @returns resulting new vector
  3207. */
  3208. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3209. /**
  3210. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3211. * @param otherVector vector to devide with
  3212. * @returns resulting new vector
  3213. */
  3214. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3215. /**
  3216. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3217. * @param otherVector vector to devide with
  3218. * @param result vector to store the result
  3219. * @returns the current Vector4.
  3220. */
  3221. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3222. /**
  3223. * Divides the current Vector3 coordinates by the given ones.
  3224. * @param otherVector vector to devide with
  3225. * @returns the updated Vector3.
  3226. */
  3227. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3228. /**
  3229. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3230. * @param other defines the second operand
  3231. * @returns the current updated Vector4
  3232. */
  3233. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3234. /**
  3235. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3236. * @param other defines the second operand
  3237. * @returns the current updated Vector4
  3238. */
  3239. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Gets a new Vector4 from current Vector4 floored values
  3242. * @returns a new Vector4
  3243. */
  3244. floor(): Vector4;
  3245. /**
  3246. * Gets a new Vector4 from current Vector3 floored values
  3247. * @returns a new Vector4
  3248. */
  3249. fract(): Vector4;
  3250. /**
  3251. * Returns the Vector4 length (float).
  3252. * @returns the length
  3253. */
  3254. length(): number;
  3255. /**
  3256. * Returns the Vector4 squared length (float).
  3257. * @returns the length squared
  3258. */
  3259. lengthSquared(): number;
  3260. /**
  3261. * Normalizes in place the Vector4.
  3262. * @returns the updated Vector4.
  3263. */
  3264. normalize(): Vector4;
  3265. /**
  3266. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3267. * @returns this converted to a new vector3
  3268. */
  3269. toVector3(): Vector3;
  3270. /**
  3271. * Returns a new Vector4 copied from the current one.
  3272. * @returns the new cloned vector
  3273. */
  3274. clone(): Vector4;
  3275. /**
  3276. * Updates the current Vector4 with the given one coordinates.
  3277. * @param source the source vector to copy from
  3278. * @returns the updated Vector4.
  3279. */
  3280. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the current Vector4 coordinates with the given floats.
  3283. * @param x float to copy from
  3284. * @param y float to copy from
  3285. * @param z float to copy from
  3286. * @param w float to copy from
  3287. * @returns the updated Vector4.
  3288. */
  3289. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3290. /**
  3291. * Updates the current Vector4 coordinates with the given floats.
  3292. * @param x float to set from
  3293. * @param y float to set from
  3294. * @param z float to set from
  3295. * @param w float to set from
  3296. * @returns the updated Vector4.
  3297. */
  3298. set(x: number, y: number, z: number, w: number): Vector4;
  3299. /**
  3300. * Copies the given float to the current Vector3 coordinates
  3301. * @param v defines the x, y, z and w coordinates of the operand
  3302. * @returns the current updated Vector3
  3303. */
  3304. setAll(v: number): Vector4;
  3305. /**
  3306. * Returns a new Vector4 set from the starting index of the given array.
  3307. * @param array the array to pull values from
  3308. * @param offset the offset into the array to start at
  3309. * @returns the new vector
  3310. */
  3311. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3312. /**
  3313. * Updates the given vector "result" from the starting index of the given array.
  3314. * @param array the array to pull values from
  3315. * @param offset the offset into the array to start at
  3316. * @param result the vector to store the result in
  3317. */
  3318. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3319. /**
  3320. * Updates the given vector "result" from the starting index of the given Float32Array.
  3321. * @param array the array to pull values from
  3322. * @param offset the offset into the array to start at
  3323. * @param result the vector to store the result in
  3324. */
  3325. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3326. /**
  3327. * Updates the given vector "result" coordinates from 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. * @param result the vector to the floats in
  3333. */
  3334. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3335. /**
  3336. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3337. * @returns the new vector
  3338. */
  3339. static Zero(): Vector4;
  3340. /**
  3341. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3342. * @returns the new vector
  3343. */
  3344. static One(): Vector4;
  3345. /**
  3346. * Returns a new normalized Vector4 from the given one.
  3347. * @param vector the vector to normalize
  3348. * @returns the vector
  3349. */
  3350. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3351. /**
  3352. * Updates the given vector "result" from the normalization of the given one.
  3353. * @param vector the vector to normalize
  3354. * @param result the vector to store the result in
  3355. */
  3356. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3357. /**
  3358. * Returns a vector with the minimum values from the left and right vectors
  3359. * @param left left vector to minimize
  3360. * @param right right vector to minimize
  3361. * @returns a new vector with the minimum of the left and right vector values
  3362. */
  3363. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3364. /**
  3365. * Returns a vector with the maximum values from the left and right vectors
  3366. * @param left left vector to maximize
  3367. * @param right right vector to maximize
  3368. * @returns a new vector with the maximum of the left and right vector values
  3369. */
  3370. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3371. /**
  3372. * Returns the distance (float) between the vectors "value1" and "value2".
  3373. * @param value1 value to calulate the distance between
  3374. * @param value2 value to calulate the distance between
  3375. * @return the distance between the two vectors
  3376. */
  3377. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3378. /**
  3379. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3380. * @param value1 value to calulate the distance between
  3381. * @param value2 value to calulate the distance between
  3382. * @return the distance between the two vectors squared
  3383. */
  3384. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3385. /**
  3386. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3387. * @param value1 value to calulate the center between
  3388. * @param value2 value to calulate the center between
  3389. * @return the center between the two vectors
  3390. */
  3391. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3392. /**
  3393. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3394. * This methods computes transformed normalized direction vectors only.
  3395. * @param vector the vector to transform
  3396. * @param transformation the transformation matrix to apply
  3397. * @returns the new vector
  3398. */
  3399. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3400. /**
  3401. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3402. * This methods computes transformed normalized direction vectors only.
  3403. * @param vector the vector to transform
  3404. * @param transformation the transformation matrix to apply
  3405. * @param result the vector to store the result in
  3406. */
  3407. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3408. /**
  3409. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3410. * This methods computes transformed normalized direction vectors only.
  3411. * @param x value to transform
  3412. * @param y value to transform
  3413. * @param z value to transform
  3414. * @param w value to transform
  3415. * @param transformation the transformation matrix to apply
  3416. * @param result the vector to store the results in
  3417. */
  3418. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3419. /**
  3420. * Creates a new Vector4 from a Vector3
  3421. * @param source defines the source data
  3422. * @param w defines the 4th component (default is 0)
  3423. * @returns a new Vector4
  3424. */
  3425. static FromVector3(source: Vector3, w?: number): Vector4;
  3426. }
  3427. /**
  3428. * Class used to store quaternion data
  3429. * @see https://en.wikipedia.org/wiki/Quaternion
  3430. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3431. */
  3432. export class Quaternion {
  3433. /** defines the first component (0 by default) */
  3434. x: number;
  3435. /** defines the second component (0 by default) */
  3436. y: number;
  3437. /** defines the third component (0 by default) */
  3438. z: number;
  3439. /** defines the fourth component (1.0 by default) */
  3440. w: number;
  3441. /**
  3442. * Creates a new Quaternion from the given floats
  3443. * @param x defines the first component (0 by default)
  3444. * @param y defines the second component (0 by default)
  3445. * @param z defines the third component (0 by default)
  3446. * @param w defines the fourth component (1.0 by default)
  3447. */
  3448. constructor(
  3449. /** defines the first component (0 by default) */
  3450. x?: number,
  3451. /** defines the second component (0 by default) */
  3452. y?: number,
  3453. /** defines the third component (0 by default) */
  3454. z?: number,
  3455. /** defines the fourth component (1.0 by default) */
  3456. w?: number);
  3457. /**
  3458. * Gets a string representation for the current quaternion
  3459. * @returns a string with the Quaternion coordinates
  3460. */
  3461. toString(): string;
  3462. /**
  3463. * Gets the class name of the quaternion
  3464. * @returns the string "Quaternion"
  3465. */
  3466. getClassName(): string;
  3467. /**
  3468. * Gets a hash code for this quaternion
  3469. * @returns the quaternion hash code
  3470. */
  3471. getHashCode(): number;
  3472. /**
  3473. * Copy the quaternion to an array
  3474. * @returns a new array populated with 4 elements from the quaternion coordinates
  3475. */
  3476. asArray(): number[];
  3477. /**
  3478. * Check if two quaternions are equals
  3479. * @param otherQuaternion defines the second operand
  3480. * @return true if the current quaternion and the given one coordinates are strictly equals
  3481. */
  3482. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3483. /**
  3484. * Clone the current quaternion
  3485. * @returns a new quaternion copied from the current one
  3486. */
  3487. clone(): Quaternion;
  3488. /**
  3489. * Copy a quaternion to the current one
  3490. * @param other defines the other quaternion
  3491. * @returns the updated current quaternion
  3492. */
  3493. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3494. /**
  3495. * Updates the current quaternion with the given float coordinates
  3496. * @param x defines the x coordinate
  3497. * @param y defines the y coordinate
  3498. * @param z defines the z coordinate
  3499. * @param w defines the w coordinate
  3500. * @returns the updated current quaternion
  3501. */
  3502. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3503. /**
  3504. * Updates the current quaternion from the given float coordinates
  3505. * @param x defines the x coordinate
  3506. * @param y defines the y coordinate
  3507. * @param z defines the z coordinate
  3508. * @param w defines the w coordinate
  3509. * @returns the updated current quaternion
  3510. */
  3511. set(x: number, y: number, z: number, w: number): Quaternion;
  3512. /**
  3513. * Adds two quaternions
  3514. * @param other defines the second operand
  3515. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3516. */
  3517. add(other: DeepImmutable<Quaternion>): Quaternion;
  3518. /**
  3519. * Add a quaternion to the current one
  3520. * @param other defines the quaternion to add
  3521. * @returns the current quaternion
  3522. */
  3523. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3524. /**
  3525. * Subtract two quaternions
  3526. * @param other defines the second operand
  3527. * @returns a new quaternion as the subtraction result of the given one from the current one
  3528. */
  3529. subtract(other: Quaternion): Quaternion;
  3530. /**
  3531. * Multiplies the current quaternion by a scale factor
  3532. * @param value defines the scale factor
  3533. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3534. */
  3535. scale(value: number): Quaternion;
  3536. /**
  3537. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Quaternion object where to store the result
  3540. * @returns the unmodified current quaternion
  3541. */
  3542. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3543. /**
  3544. * Multiplies in place the current quaternion by a scale factor
  3545. * @param value defines the scale factor
  3546. * @returns the current modified quaternion
  3547. */
  3548. scaleInPlace(value: number): Quaternion;
  3549. /**
  3550. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3551. * @param scale defines the scale factor
  3552. * @param result defines the Quaternion object where to store the result
  3553. * @returns the unmodified current quaternion
  3554. */
  3555. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3556. /**
  3557. * Multiplies two quaternions
  3558. * @param q1 defines the second operand
  3559. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3560. */
  3561. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3562. /**
  3563. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3564. * @param q1 defines the second operand
  3565. * @param result defines the target quaternion
  3566. * @returns the current quaternion
  3567. */
  3568. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3569. /**
  3570. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3571. * @param q1 defines the second operand
  3572. * @returns the currentupdated quaternion
  3573. */
  3574. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3575. /**
  3576. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3577. * @param ref defines the target quaternion
  3578. * @returns the current quaternion
  3579. */
  3580. conjugateToRef(ref: Quaternion): Quaternion;
  3581. /**
  3582. * Conjugates in place (1-q) the current quaternion
  3583. * @returns the current updated quaternion
  3584. */
  3585. conjugateInPlace(): Quaternion;
  3586. /**
  3587. * Conjugates in place (1-q) the current quaternion
  3588. * @returns a new quaternion
  3589. */
  3590. conjugate(): Quaternion;
  3591. /**
  3592. * Gets length of current quaternion
  3593. * @returns the quaternion length (float)
  3594. */
  3595. length(): number;
  3596. /**
  3597. * Normalize in place the current quaternion
  3598. * @returns the current updated quaternion
  3599. */
  3600. normalize(): Quaternion;
  3601. /**
  3602. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3603. * @param order is a reserved parameter and is ignore for now
  3604. * @returns a new Vector3 containing the Euler angles
  3605. */
  3606. toEulerAngles(order?: string): Vector3;
  3607. /**
  3608. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3609. * @param result defines the vector which will be filled with the Euler angles
  3610. * @param order is a reserved parameter and is ignore for now
  3611. * @returns the current unchanged quaternion
  3612. */
  3613. toEulerAnglesToRef(result: Vector3): Quaternion;
  3614. /**
  3615. * Updates the given rotation matrix with the current quaternion values
  3616. * @param result defines the target matrix
  3617. * @returns the current unchanged quaternion
  3618. */
  3619. toRotationMatrix(result: Matrix): Quaternion;
  3620. /**
  3621. * Updates the current quaternion from the given rotation matrix values
  3622. * @param matrix defines the source matrix
  3623. * @returns the current updated quaternion
  3624. */
  3625. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3626. /**
  3627. * Creates a new quaternion from a rotation matrix
  3628. * @param matrix defines the source matrix
  3629. * @returns a new quaternion created from the given rotation matrix values
  3630. */
  3631. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3632. /**
  3633. * Updates the given quaternion with the given rotation matrix values
  3634. * @param matrix defines the source matrix
  3635. * @param result defines the target quaternion
  3636. */
  3637. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3638. /**
  3639. * Returns the dot product (float) between the quaternions "left" and "right"
  3640. * @param left defines the left operand
  3641. * @param right defines the right operand
  3642. * @returns the dot product
  3643. */
  3644. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3645. /**
  3646. * Checks if the two quaternions are close to each other
  3647. * @param quat0 defines the first quaternion to check
  3648. * @param quat1 defines the second quaternion to check
  3649. * @returns true if the two quaternions are close to each other
  3650. */
  3651. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3652. /**
  3653. * Creates an empty quaternion
  3654. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3655. */
  3656. static Zero(): Quaternion;
  3657. /**
  3658. * Inverse a given quaternion
  3659. * @param q defines the source quaternion
  3660. * @returns a new quaternion as the inverted current quaternion
  3661. */
  3662. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3663. /**
  3664. * Inverse a given quaternion
  3665. * @param q defines the source quaternion
  3666. * @param result the quaternion the result will be stored in
  3667. * @returns the result quaternion
  3668. */
  3669. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3670. /**
  3671. * Creates an identity quaternion
  3672. * @returns the identity quaternion
  3673. */
  3674. static Identity(): Quaternion;
  3675. /**
  3676. * Gets a boolean indicating if the given quaternion is identity
  3677. * @param quaternion defines the quaternion to check
  3678. * @returns true if the quaternion is identity
  3679. */
  3680. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3681. /**
  3682. * Creates a quaternion from a rotation around an axis
  3683. * @param axis defines the axis to use
  3684. * @param angle defines the angle to use
  3685. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3686. */
  3687. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3688. /**
  3689. * Creates a rotation around an axis and stores it into the given quaternion
  3690. * @param axis defines the axis to use
  3691. * @param angle defines the angle to use
  3692. * @param result defines the target quaternion
  3693. * @returns the target quaternion
  3694. */
  3695. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3696. /**
  3697. * Creates a new quaternion from data stored into an array
  3698. * @param array defines the data source
  3699. * @param offset defines the offset in the source array where the data starts
  3700. * @returns a new quaternion
  3701. */
  3702. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3703. /**
  3704. * Create a quaternion from Euler rotation angles
  3705. * @param x Pitch
  3706. * @param y Yaw
  3707. * @param z Roll
  3708. * @returns the new Quaternion
  3709. */
  3710. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3711. /**
  3712. * Updates a quaternion from Euler rotation angles
  3713. * @param x Pitch
  3714. * @param y Yaw
  3715. * @param z Roll
  3716. * @param result the quaternion to store the result
  3717. * @returns the updated quaternion
  3718. */
  3719. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3720. /**
  3721. * Create a quaternion from Euler rotation vector
  3722. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3723. * @returns the new Quaternion
  3724. */
  3725. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3726. /**
  3727. * Updates a quaternion from Euler rotation vector
  3728. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3729. * @param result the quaternion to store the result
  3730. * @returns the updated quaternion
  3731. */
  3732. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3733. /**
  3734. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3735. * @param yaw defines the rotation around Y axis
  3736. * @param pitch defines the rotation around X axis
  3737. * @param roll defines the rotation around Z axis
  3738. * @returns the new quaternion
  3739. */
  3740. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3741. /**
  3742. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3743. * @param yaw defines the rotation around Y axis
  3744. * @param pitch defines the rotation around X axis
  3745. * @param roll defines the rotation around Z axis
  3746. * @param result defines the target quaternion
  3747. */
  3748. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3749. /**
  3750. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3751. * @param alpha defines the rotation around first axis
  3752. * @param beta defines the rotation around second axis
  3753. * @param gamma defines the rotation around third axis
  3754. * @returns the new quaternion
  3755. */
  3756. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3757. /**
  3758. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3759. * @param alpha defines the rotation around first axis
  3760. * @param beta defines the rotation around second axis
  3761. * @param gamma defines the rotation around third axis
  3762. * @param result defines the target quaternion
  3763. */
  3764. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3765. /**
  3766. * 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)
  3767. * @param axis1 defines the first axis
  3768. * @param axis2 defines the second axis
  3769. * @param axis3 defines the third axis
  3770. * @returns the new quaternion
  3771. */
  3772. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3773. /**
  3774. * 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
  3775. * @param axis1 defines the first axis
  3776. * @param axis2 defines the second axis
  3777. * @param axis3 defines the third axis
  3778. * @param ref defines the target quaternion
  3779. */
  3780. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3781. /**
  3782. * Interpolates between two quaternions
  3783. * @param left defines first quaternion
  3784. * @param right defines second quaternion
  3785. * @param amount defines the gradient to use
  3786. * @returns the new interpolated quaternion
  3787. */
  3788. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3789. /**
  3790. * Interpolates between two quaternions and stores it into a target quaternion
  3791. * @param left defines first quaternion
  3792. * @param right defines second quaternion
  3793. * @param amount defines the gradient to use
  3794. * @param result defines the target quaternion
  3795. */
  3796. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3797. /**
  3798. * Interpolate between two quaternions using Hermite interpolation
  3799. * @param value1 defines first quaternion
  3800. * @param tangent1 defines the incoming tangent
  3801. * @param value2 defines second quaternion
  3802. * @param tangent2 defines the outgoing tangent
  3803. * @param amount defines the target quaternion
  3804. * @returns the new interpolated quaternion
  3805. */
  3806. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3807. }
  3808. /**
  3809. * Class used to store matrix data (4x4)
  3810. */
  3811. export class Matrix {
  3812. private static _updateFlagSeed;
  3813. private static _identityReadOnly;
  3814. private _isIdentity;
  3815. private _isIdentityDirty;
  3816. private _isIdentity3x2;
  3817. private _isIdentity3x2Dirty;
  3818. /**
  3819. * Gets the update flag of the matrix which is an unique number for the matrix.
  3820. * It will be incremented every time the matrix data change.
  3821. * You can use it to speed the comparison between two versions of the same matrix.
  3822. */
  3823. updateFlag: number;
  3824. private readonly _m;
  3825. /**
  3826. * Gets the internal data of the matrix
  3827. */
  3828. readonly m: DeepImmutable<Float32Array>;
  3829. /** @hidden */
  3830. _markAsUpdated(): void;
  3831. /** @hidden */
  3832. private _updateIdentityStatus;
  3833. /**
  3834. * Creates an empty matrix (filled with zeros)
  3835. */
  3836. constructor();
  3837. /**
  3838. * Check if the current matrix is identity
  3839. * @returns true is the matrix is the identity matrix
  3840. */
  3841. isIdentity(): boolean;
  3842. /**
  3843. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3844. * @returns true is the matrix is the identity matrix
  3845. */
  3846. isIdentityAs3x2(): boolean;
  3847. /**
  3848. * Gets the determinant of the matrix
  3849. * @returns the matrix determinant
  3850. */
  3851. determinant(): number;
  3852. /**
  3853. * Returns the matrix as a Float32Array
  3854. * @returns the matrix underlying array
  3855. */
  3856. toArray(): DeepImmutable<Float32Array>;
  3857. /**
  3858. * Returns the matrix as a Float32Array
  3859. * @returns the matrix underlying array.
  3860. */
  3861. asArray(): DeepImmutable<Float32Array>;
  3862. /**
  3863. * Inverts the current matrix in place
  3864. * @returns the current inverted matrix
  3865. */
  3866. invert(): Matrix;
  3867. /**
  3868. * Sets all the matrix elements to zero
  3869. * @returns the current matrix
  3870. */
  3871. reset(): Matrix;
  3872. /**
  3873. * Adds the current matrix with a second one
  3874. * @param other defines the matrix to add
  3875. * @returns a new matrix as the addition of the current matrix and the given one
  3876. */
  3877. add(other: DeepImmutable<Matrix>): Matrix;
  3878. /**
  3879. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3880. * @param other defines the matrix to add
  3881. * @param result defines the target matrix
  3882. * @returns the current matrix
  3883. */
  3884. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3885. /**
  3886. * Adds in place the given matrix to the current matrix
  3887. * @param other defines the second operand
  3888. * @returns the current updated matrix
  3889. */
  3890. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3891. /**
  3892. * Sets the given matrix to the current inverted Matrix
  3893. * @param other defines the target matrix
  3894. * @returns the unmodified current matrix
  3895. */
  3896. invertToRef(other: Matrix): Matrix;
  3897. /**
  3898. * add a value at the specified position in the current Matrix
  3899. * @param index the index of the value within the matrix. between 0 and 15.
  3900. * @param value the value to be added
  3901. * @returns the current updated matrix
  3902. */
  3903. addAtIndex(index: number, value: number): Matrix;
  3904. /**
  3905. * mutiply the specified position in the current Matrix by a value
  3906. * @param index the index of the value within the matrix. between 0 and 15.
  3907. * @param value the value to be added
  3908. * @returns the current updated matrix
  3909. */
  3910. multiplyAtIndex(index: number, value: number): Matrix;
  3911. /**
  3912. * Inserts the translation vector (using 3 floats) in the current matrix
  3913. * @param x defines the 1st component of the translation
  3914. * @param y defines the 2nd component of the translation
  3915. * @param z defines the 3rd component of the translation
  3916. * @returns the current updated matrix
  3917. */
  3918. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3919. /**
  3920. * Adds the translation vector (using 3 floats) in the current matrix
  3921. * @param x defines the 1st component of the translation
  3922. * @param y defines the 2nd component of the translation
  3923. * @param z defines the 3rd component of the translation
  3924. * @returns the current updated matrix
  3925. */
  3926. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3927. /**
  3928. * Inserts the translation vector in the current matrix
  3929. * @param vector3 defines the translation to insert
  3930. * @returns the current updated matrix
  3931. */
  3932. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3933. /**
  3934. * Gets the translation value of the current matrix
  3935. * @returns a new Vector3 as the extracted translation from the matrix
  3936. */
  3937. getTranslation(): Vector3;
  3938. /**
  3939. * Fill a Vector3 with the extracted translation from the matrix
  3940. * @param result defines the Vector3 where to store the translation
  3941. * @returns the current matrix
  3942. */
  3943. getTranslationToRef(result: Vector3): Matrix;
  3944. /**
  3945. * Remove rotation and scaling part from the matrix
  3946. * @returns the updated matrix
  3947. */
  3948. removeRotationAndScaling(): Matrix;
  3949. /**
  3950. * Multiply two matrices
  3951. * @param other defines the second operand
  3952. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3953. */
  3954. multiply(other: DeepImmutable<Matrix>): Matrix;
  3955. /**
  3956. * Copy the current matrix from the given one
  3957. * @param other defines the source matrix
  3958. * @returns the current updated matrix
  3959. */
  3960. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3961. /**
  3962. * Populates the given array from the starting index with the current matrix values
  3963. * @param array defines the target array
  3964. * @param offset defines the offset in the target array where to start storing values
  3965. * @returns the current matrix
  3966. */
  3967. copyToArray(array: Float32Array, offset?: number): Matrix;
  3968. /**
  3969. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3970. * @param other defines the second operand
  3971. * @param result defines the matrix where to store the multiplication
  3972. * @returns the current matrix
  3973. */
  3974. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3975. /**
  3976. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3977. * @param other defines the second operand
  3978. * @param result defines the array where to store the multiplication
  3979. * @param offset defines the offset in the target array where to start storing values
  3980. * @returns the current matrix
  3981. */
  3982. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3983. /**
  3984. * Check equality between this matrix and a second one
  3985. * @param value defines the second matrix to compare
  3986. * @returns true is the current matrix and the given one values are strictly equal
  3987. */
  3988. equals(value: DeepImmutable<Matrix>): boolean;
  3989. /**
  3990. * Clone the current matrix
  3991. * @returns a new matrix from the current matrix
  3992. */
  3993. clone(): Matrix;
  3994. /**
  3995. * Returns the name of the current matrix class
  3996. * @returns the string "Matrix"
  3997. */
  3998. getClassName(): string;
  3999. /**
  4000. * Gets the hash code of the current matrix
  4001. * @returns the hash code
  4002. */
  4003. getHashCode(): number;
  4004. /**
  4005. * Decomposes the current Matrix into a translation, rotation and scaling components
  4006. * @param scale defines the scale vector3 given as a reference to update
  4007. * @param rotation defines the rotation quaternion given as a reference to update
  4008. * @param translation defines the translation vector3 given as a reference to update
  4009. * @returns true if operation was successful
  4010. */
  4011. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4012. /**
  4013. * Gets specific row of the matrix
  4014. * @param index defines the number of the row to get
  4015. * @returns the index-th row of the current matrix as a new Vector4
  4016. */
  4017. getRow(index: number): Nullable<Vector4>;
  4018. /**
  4019. * Sets the index-th row of the current matrix to the vector4 values
  4020. * @param index defines the number of the row to set
  4021. * @param row defines the target vector4
  4022. * @returns the updated current matrix
  4023. */
  4024. setRow(index: number, row: Vector4): Matrix;
  4025. /**
  4026. * Compute the transpose of the matrix
  4027. * @returns the new transposed matrix
  4028. */
  4029. transpose(): Matrix;
  4030. /**
  4031. * Compute the transpose of the matrix and store it in a given matrix
  4032. * @param result defines the target matrix
  4033. * @returns the current matrix
  4034. */
  4035. transposeToRef(result: Matrix): Matrix;
  4036. /**
  4037. * Sets the index-th row of the current matrix with the given 4 x float values
  4038. * @param index defines the row index
  4039. * @param x defines the x component to set
  4040. * @param y defines the y component to set
  4041. * @param z defines the z component to set
  4042. * @param w defines the w component to set
  4043. * @returns the updated current matrix
  4044. */
  4045. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4046. /**
  4047. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4048. * @param scale defines the scale factor
  4049. * @returns a new matrix
  4050. */
  4051. scale(scale: number): Matrix;
  4052. /**
  4053. * Scale the current matrix values by a factor to a given result matrix
  4054. * @param scale defines the scale factor
  4055. * @param result defines the matrix to store the result
  4056. * @returns the current matrix
  4057. */
  4058. scaleToRef(scale: number, result: Matrix): Matrix;
  4059. /**
  4060. * Scale the current matrix values by a factor and add the result to a given matrix
  4061. * @param scale defines the scale factor
  4062. * @param result defines the Matrix to store the result
  4063. * @returns the current matrix
  4064. */
  4065. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4066. /**
  4067. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4068. * @param ref matrix to store the result
  4069. */
  4070. toNormalMatrix(ref: Matrix): void;
  4071. /**
  4072. * Gets only rotation part of the current matrix
  4073. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4074. */
  4075. getRotationMatrix(): Matrix;
  4076. /**
  4077. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4078. * @param result defines the target matrix to store data to
  4079. * @returns the current matrix
  4080. */
  4081. getRotationMatrixToRef(result: Matrix): Matrix;
  4082. /**
  4083. * Toggles model matrix from being right handed to left handed in place and vice versa
  4084. */
  4085. toggleModelMatrixHandInPlace(): void;
  4086. /**
  4087. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4088. */
  4089. toggleProjectionMatrixHandInPlace(): void;
  4090. /**
  4091. * Creates a matrix from an array
  4092. * @param array defines the source array
  4093. * @param offset defines an offset in the source array
  4094. * @returns a new Matrix set from the starting index of the given array
  4095. */
  4096. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4097. /**
  4098. * Copy the content of an array into a given matrix
  4099. * @param array defines the source array
  4100. * @param offset defines an offset in the source array
  4101. * @param result defines the target matrix
  4102. */
  4103. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4104. /**
  4105. * Stores an array into a matrix after having multiplied each component by a given factor
  4106. * @param array defines the source array
  4107. * @param offset defines the offset in the source array
  4108. * @param scale defines the scaling factor
  4109. * @param result defines the target matrix
  4110. */
  4111. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4112. /**
  4113. * Gets an identity matrix that must not be updated
  4114. */
  4115. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4116. /**
  4117. * Stores a list of values (16) inside a given matrix
  4118. * @param initialM11 defines 1st value of 1st row
  4119. * @param initialM12 defines 2nd value of 1st row
  4120. * @param initialM13 defines 3rd value of 1st row
  4121. * @param initialM14 defines 4th value of 1st row
  4122. * @param initialM21 defines 1st value of 2nd row
  4123. * @param initialM22 defines 2nd value of 2nd row
  4124. * @param initialM23 defines 3rd value of 2nd row
  4125. * @param initialM24 defines 4th value of 2nd row
  4126. * @param initialM31 defines 1st value of 3rd row
  4127. * @param initialM32 defines 2nd value of 3rd row
  4128. * @param initialM33 defines 3rd value of 3rd row
  4129. * @param initialM34 defines 4th value of 3rd row
  4130. * @param initialM41 defines 1st value of 4th row
  4131. * @param initialM42 defines 2nd value of 4th row
  4132. * @param initialM43 defines 3rd value of 4th row
  4133. * @param initialM44 defines 4th value of 4th row
  4134. * @param result defines the target matrix
  4135. */
  4136. 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;
  4137. /**
  4138. * Creates new matrix from a list of values (16)
  4139. * @param initialM11 defines 1st value of 1st row
  4140. * @param initialM12 defines 2nd value of 1st row
  4141. * @param initialM13 defines 3rd value of 1st row
  4142. * @param initialM14 defines 4th value of 1st row
  4143. * @param initialM21 defines 1st value of 2nd row
  4144. * @param initialM22 defines 2nd value of 2nd row
  4145. * @param initialM23 defines 3rd value of 2nd row
  4146. * @param initialM24 defines 4th value of 2nd row
  4147. * @param initialM31 defines 1st value of 3rd row
  4148. * @param initialM32 defines 2nd value of 3rd row
  4149. * @param initialM33 defines 3rd value of 3rd row
  4150. * @param initialM34 defines 4th value of 3rd row
  4151. * @param initialM41 defines 1st value of 4th row
  4152. * @param initialM42 defines 2nd value of 4th row
  4153. * @param initialM43 defines 3rd value of 4th row
  4154. * @param initialM44 defines 4th value of 4th row
  4155. * @returns the new matrix
  4156. */
  4157. 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;
  4158. /**
  4159. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4160. * @param scale defines the scale vector3
  4161. * @param rotation defines the rotation quaternion
  4162. * @param translation defines the translation vector3
  4163. * @returns a new matrix
  4164. */
  4165. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4166. /**
  4167. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4168. * @param scale defines the scale vector3
  4169. * @param rotation defines the rotation quaternion
  4170. * @param translation defines the translation vector3
  4171. * @param result defines the target matrix
  4172. */
  4173. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4174. /**
  4175. * Creates a new identity matrix
  4176. * @returns a new identity matrix
  4177. */
  4178. static Identity(): Matrix;
  4179. /**
  4180. * Creates a new identity matrix and stores the result in a given matrix
  4181. * @param result defines the target matrix
  4182. */
  4183. static IdentityToRef(result: Matrix): void;
  4184. /**
  4185. * Creates a new zero matrix
  4186. * @returns a new zero matrix
  4187. */
  4188. static Zero(): Matrix;
  4189. /**
  4190. * Creates a new rotation matrix for "angle" radians around the X axis
  4191. * @param angle defines the angle (in radians) to use
  4192. * @return the new matrix
  4193. */
  4194. static RotationX(angle: number): Matrix;
  4195. /**
  4196. * Creates a new matrix as the invert of a given matrix
  4197. * @param source defines the source matrix
  4198. * @returns the new matrix
  4199. */
  4200. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4203. * @param angle defines the angle (in radians) to use
  4204. * @param result defines the target matrix
  4205. */
  4206. static RotationXToRef(angle: number, result: Matrix): void;
  4207. /**
  4208. * Creates a new rotation matrix for "angle" radians around the Y axis
  4209. * @param angle defines the angle (in radians) to use
  4210. * @return the new matrix
  4211. */
  4212. static RotationY(angle: number): Matrix;
  4213. /**
  4214. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4215. * @param angle defines the angle (in radians) to use
  4216. * @param result defines the target matrix
  4217. */
  4218. static RotationYToRef(angle: number, result: Matrix): void;
  4219. /**
  4220. * Creates a new rotation matrix for "angle" radians around the Z axis
  4221. * @param angle defines the angle (in radians) to use
  4222. * @return the new matrix
  4223. */
  4224. static RotationZ(angle: number): Matrix;
  4225. /**
  4226. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4227. * @param angle defines the angle (in radians) to use
  4228. * @param result defines the target matrix
  4229. */
  4230. static RotationZToRef(angle: number, result: Matrix): void;
  4231. /**
  4232. * Creates a new rotation matrix for "angle" radians around the given axis
  4233. * @param axis defines the axis to use
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4240. * @param axis defines the axis to use
  4241. * @param angle defines the angle (in radians) to use
  4242. * @param result defines the target matrix
  4243. */
  4244. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4245. /**
  4246. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4247. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4248. * @param from defines the vector to align
  4249. * @param to defines the vector to align to
  4250. * @param result defines the target matrix
  4251. */
  4252. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4253. /**
  4254. * Creates a rotation matrix
  4255. * @param yaw defines the yaw angle in radians (Y axis)
  4256. * @param pitch defines the pitch angle in radians (X axis)
  4257. * @param roll defines the roll angle in radians (X axis)
  4258. * @returns the new rotation matrix
  4259. */
  4260. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4261. /**
  4262. * Creates a rotation matrix and stores it in a given matrix
  4263. * @param yaw defines the yaw angle in radians (Y axis)
  4264. * @param pitch defines the pitch angle in radians (X axis)
  4265. * @param roll defines the roll angle in radians (X axis)
  4266. * @param result defines the target matrix
  4267. */
  4268. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4269. /**
  4270. * Creates a scaling matrix
  4271. * @param x defines the scale factor on X axis
  4272. * @param y defines the scale factor on Y axis
  4273. * @param z defines the scale factor on Z axis
  4274. * @returns the new matrix
  4275. */
  4276. static Scaling(x: number, y: number, z: number): Matrix;
  4277. /**
  4278. * Creates a scaling matrix and stores it in a given matrix
  4279. * @param x defines the scale factor on X axis
  4280. * @param y defines the scale factor on Y axis
  4281. * @param z defines the scale factor on Z axis
  4282. * @param result defines the target matrix
  4283. */
  4284. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4285. /**
  4286. * Creates a translation matrix
  4287. * @param x defines the translation on X axis
  4288. * @param y defines the translation on Y axis
  4289. * @param z defines the translationon Z axis
  4290. * @returns the new matrix
  4291. */
  4292. static Translation(x: number, y: number, z: number): Matrix;
  4293. /**
  4294. * Creates a translation matrix and stores it in a given matrix
  4295. * @param x defines the translation on X axis
  4296. * @param y defines the translation on Y axis
  4297. * @param z defines the translationon Z axis
  4298. * @param result defines the target matrix
  4299. */
  4300. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4301. /**
  4302. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4303. * @param startValue defines the start value
  4304. * @param endValue defines the end value
  4305. * @param gradient defines the gradient factor
  4306. * @returns the new matrix
  4307. */
  4308. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4309. /**
  4310. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4311. * @param startValue defines the start value
  4312. * @param endValue defines the end value
  4313. * @param gradient defines the gradient factor
  4314. * @param result defines the Matrix object where to store data
  4315. */
  4316. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4317. /**
  4318. * Builds a new matrix whose values are computed by:
  4319. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4320. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4321. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4322. * @param startValue defines the first matrix
  4323. * @param endValue defines the second matrix
  4324. * @param gradient defines the gradient between the two matrices
  4325. * @returns the new matrix
  4326. */
  4327. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4328. /**
  4329. * Update a matrix to values which are computed by:
  4330. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4331. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4332. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4333. * @param startValue defines the first matrix
  4334. * @param endValue defines the second matrix
  4335. * @param gradient defines the gradient between the two matrices
  4336. * @param result defines the target matrix
  4337. */
  4338. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4339. /**
  4340. * 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"
  4341. * This function works in left handed mode
  4342. * @param eye defines the final position of the entity
  4343. * @param target defines where the entity should look at
  4344. * @param up defines the up vector for the entity
  4345. * @returns the new matrix
  4346. */
  4347. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4348. /**
  4349. * 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".
  4350. * This function works in left handed mode
  4351. * @param eye defines the final position of the entity
  4352. * @param target defines where the entity should look at
  4353. * @param up defines the up vector for the entity
  4354. * @param result defines the target matrix
  4355. */
  4356. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4357. /**
  4358. * 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"
  4359. * This function works in right handed mode
  4360. * @param eye defines the final position of the entity
  4361. * @param target defines where the entity should look at
  4362. * @param up defines the up vector for the entity
  4363. * @returns the new matrix
  4364. */
  4365. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4366. /**
  4367. * 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".
  4368. * This function works in right handed mode
  4369. * @param eye defines the final position of the entity
  4370. * @param target defines where the entity should look at
  4371. * @param up defines the up vector for the entity
  4372. * @param result defines the target matrix
  4373. */
  4374. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4375. /**
  4376. * Create a left-handed orthographic projection matrix
  4377. * @param width defines the viewport width
  4378. * @param height defines the viewport height
  4379. * @param znear defines the near clip plane
  4380. * @param zfar defines the far clip plane
  4381. * @returns a new matrix as a left-handed orthographic projection matrix
  4382. */
  4383. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4384. /**
  4385. * Store a left-handed orthographic projection to a given matrix
  4386. * @param width defines the viewport width
  4387. * @param height defines the viewport height
  4388. * @param znear defines the near clip plane
  4389. * @param zfar defines the far clip plane
  4390. * @param result defines the target matrix
  4391. */
  4392. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4393. /**
  4394. * Create a left-handed orthographic projection matrix
  4395. * @param left defines the viewport left coordinate
  4396. * @param right defines the viewport right coordinate
  4397. * @param bottom defines the viewport bottom coordinate
  4398. * @param top defines the viewport top coordinate
  4399. * @param znear defines the near clip plane
  4400. * @param zfar defines the far clip plane
  4401. * @returns a new matrix as a left-handed orthographic projection matrix
  4402. */
  4403. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4404. /**
  4405. * Stores a left-handed orthographic projection into a given matrix
  4406. * @param left defines the viewport left coordinate
  4407. * @param right defines the viewport right coordinate
  4408. * @param bottom defines the viewport bottom coordinate
  4409. * @param top defines the viewport top coordinate
  4410. * @param znear defines the near clip plane
  4411. * @param zfar defines the far clip plane
  4412. * @param result defines the target matrix
  4413. */
  4414. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4415. /**
  4416. * Creates a right-handed orthographic projection matrix
  4417. * @param left defines the viewport left coordinate
  4418. * @param right defines the viewport right coordinate
  4419. * @param bottom defines the viewport bottom coordinate
  4420. * @param top defines the viewport top coordinate
  4421. * @param znear defines the near clip plane
  4422. * @param zfar defines the far clip plane
  4423. * @returns a new matrix as a right-handed orthographic projection matrix
  4424. */
  4425. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4426. /**
  4427. * Stores a right-handed orthographic projection into a given matrix
  4428. * @param left defines the viewport left coordinate
  4429. * @param right defines the viewport right coordinate
  4430. * @param bottom defines the viewport bottom coordinate
  4431. * @param top defines the viewport top coordinate
  4432. * @param znear defines the near clip plane
  4433. * @param zfar defines the far clip plane
  4434. * @param result defines the target matrix
  4435. */
  4436. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4437. /**
  4438. * Creates a left-handed perspective projection matrix
  4439. * @param width defines the viewport width
  4440. * @param height defines the viewport height
  4441. * @param znear defines the near clip plane
  4442. * @param zfar defines the far clip plane
  4443. * @returns a new matrix as a left-handed perspective projection matrix
  4444. */
  4445. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4446. /**
  4447. * Creates a left-handed perspective projection matrix
  4448. * @param fov defines the horizontal field of view
  4449. * @param aspect defines the aspect ratio
  4450. * @param znear defines the near clip plane
  4451. * @param zfar defines the far clip plane
  4452. * @returns a new matrix as a left-handed perspective projection matrix
  4453. */
  4454. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4455. /**
  4456. * Stores a left-handed perspective projection into a given matrix
  4457. * @param fov defines the horizontal field of view
  4458. * @param aspect defines the aspect ratio
  4459. * @param znear defines the near clip plane
  4460. * @param zfar defines the far clip plane
  4461. * @param result defines the target matrix
  4462. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4463. */
  4464. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4465. /**
  4466. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4467. * @param fov defines the horizontal field of view
  4468. * @param aspect defines the aspect ratio
  4469. * @param znear defines the near clip plane
  4470. * @param zfar not used as infinity is used as far clip
  4471. * @param result defines the target matrix
  4472. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4473. */
  4474. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4475. /**
  4476. * Creates a right-handed perspective projection matrix
  4477. * @param fov defines the horizontal field of view
  4478. * @param aspect defines the aspect ratio
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a right-handed perspective projection matrix
  4482. */
  4483. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a right-handed perspective projection into a given matrix
  4486. * @param fov defines the horizontal field of view
  4487. * @param aspect defines the aspect ratio
  4488. * @param znear defines the near clip plane
  4489. * @param zfar defines the far clip plane
  4490. * @param result defines the target matrix
  4491. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4492. */
  4493. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4494. /**
  4495. * Stores a right-handed perspective projection into a given matrix
  4496. * @param fov defines the horizontal field of view
  4497. * @param aspect defines the aspect ratio
  4498. * @param znear defines the near clip plane
  4499. * @param zfar not used as infinity is used as far clip
  4500. * @param result defines the target matrix
  4501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4502. */
  4503. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4504. /**
  4505. * Stores a perspective projection for WebVR info a given matrix
  4506. * @param fov defines the field of view
  4507. * @param znear defines the near clip plane
  4508. * @param zfar defines the far clip plane
  4509. * @param result defines the target matrix
  4510. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4511. */
  4512. static PerspectiveFovWebVRToRef(fov: {
  4513. upDegrees: number;
  4514. downDegrees: number;
  4515. leftDegrees: number;
  4516. rightDegrees: number;
  4517. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4518. /**
  4519. * Computes a complete transformation matrix
  4520. * @param viewport defines the viewport to use
  4521. * @param world defines the world matrix
  4522. * @param view defines the view matrix
  4523. * @param projection defines the projection matrix
  4524. * @param zmin defines the near clip plane
  4525. * @param zmax defines the far clip plane
  4526. * @returns the transformation matrix
  4527. */
  4528. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4529. /**
  4530. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4531. * @param matrix defines the matrix to use
  4532. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4533. */
  4534. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4535. /**
  4536. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4537. * @param matrix defines the matrix to use
  4538. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4539. */
  4540. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4541. /**
  4542. * Compute the transpose of a given matrix
  4543. * @param matrix defines the matrix to transpose
  4544. * @returns the new matrix
  4545. */
  4546. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4547. /**
  4548. * Compute the transpose of a matrix and store it in a target matrix
  4549. * @param matrix defines the matrix to transpose
  4550. * @param result defines the target matrix
  4551. */
  4552. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4553. /**
  4554. * Computes a reflection matrix from a plane
  4555. * @param plane defines the reflection plane
  4556. * @returns a new matrix
  4557. */
  4558. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4559. /**
  4560. * Computes a reflection matrix from a plane
  4561. * @param plane defines the reflection plane
  4562. * @param result defines the target matrix
  4563. */
  4564. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4565. /**
  4566. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4567. * @param xaxis defines the value of the 1st axis
  4568. * @param yaxis defines the value of the 2nd axis
  4569. * @param zaxis defines the value of the 3rd axis
  4570. * @param result defines the target matrix
  4571. */
  4572. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4573. /**
  4574. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4575. * @param quat defines the quaternion to use
  4576. * @param result defines the target matrix
  4577. */
  4578. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4579. }
  4580. /**
  4581. * @hidden
  4582. */
  4583. export class TmpVectors {
  4584. static Vector2: Vector2[];
  4585. static Vector3: Vector3[];
  4586. static Vector4: Vector4[];
  4587. static Quaternion: Quaternion[];
  4588. static Matrix: Matrix[];
  4589. }
  4590. }
  4591. declare module BABYLON {
  4592. /**
  4593. * Defines potential orientation for back face culling
  4594. */
  4595. export enum Orientation {
  4596. /**
  4597. * Clockwise
  4598. */
  4599. CW = 0,
  4600. /** Counter clockwise */
  4601. CCW = 1
  4602. }
  4603. /** Class used to represent a Bezier curve */
  4604. export class BezierCurve {
  4605. /**
  4606. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4607. * @param t defines the time
  4608. * @param x1 defines the left coordinate on X axis
  4609. * @param y1 defines the left coordinate on Y axis
  4610. * @param x2 defines the right coordinate on X axis
  4611. * @param y2 defines the right coordinate on Y axis
  4612. * @returns the interpolated value
  4613. */
  4614. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4615. }
  4616. /**
  4617. * Defines angle representation
  4618. */
  4619. export class Angle {
  4620. private _radians;
  4621. /**
  4622. * Creates an Angle object of "radians" radians (float).
  4623. * @param radians the angle in radians
  4624. */
  4625. constructor(radians: number);
  4626. /**
  4627. * Get value in degrees
  4628. * @returns the Angle value in degrees (float)
  4629. */
  4630. degrees(): number;
  4631. /**
  4632. * Get value in radians
  4633. * @returns the Angle value in radians (float)
  4634. */
  4635. radians(): number;
  4636. /**
  4637. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4638. * @param a defines first vector
  4639. * @param b defines second vector
  4640. * @returns a new Angle
  4641. */
  4642. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4643. /**
  4644. * Gets a new Angle object from the given float in radians
  4645. * @param radians defines the angle value in radians
  4646. * @returns a new Angle
  4647. */
  4648. static FromRadians(radians: number): Angle;
  4649. /**
  4650. * Gets a new Angle object from the given float in degrees
  4651. * @param degrees defines the angle value in degrees
  4652. * @returns a new Angle
  4653. */
  4654. static FromDegrees(degrees: number): Angle;
  4655. }
  4656. /**
  4657. * This represents an arc in a 2d space.
  4658. */
  4659. export class Arc2 {
  4660. /** Defines the start point of the arc */
  4661. startPoint: Vector2;
  4662. /** Defines the mid point of the arc */
  4663. midPoint: Vector2;
  4664. /** Defines the end point of the arc */
  4665. endPoint: Vector2;
  4666. /**
  4667. * Defines the center point of the arc.
  4668. */
  4669. centerPoint: Vector2;
  4670. /**
  4671. * Defines the radius of the arc.
  4672. */
  4673. radius: number;
  4674. /**
  4675. * Defines the angle of the arc (from mid point to end point).
  4676. */
  4677. angle: Angle;
  4678. /**
  4679. * Defines the start angle of the arc (from start point to middle point).
  4680. */
  4681. startAngle: Angle;
  4682. /**
  4683. * Defines the orientation of the arc (clock wise/counter clock wise).
  4684. */
  4685. orientation: Orientation;
  4686. /**
  4687. * Creates an Arc object from the three given points : start, middle and end.
  4688. * @param startPoint Defines the start point of the arc
  4689. * @param midPoint Defines the midlle point of the arc
  4690. * @param endPoint Defines the end point of the arc
  4691. */
  4692. constructor(
  4693. /** Defines the start point of the arc */
  4694. startPoint: Vector2,
  4695. /** Defines the mid point of the arc */
  4696. midPoint: Vector2,
  4697. /** Defines the end point of the arc */
  4698. endPoint: Vector2);
  4699. }
  4700. /**
  4701. * Represents a 2D path made up of multiple 2D points
  4702. */
  4703. export class Path2 {
  4704. private _points;
  4705. private _length;
  4706. /**
  4707. * If the path start and end point are the same
  4708. */
  4709. closed: boolean;
  4710. /**
  4711. * Creates a Path2 object from the starting 2D coordinates x and y.
  4712. * @param x the starting points x value
  4713. * @param y the starting points y value
  4714. */
  4715. constructor(x: number, y: number);
  4716. /**
  4717. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4718. * @param x the added points x value
  4719. * @param y the added points y value
  4720. * @returns the updated Path2.
  4721. */
  4722. addLineTo(x: number, y: number): Path2;
  4723. /**
  4724. * 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.
  4725. * @param midX middle point x value
  4726. * @param midY middle point y value
  4727. * @param endX end point x value
  4728. * @param endY end point y value
  4729. * @param numberOfSegments (default: 36)
  4730. * @returns the updated Path2.
  4731. */
  4732. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4733. /**
  4734. * Closes the Path2.
  4735. * @returns the Path2.
  4736. */
  4737. close(): Path2;
  4738. /**
  4739. * Gets the sum of the distance between each sequential point in the path
  4740. * @returns the Path2 total length (float).
  4741. */
  4742. length(): number;
  4743. /**
  4744. * Gets the points which construct the path
  4745. * @returns the Path2 internal array of points.
  4746. */
  4747. getPoints(): Vector2[];
  4748. /**
  4749. * Retreives the point at the distance aways from the starting point
  4750. * @param normalizedLengthPosition the length along the path to retreive the point from
  4751. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4752. */
  4753. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4754. /**
  4755. * Creates a new path starting from an x and y position
  4756. * @param x starting x value
  4757. * @param y starting y value
  4758. * @returns a new Path2 starting at the coordinates (x, y).
  4759. */
  4760. static StartingAt(x: number, y: number): Path2;
  4761. }
  4762. /**
  4763. * Represents a 3D path made up of multiple 3D points
  4764. */
  4765. export class Path3D {
  4766. /**
  4767. * an array of Vector3, the curve axis of the Path3D
  4768. */
  4769. path: Vector3[];
  4770. private _curve;
  4771. private _distances;
  4772. private _tangents;
  4773. private _normals;
  4774. private _binormals;
  4775. private _raw;
  4776. private _alignTangentsWithPath;
  4777. private readonly _pointAtData;
  4778. /**
  4779. * new Path3D(path, normal, raw)
  4780. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4781. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4782. * @param path an array of Vector3, the curve axis of the Path3D
  4783. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4784. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4785. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4786. */
  4787. constructor(
  4788. /**
  4789. * an array of Vector3, the curve axis of the Path3D
  4790. */
  4791. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4792. /**
  4793. * Returns the Path3D array of successive Vector3 designing its curve.
  4794. * @returns the Path3D array of successive Vector3 designing its curve.
  4795. */
  4796. getCurve(): Vector3[];
  4797. /**
  4798. * Returns the Path3D array of successive Vector3 designing its curve.
  4799. * @returns the Path3D array of successive Vector3 designing its curve.
  4800. */
  4801. getPoints(): Vector3[];
  4802. /**
  4803. * @returns the computed length (float) of the path.
  4804. */
  4805. length(): number;
  4806. /**
  4807. * Returns an array populated with tangent vectors on each Path3D curve point.
  4808. * @returns an array populated with tangent vectors on each Path3D curve point.
  4809. */
  4810. getTangents(): Vector3[];
  4811. /**
  4812. * Returns an array populated with normal vectors on each Path3D curve point.
  4813. * @returns an array populated with normal vectors on each Path3D curve point.
  4814. */
  4815. getNormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with binormal vectors on each Path3D curve point.
  4818. * @returns an array populated with binormal vectors on each Path3D curve point.
  4819. */
  4820. getBinormals(): Vector3[];
  4821. /**
  4822. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4823. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4824. */
  4825. getDistances(): number[];
  4826. /**
  4827. * Returns an interpolated point along this path
  4828. * @param position the position of the point along this path, from 0.0 to 1.0
  4829. * @returns a new Vector3 as the point
  4830. */
  4831. getPointAt(position: number): Vector3;
  4832. /**
  4833. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4834. * @param position the position of the point along this path, from 0.0 to 1.0
  4835. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4836. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4837. */
  4838. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4839. /**
  4840. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4841. * @param position the position of the point along this path, from 0.0 to 1.0
  4842. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4843. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4844. */
  4845. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4846. /**
  4847. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4848. * @param position the position of the point along this path, from 0.0 to 1.0
  4849. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4850. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4851. */
  4852. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4853. /**
  4854. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4857. */
  4858. getDistanceAt(position: number): number;
  4859. /**
  4860. * Returns the array index of the previous point of an interpolated point along this path
  4861. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4862. * @returns the array index
  4863. */
  4864. getPreviousPointIndexAt(position: number): number;
  4865. /**
  4866. * 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)
  4867. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4868. * @returns the sub position
  4869. */
  4870. getSubPositionAt(position: number): number;
  4871. /**
  4872. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4873. * @param target the vector of which to get the closest position to
  4874. * @returns the position of the closest virtual point on this path to the target vector
  4875. */
  4876. getClosestPositionTo(target: Vector3): number;
  4877. /**
  4878. * Returns a sub path (slice) of this path
  4879. * @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
  4880. * @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
  4881. * @returns a sub path (slice) of this path
  4882. */
  4883. slice(start?: number, end?: number): Path3D;
  4884. /**
  4885. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4886. * @param path path which all values are copied into the curves points
  4887. * @param firstNormal which should be projected onto the curve
  4888. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4889. * @returns the same object updated.
  4890. */
  4891. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4892. private _compute;
  4893. private _getFirstNonNullVector;
  4894. private _getLastNonNullVector;
  4895. private _normalVector;
  4896. /**
  4897. * Updates the point at data for an interpolated point along this curve
  4898. * @param position the position of the point along this curve, from 0.0 to 1.0
  4899. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4900. * @returns the (updated) point at data
  4901. */
  4902. private _updatePointAtData;
  4903. /**
  4904. * Updates the point at data from the specified parameters
  4905. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4906. * @param point the interpolated point
  4907. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4908. */
  4909. private _setPointAtData;
  4910. /**
  4911. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4912. */
  4913. private _updateInterpolationMatrix;
  4914. }
  4915. /**
  4916. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4917. * A Curve3 is designed from a series of successive Vector3.
  4918. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4919. */
  4920. export class Curve3 {
  4921. private _points;
  4922. private _length;
  4923. /**
  4924. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4925. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4926. * @param v1 (Vector3) the control point
  4927. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4928. * @param nbPoints (integer) the wanted number of points in the curve
  4929. * @returns the created Curve3
  4930. */
  4931. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4932. /**
  4933. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4934. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4935. * @param v1 (Vector3) the first control point
  4936. * @param v2 (Vector3) the second control point
  4937. * @param v3 (Vector3) the end point of the Cubic Bezier
  4938. * @param nbPoints (integer) the wanted number of points in the curve
  4939. * @returns the created Curve3
  4940. */
  4941. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4942. /**
  4943. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4944. * @param p1 (Vector3) the origin point of the Hermite Spline
  4945. * @param t1 (Vector3) the tangent vector at the origin point
  4946. * @param p2 (Vector3) the end point of the Hermite Spline
  4947. * @param t2 (Vector3) the tangent vector at the end point
  4948. * @param nbPoints (integer) the wanted number of points in the curve
  4949. * @returns the created Curve3
  4950. */
  4951. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4952. /**
  4953. * Returns a Curve3 object along a CatmullRom Spline curve :
  4954. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4955. * @param nbPoints (integer) the wanted number of points between each curve control points
  4956. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4957. * @returns the created Curve3
  4958. */
  4959. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4960. /**
  4961. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4962. * A Curve3 is designed from a series of successive Vector3.
  4963. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4964. * @param points points which make up the curve
  4965. */
  4966. constructor(points: Vector3[]);
  4967. /**
  4968. * @returns the Curve3 stored array of successive Vector3
  4969. */
  4970. getPoints(): Vector3[];
  4971. /**
  4972. * @returns the computed length (float) of the curve.
  4973. */
  4974. length(): number;
  4975. /**
  4976. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4977. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4978. * curveA and curveB keep unchanged.
  4979. * @param curve the curve to continue from this curve
  4980. * @returns the newly constructed curve
  4981. */
  4982. continue(curve: DeepImmutable<Curve3>): Curve3;
  4983. private _computeLength;
  4984. }
  4985. }
  4986. declare module BABYLON {
  4987. /**
  4988. * This represents the main contract an easing function should follow.
  4989. * Easing functions are used throughout the animation system.
  4990. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4991. */
  4992. export interface IEasingFunction {
  4993. /**
  4994. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4995. * of the easing function.
  4996. * The link below provides some of the most common examples of easing functions.
  4997. * @see https://easings.net/
  4998. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4999. * @returns the corresponding value on the curve defined by the easing function
  5000. */
  5001. ease(gradient: number): number;
  5002. }
  5003. /**
  5004. * Base class used for every default easing function.
  5005. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5006. */
  5007. export class EasingFunction implements IEasingFunction {
  5008. /**
  5009. * Interpolation follows the mathematical formula associated with the easing function.
  5010. */
  5011. static readonly EASINGMODE_EASEIN: number;
  5012. /**
  5013. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5014. */
  5015. static readonly EASINGMODE_EASEOUT: number;
  5016. /**
  5017. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5018. */
  5019. static readonly EASINGMODE_EASEINOUT: number;
  5020. private _easingMode;
  5021. /**
  5022. * Sets the easing mode of the current function.
  5023. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5024. */
  5025. setEasingMode(easingMode: number): void;
  5026. /**
  5027. * Gets the current easing mode.
  5028. * @returns the easing mode
  5029. */
  5030. getEasingMode(): number;
  5031. /**
  5032. * @hidden
  5033. */
  5034. easeInCore(gradient: number): number;
  5035. /**
  5036. * Given an input gradient between 0 and 1, this returns the corresponding value
  5037. * of the easing function.
  5038. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5039. * @returns the corresponding value on the curve defined by the easing function
  5040. */
  5041. ease(gradient: number): number;
  5042. }
  5043. /**
  5044. * Easing function with a circle shape (see link below).
  5045. * @see https://easings.net/#easeInCirc
  5046. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5047. */
  5048. export class CircleEase extends EasingFunction implements IEasingFunction {
  5049. /** @hidden */
  5050. easeInCore(gradient: number): number;
  5051. }
  5052. /**
  5053. * Easing function with a ease back shape (see link below).
  5054. * @see https://easings.net/#easeInBack
  5055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5056. */
  5057. export class BackEase extends EasingFunction implements IEasingFunction {
  5058. /** Defines the amplitude of the function */
  5059. amplitude: number;
  5060. /**
  5061. * Instantiates a back ease easing
  5062. * @see https://easings.net/#easeInBack
  5063. * @param amplitude Defines the amplitude of the function
  5064. */
  5065. constructor(
  5066. /** Defines the amplitude of the function */
  5067. amplitude?: number);
  5068. /** @hidden */
  5069. easeInCore(gradient: number): number;
  5070. }
  5071. /**
  5072. * Easing function with a bouncing shape (see link below).
  5073. * @see https://easings.net/#easeInBounce
  5074. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5075. */
  5076. export class BounceEase extends EasingFunction implements IEasingFunction {
  5077. /** Defines the number of bounces */
  5078. bounces: number;
  5079. /** Defines the amplitude of the bounce */
  5080. bounciness: number;
  5081. /**
  5082. * Instantiates a bounce easing
  5083. * @see https://easings.net/#easeInBounce
  5084. * @param bounces Defines the number of bounces
  5085. * @param bounciness Defines the amplitude of the bounce
  5086. */
  5087. constructor(
  5088. /** Defines the number of bounces */
  5089. bounces?: number,
  5090. /** Defines the amplitude of the bounce */
  5091. bounciness?: number);
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a power of 3 shape (see link below).
  5097. * @see https://easings.net/#easeInCubic
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class CubicEase extends EasingFunction implements IEasingFunction {
  5101. /** @hidden */
  5102. easeInCore(gradient: number): number;
  5103. }
  5104. /**
  5105. * Easing function with an elastic shape (see link below).
  5106. * @see https://easings.net/#easeInElastic
  5107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5108. */
  5109. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5110. /** Defines the number of oscillations*/
  5111. oscillations: number;
  5112. /** Defines the amplitude of the oscillations*/
  5113. springiness: number;
  5114. /**
  5115. * Instantiates an elastic easing function
  5116. * @see https://easings.net/#easeInElastic
  5117. * @param oscillations Defines the number of oscillations
  5118. * @param springiness Defines the amplitude of the oscillations
  5119. */
  5120. constructor(
  5121. /** Defines the number of oscillations*/
  5122. oscillations?: number,
  5123. /** Defines the amplitude of the oscillations*/
  5124. springiness?: number);
  5125. /** @hidden */
  5126. easeInCore(gradient: number): number;
  5127. }
  5128. /**
  5129. * Easing function with an exponential shape (see link below).
  5130. * @see https://easings.net/#easeInExpo
  5131. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5132. */
  5133. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5134. /** Defines the exponent of the function */
  5135. exponent: number;
  5136. /**
  5137. * Instantiates an exponential easing function
  5138. * @see https://easings.net/#easeInExpo
  5139. * @param exponent Defines the exponent of the function
  5140. */
  5141. constructor(
  5142. /** Defines the exponent of the function */
  5143. exponent?: number);
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with a power shape (see link below).
  5149. * @see https://easings.net/#easeInQuad
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class PowerEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the power of the function */
  5154. power: number;
  5155. /**
  5156. * Instantiates an power base easing function
  5157. * @see https://easings.net/#easeInQuad
  5158. * @param power Defines the power of the function
  5159. */
  5160. constructor(
  5161. /** Defines the power of the function */
  5162. power?: number);
  5163. /** @hidden */
  5164. easeInCore(gradient: number): number;
  5165. }
  5166. /**
  5167. * Easing function with a power of 2 shape (see link below).
  5168. * @see https://easings.net/#easeInQuad
  5169. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5170. */
  5171. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5172. /** @hidden */
  5173. easeInCore(gradient: number): number;
  5174. }
  5175. /**
  5176. * Easing function with a power of 4 shape (see link below).
  5177. * @see https://easings.net/#easeInQuart
  5178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5179. */
  5180. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5181. /** @hidden */
  5182. easeInCore(gradient: number): number;
  5183. }
  5184. /**
  5185. * Easing function with a power of 5 shape (see link below).
  5186. * @see https://easings.net/#easeInQuint
  5187. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5188. */
  5189. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with a sin shape (see link below).
  5195. * @see https://easings.net/#easeInSine
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class SineEase extends EasingFunction implements IEasingFunction {
  5199. /** @hidden */
  5200. easeInCore(gradient: number): number;
  5201. }
  5202. /**
  5203. * Easing function with a bezier shape (see link below).
  5204. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5208. /** Defines the x component of the start tangent in the bezier curve */
  5209. x1: number;
  5210. /** Defines the y component of the start tangent in the bezier curve */
  5211. y1: number;
  5212. /** Defines the x component of the end tangent in the bezier curve */
  5213. x2: number;
  5214. /** Defines the y component of the end tangent in the bezier curve */
  5215. y2: number;
  5216. /**
  5217. * Instantiates a bezier function
  5218. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5219. * @param x1 Defines the x component of the start tangent in the bezier curve
  5220. * @param y1 Defines the y component of the start tangent in the bezier curve
  5221. * @param x2 Defines the x component of the end tangent in the bezier curve
  5222. * @param y2 Defines the y component of the end tangent in the bezier curve
  5223. */
  5224. constructor(
  5225. /** Defines the x component of the start tangent in the bezier curve */
  5226. x1?: number,
  5227. /** Defines the y component of the start tangent in the bezier curve */
  5228. y1?: number,
  5229. /** Defines the x component of the end tangent in the bezier curve */
  5230. x2?: number,
  5231. /** Defines the y component of the end tangent in the bezier curve */
  5232. y2?: number);
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. }
  5237. declare module BABYLON {
  5238. /**
  5239. * Class used to hold a RBG color
  5240. */
  5241. export class Color3 {
  5242. /**
  5243. * Defines the red component (between 0 and 1, default is 0)
  5244. */
  5245. r: number;
  5246. /**
  5247. * Defines the green component (between 0 and 1, default is 0)
  5248. */
  5249. g: number;
  5250. /**
  5251. * Defines the blue component (between 0 and 1, default is 0)
  5252. */
  5253. b: number;
  5254. /**
  5255. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5256. * @param r defines the red component (between 0 and 1, default is 0)
  5257. * @param g defines the green component (between 0 and 1, default is 0)
  5258. * @param b defines the blue component (between 0 and 1, default is 0)
  5259. */
  5260. constructor(
  5261. /**
  5262. * Defines the red component (between 0 and 1, default is 0)
  5263. */
  5264. r?: number,
  5265. /**
  5266. * Defines the green component (between 0 and 1, default is 0)
  5267. */
  5268. g?: number,
  5269. /**
  5270. * Defines the blue component (between 0 and 1, default is 0)
  5271. */
  5272. b?: number);
  5273. /**
  5274. * Creates a string with the Color3 current values
  5275. * @returns the string representation of the Color3 object
  5276. */
  5277. toString(): string;
  5278. /**
  5279. * Returns the string "Color3"
  5280. * @returns "Color3"
  5281. */
  5282. getClassName(): string;
  5283. /**
  5284. * Compute the Color3 hash code
  5285. * @returns an unique number that can be used to hash Color3 objects
  5286. */
  5287. getHashCode(): number;
  5288. /**
  5289. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5290. * @param array defines the array where to store the r,g,b components
  5291. * @param index defines an optional index in the target array to define where to start storing values
  5292. * @returns the current Color3 object
  5293. */
  5294. toArray(array: FloatArray, index?: number): Color3;
  5295. /**
  5296. * Returns a new Color4 object from the current Color3 and the given alpha
  5297. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5298. * @returns a new Color4 object
  5299. */
  5300. toColor4(alpha?: number): Color4;
  5301. /**
  5302. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5303. * @returns the new array
  5304. */
  5305. asArray(): number[];
  5306. /**
  5307. * Returns the luminance value
  5308. * @returns a float value
  5309. */
  5310. toLuminance(): number;
  5311. /**
  5312. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5313. * @param otherColor defines the second operand
  5314. * @returns the new Color3 object
  5315. */
  5316. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5317. /**
  5318. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5319. * @param otherColor defines the second operand
  5320. * @param result defines the Color3 object where to store the result
  5321. * @returns the current Color3
  5322. */
  5323. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5324. /**
  5325. * Determines equality between Color3 objects
  5326. * @param otherColor defines the second operand
  5327. * @returns true if the rgb values are equal to the given ones
  5328. */
  5329. equals(otherColor: DeepImmutable<Color3>): boolean;
  5330. /**
  5331. * Determines equality between the current Color3 object and a set of r,b,g values
  5332. * @param r defines the red component to check
  5333. * @param g defines the green component to check
  5334. * @param b defines the blue component to check
  5335. * @returns true if the rgb values are equal to the given ones
  5336. */
  5337. equalsFloats(r: number, g: number, b: number): boolean;
  5338. /**
  5339. * Multiplies in place each rgb value by scale
  5340. * @param scale defines the scaling factor
  5341. * @returns the updated Color3
  5342. */
  5343. scale(scale: number): Color3;
  5344. /**
  5345. * Multiplies the rgb values by scale and stores the result into "result"
  5346. * @param scale defines the scaling factor
  5347. * @param result defines the Color3 object where to store the result
  5348. * @returns the unmodified current Color3
  5349. */
  5350. scaleToRef(scale: number, result: Color3): Color3;
  5351. /**
  5352. * Scale the current Color3 values by a factor and add the result to a given Color3
  5353. * @param scale defines the scale factor
  5354. * @param result defines color to store the result into
  5355. * @returns the unmodified current Color3
  5356. */
  5357. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5358. /**
  5359. * Clamps the rgb values by the min and max values and stores the result into "result"
  5360. * @param min defines minimum clamping value (default is 0)
  5361. * @param max defines maximum clamping value (default is 1)
  5362. * @param result defines color to store the result into
  5363. * @returns the original Color3
  5364. */
  5365. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5366. /**
  5367. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5368. * @param otherColor defines the second operand
  5369. * @returns the new Color3
  5370. */
  5371. add(otherColor: DeepImmutable<Color3>): Color3;
  5372. /**
  5373. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5374. * @param otherColor defines the second operand
  5375. * @param result defines Color3 object to store the result into
  5376. * @returns the unmodified current Color3
  5377. */
  5378. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5379. /**
  5380. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5381. * @param otherColor defines the second operand
  5382. * @returns the new Color3
  5383. */
  5384. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5385. /**
  5386. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5387. * @param otherColor defines the second operand
  5388. * @param result defines Color3 object to store the result into
  5389. * @returns the unmodified current Color3
  5390. */
  5391. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5392. /**
  5393. * Copy the current object
  5394. * @returns a new Color3 copied the current one
  5395. */
  5396. clone(): Color3;
  5397. /**
  5398. * Copies the rgb values from the source in the current Color3
  5399. * @param source defines the source Color3 object
  5400. * @returns the updated Color3 object
  5401. */
  5402. copyFrom(source: DeepImmutable<Color3>): Color3;
  5403. /**
  5404. * Updates the Color3 rgb values from the given floats
  5405. * @param r defines the red component to read from
  5406. * @param g defines the green component to read from
  5407. * @param b defines the blue component to read from
  5408. * @returns the current Color3 object
  5409. */
  5410. copyFromFloats(r: number, g: number, b: number): Color3;
  5411. /**
  5412. * Updates the Color3 rgb values from the given floats
  5413. * @param r defines the red component to read from
  5414. * @param g defines the green component to read from
  5415. * @param b defines the blue component to read from
  5416. * @returns the current Color3 object
  5417. */
  5418. set(r: number, g: number, b: number): Color3;
  5419. /**
  5420. * Compute the Color3 hexadecimal code as a string
  5421. * @returns a string containing the hexadecimal representation of the Color3 object
  5422. */
  5423. toHexString(): string;
  5424. /**
  5425. * Computes a new Color3 converted from the current one to linear space
  5426. * @returns a new Color3 object
  5427. */
  5428. toLinearSpace(): Color3;
  5429. /**
  5430. * Converts current color in rgb space to HSV values
  5431. * @returns a new color3 representing the HSV values
  5432. */
  5433. toHSV(): Color3;
  5434. /**
  5435. * Converts current color in rgb space to HSV values
  5436. * @param result defines the Color3 where to store the HSV values
  5437. */
  5438. toHSVToRef(result: Color3): void;
  5439. /**
  5440. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5441. * @param convertedColor defines the Color3 object where to store the linear space version
  5442. * @returns the unmodified Color3
  5443. */
  5444. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5445. /**
  5446. * Computes a new Color3 converted from the current one to gamma space
  5447. * @returns a new Color3 object
  5448. */
  5449. toGammaSpace(): Color3;
  5450. /**
  5451. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5452. * @param convertedColor defines the Color3 object where to store the gamma space version
  5453. * @returns the unmodified Color3
  5454. */
  5455. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5456. private static _BlackReadOnly;
  5457. /**
  5458. * Convert Hue, saturation and value to a Color3 (RGB)
  5459. * @param hue defines the hue
  5460. * @param saturation defines the saturation
  5461. * @param value defines the value
  5462. * @param result defines the Color3 where to store the RGB values
  5463. */
  5464. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5465. /**
  5466. * Creates a new Color3 from the string containing valid hexadecimal values
  5467. * @param hex defines a string containing valid hexadecimal values
  5468. * @returns a new Color3 object
  5469. */
  5470. static FromHexString(hex: string): Color3;
  5471. /**
  5472. * Creates a new Color3 from the starting index of the given array
  5473. * @param array defines the source array
  5474. * @param offset defines an offset in the source array
  5475. * @returns a new Color3 object
  5476. */
  5477. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5478. /**
  5479. * Creates a new Color3 from integer values (< 256)
  5480. * @param r defines the red component to read from (value between 0 and 255)
  5481. * @param g defines the green component to read from (value between 0 and 255)
  5482. * @param b defines the blue component to read from (value between 0 and 255)
  5483. * @returns a new Color3 object
  5484. */
  5485. static FromInts(r: number, g: number, b: number): Color3;
  5486. /**
  5487. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5488. * @param start defines the start Color3 value
  5489. * @param end defines the end Color3 value
  5490. * @param amount defines the gradient value between start and end
  5491. * @returns a new Color3 object
  5492. */
  5493. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5494. /**
  5495. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5496. * @param left defines the start value
  5497. * @param right defines the end value
  5498. * @param amount defines the gradient factor
  5499. * @param result defines the Color3 object where to store the result
  5500. */
  5501. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5502. /**
  5503. * Returns a Color3 value containing a red color
  5504. * @returns a new Color3 object
  5505. */
  5506. static Red(): Color3;
  5507. /**
  5508. * Returns a Color3 value containing a green color
  5509. * @returns a new Color3 object
  5510. */
  5511. static Green(): Color3;
  5512. /**
  5513. * Returns a Color3 value containing a blue color
  5514. * @returns a new Color3 object
  5515. */
  5516. static Blue(): Color3;
  5517. /**
  5518. * Returns a Color3 value containing a black color
  5519. * @returns a new Color3 object
  5520. */
  5521. static Black(): Color3;
  5522. /**
  5523. * Gets a Color3 value containing a black color that must not be updated
  5524. */
  5525. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5526. /**
  5527. * Returns a Color3 value containing a white color
  5528. * @returns a new Color3 object
  5529. */
  5530. static White(): Color3;
  5531. /**
  5532. * Returns a Color3 value containing a purple color
  5533. * @returns a new Color3 object
  5534. */
  5535. static Purple(): Color3;
  5536. /**
  5537. * Returns a Color3 value containing a magenta color
  5538. * @returns a new Color3 object
  5539. */
  5540. static Magenta(): Color3;
  5541. /**
  5542. * Returns a Color3 value containing a yellow color
  5543. * @returns a new Color3 object
  5544. */
  5545. static Yellow(): Color3;
  5546. /**
  5547. * Returns a Color3 value containing a gray color
  5548. * @returns a new Color3 object
  5549. */
  5550. static Gray(): Color3;
  5551. /**
  5552. * Returns a Color3 value containing a teal color
  5553. * @returns a new Color3 object
  5554. */
  5555. static Teal(): Color3;
  5556. /**
  5557. * Returns a Color3 value containing a random color
  5558. * @returns a new Color3 object
  5559. */
  5560. static Random(): Color3;
  5561. }
  5562. /**
  5563. * Class used to hold a RBGA color
  5564. */
  5565. export class Color4 {
  5566. /**
  5567. * Defines the red component (between 0 and 1, default is 0)
  5568. */
  5569. r: number;
  5570. /**
  5571. * Defines the green component (between 0 and 1, default is 0)
  5572. */
  5573. g: number;
  5574. /**
  5575. * Defines the blue component (between 0 and 1, default is 0)
  5576. */
  5577. b: number;
  5578. /**
  5579. * Defines the alpha component (between 0 and 1, default is 1)
  5580. */
  5581. a: number;
  5582. /**
  5583. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5584. * @param r defines the red component (between 0 and 1, default is 0)
  5585. * @param g defines the green component (between 0 and 1, default is 0)
  5586. * @param b defines the blue component (between 0 and 1, default is 0)
  5587. * @param a defines the alpha component (between 0 and 1, default is 1)
  5588. */
  5589. constructor(
  5590. /**
  5591. * Defines the red component (between 0 and 1, default is 0)
  5592. */
  5593. r?: number,
  5594. /**
  5595. * Defines the green component (between 0 and 1, default is 0)
  5596. */
  5597. g?: number,
  5598. /**
  5599. * Defines the blue component (between 0 and 1, default is 0)
  5600. */
  5601. b?: number,
  5602. /**
  5603. * Defines the alpha component (between 0 and 1, default is 1)
  5604. */
  5605. a?: number);
  5606. /**
  5607. * Adds in place the given Color4 values to the current Color4 object
  5608. * @param right defines the second operand
  5609. * @returns the current updated Color4 object
  5610. */
  5611. addInPlace(right: DeepImmutable<Color4>): Color4;
  5612. /**
  5613. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5614. * @returns the new array
  5615. */
  5616. asArray(): number[];
  5617. /**
  5618. * Stores from the starting index in the given array the Color4 successive values
  5619. * @param array defines the array where to store the r,g,b components
  5620. * @param index defines an optional index in the target array to define where to start storing values
  5621. * @returns the current Color4 object
  5622. */
  5623. toArray(array: number[], index?: number): Color4;
  5624. /**
  5625. * Determines equality between Color4 objects
  5626. * @param otherColor defines the second operand
  5627. * @returns true if the rgba values are equal to the given ones
  5628. */
  5629. equals(otherColor: DeepImmutable<Color4>): boolean;
  5630. /**
  5631. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5632. * @param right defines the second operand
  5633. * @returns a new Color4 object
  5634. */
  5635. add(right: DeepImmutable<Color4>): Color4;
  5636. /**
  5637. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5638. * @param right defines the second operand
  5639. * @returns a new Color4 object
  5640. */
  5641. subtract(right: DeepImmutable<Color4>): Color4;
  5642. /**
  5643. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5644. * @param right defines the second operand
  5645. * @param result defines the Color4 object where to store the result
  5646. * @returns the current Color4 object
  5647. */
  5648. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5649. /**
  5650. * Creates a new Color4 with the current Color4 values multiplied by scale
  5651. * @param scale defines the scaling factor to apply
  5652. * @returns a new Color4 object
  5653. */
  5654. scale(scale: number): Color4;
  5655. /**
  5656. * Multiplies the current Color4 values by scale and stores the result in "result"
  5657. * @param scale defines the scaling factor to apply
  5658. * @param result defines the Color4 object where to store the result
  5659. * @returns the current unmodified Color4
  5660. */
  5661. scaleToRef(scale: number, result: Color4): Color4;
  5662. /**
  5663. * Scale the current Color4 values by a factor and add the result to a given Color4
  5664. * @param scale defines the scale factor
  5665. * @param result defines the Color4 object where to store the result
  5666. * @returns the unmodified current Color4
  5667. */
  5668. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5669. /**
  5670. * Clamps the rgb values by the min and max values and stores the result into "result"
  5671. * @param min defines minimum clamping value (default is 0)
  5672. * @param max defines maximum clamping value (default is 1)
  5673. * @param result defines color to store the result into.
  5674. * @returns the cuurent Color4
  5675. */
  5676. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5677. /**
  5678. * Multipy an Color4 value by another and return a new Color4 object
  5679. * @param color defines the Color4 value to multiply by
  5680. * @returns a new Color4 object
  5681. */
  5682. multiply(color: Color4): Color4;
  5683. /**
  5684. * Multipy a Color4 value by another and push the result in a reference value
  5685. * @param color defines the Color4 value to multiply by
  5686. * @param result defines the Color4 to fill the result in
  5687. * @returns the result Color4
  5688. */
  5689. multiplyToRef(color: Color4, result: Color4): Color4;
  5690. /**
  5691. * Creates a string with the Color4 current values
  5692. * @returns the string representation of the Color4 object
  5693. */
  5694. toString(): string;
  5695. /**
  5696. * Returns the string "Color4"
  5697. * @returns "Color4"
  5698. */
  5699. getClassName(): string;
  5700. /**
  5701. * Compute the Color4 hash code
  5702. * @returns an unique number that can be used to hash Color4 objects
  5703. */
  5704. getHashCode(): number;
  5705. /**
  5706. * Creates a new Color4 copied from the current one
  5707. * @returns a new Color4 object
  5708. */
  5709. clone(): Color4;
  5710. /**
  5711. * Copies the given Color4 values into the current one
  5712. * @param source defines the source Color4 object
  5713. * @returns the current updated Color4 object
  5714. */
  5715. copyFrom(source: Color4): Color4;
  5716. /**
  5717. * Copies the given float values into the current one
  5718. * @param r defines the red component to read from
  5719. * @param g defines the green component to read from
  5720. * @param b defines the blue component to read from
  5721. * @param a defines the alpha component to read from
  5722. * @returns the current updated Color4 object
  5723. */
  5724. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5725. /**
  5726. * Copies the given float values into the current one
  5727. * @param r defines the red component to read from
  5728. * @param g defines the green component to read from
  5729. * @param b defines the blue component to read from
  5730. * @param a defines the alpha component to read from
  5731. * @returns the current updated Color4 object
  5732. */
  5733. set(r: number, g: number, b: number, a: number): Color4;
  5734. /**
  5735. * Compute the Color4 hexadecimal code as a string
  5736. * @returns a string containing the hexadecimal representation of the Color4 object
  5737. */
  5738. toHexString(): string;
  5739. /**
  5740. * Computes a new Color4 converted from the current one to linear space
  5741. * @returns a new Color4 object
  5742. */
  5743. toLinearSpace(): Color4;
  5744. /**
  5745. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5746. * @param convertedColor defines the Color4 object where to store the linear space version
  5747. * @returns the unmodified Color4
  5748. */
  5749. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5750. /**
  5751. * Computes a new Color4 converted from the current one to gamma space
  5752. * @returns a new Color4 object
  5753. */
  5754. toGammaSpace(): Color4;
  5755. /**
  5756. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5757. * @param convertedColor defines the Color4 object where to store the gamma space version
  5758. * @returns the unmodified Color4
  5759. */
  5760. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5761. /**
  5762. * Creates a new Color4 from the string containing valid hexadecimal values
  5763. * @param hex defines a string containing valid hexadecimal values
  5764. * @returns a new Color4 object
  5765. */
  5766. static FromHexString(hex: string): Color4;
  5767. /**
  5768. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5769. * @param left defines the start value
  5770. * @param right defines the end value
  5771. * @param amount defines the gradient factor
  5772. * @returns a new Color4 object
  5773. */
  5774. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5775. /**
  5776. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5777. * @param left defines the start value
  5778. * @param right defines the end value
  5779. * @param amount defines the gradient factor
  5780. * @param result defines the Color4 object where to store data
  5781. */
  5782. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5783. /**
  5784. * Creates a new Color4 from a Color3 and an alpha value
  5785. * @param color3 defines the source Color3 to read from
  5786. * @param alpha defines the alpha component (1.0 by default)
  5787. * @returns a new Color4 object
  5788. */
  5789. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5790. /**
  5791. * Creates a new Color4 from the starting index element of the given array
  5792. * @param array defines the source array to read from
  5793. * @param offset defines the offset in the source array
  5794. * @returns a new Color4 object
  5795. */
  5796. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5797. /**
  5798. * Creates a new Color3 from integer values (< 256)
  5799. * @param r defines the red component to read from (value between 0 and 255)
  5800. * @param g defines the green component to read from (value between 0 and 255)
  5801. * @param b defines the blue component to read from (value between 0 and 255)
  5802. * @param a defines the alpha component to read from (value between 0 and 255)
  5803. * @returns a new Color3 object
  5804. */
  5805. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5806. /**
  5807. * Check the content of a given array and convert it to an array containing RGBA data
  5808. * If the original array was already containing count * 4 values then it is returned directly
  5809. * @param colors defines the array to check
  5810. * @param count defines the number of RGBA data to expect
  5811. * @returns an array containing count * 4 values (RGBA)
  5812. */
  5813. static CheckColors4(colors: number[], count: number): number[];
  5814. }
  5815. /**
  5816. * @hidden
  5817. */
  5818. export class TmpColors {
  5819. static Color3: Color3[];
  5820. static Color4: Color4[];
  5821. }
  5822. }
  5823. declare module BABYLON {
  5824. /**
  5825. * Defines an interface which represents an animation key frame
  5826. */
  5827. export interface IAnimationKey {
  5828. /**
  5829. * Frame of the key frame
  5830. */
  5831. frame: number;
  5832. /**
  5833. * Value at the specifies key frame
  5834. */
  5835. value: any;
  5836. /**
  5837. * The input tangent for the cubic hermite spline
  5838. */
  5839. inTangent?: any;
  5840. /**
  5841. * The output tangent for the cubic hermite spline
  5842. */
  5843. outTangent?: any;
  5844. /**
  5845. * The animation interpolation type
  5846. */
  5847. interpolation?: AnimationKeyInterpolation;
  5848. }
  5849. /**
  5850. * Enum for the animation key frame interpolation type
  5851. */
  5852. export enum AnimationKeyInterpolation {
  5853. /**
  5854. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5855. */
  5856. STEP = 1
  5857. }
  5858. }
  5859. declare module BABYLON {
  5860. /**
  5861. * Represents the range of an animation
  5862. */
  5863. export class AnimationRange {
  5864. /**The name of the animation range**/
  5865. name: string;
  5866. /**The starting frame of the animation */
  5867. from: number;
  5868. /**The ending frame of the animation*/
  5869. to: number;
  5870. /**
  5871. * Initializes the range of an animation
  5872. * @param name The name of the animation range
  5873. * @param from The starting frame of the animation
  5874. * @param to The ending frame of the animation
  5875. */
  5876. constructor(
  5877. /**The name of the animation range**/
  5878. name: string,
  5879. /**The starting frame of the animation */
  5880. from: number,
  5881. /**The ending frame of the animation*/
  5882. to: number);
  5883. /**
  5884. * Makes a copy of the animation range
  5885. * @returns A copy of the animation range
  5886. */
  5887. clone(): AnimationRange;
  5888. }
  5889. }
  5890. declare module BABYLON {
  5891. /**
  5892. * Composed of a frame, and an action function
  5893. */
  5894. export class AnimationEvent {
  5895. /** The frame for which the event is triggered **/
  5896. frame: number;
  5897. /** The event to perform when triggered **/
  5898. action: (currentFrame: number) => void;
  5899. /** Specifies if the event should be triggered only once**/
  5900. onlyOnce?: boolean | undefined;
  5901. /**
  5902. * Specifies if the animation event is done
  5903. */
  5904. isDone: boolean;
  5905. /**
  5906. * Initializes the animation event
  5907. * @param frame The frame for which the event is triggered
  5908. * @param action The event to perform when triggered
  5909. * @param onlyOnce Specifies if the event should be triggered only once
  5910. */
  5911. constructor(
  5912. /** The frame for which the event is triggered **/
  5913. frame: number,
  5914. /** The event to perform when triggered **/
  5915. action: (currentFrame: number) => void,
  5916. /** Specifies if the event should be triggered only once**/
  5917. onlyOnce?: boolean | undefined);
  5918. /** @hidden */
  5919. _clone(): AnimationEvent;
  5920. }
  5921. }
  5922. declare module BABYLON {
  5923. /**
  5924. * Interface used to define a behavior
  5925. */
  5926. export interface Behavior<T> {
  5927. /** gets or sets behavior's name */
  5928. name: string;
  5929. /**
  5930. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5931. */
  5932. init(): void;
  5933. /**
  5934. * Called when the behavior is attached to a target
  5935. * @param target defines the target where the behavior is attached to
  5936. */
  5937. attach(target: T): void;
  5938. /**
  5939. * Called when the behavior is detached from its target
  5940. */
  5941. detach(): void;
  5942. }
  5943. /**
  5944. * Interface implemented by classes supporting behaviors
  5945. */
  5946. export interface IBehaviorAware<T> {
  5947. /**
  5948. * Attach a behavior
  5949. * @param behavior defines the behavior to attach
  5950. * @returns the current host
  5951. */
  5952. addBehavior(behavior: Behavior<T>): T;
  5953. /**
  5954. * Remove a behavior from the current object
  5955. * @param behavior defines the behavior to detach
  5956. * @returns the current host
  5957. */
  5958. removeBehavior(behavior: Behavior<T>): T;
  5959. /**
  5960. * Gets a behavior using its name to search
  5961. * @param name defines the name to search
  5962. * @returns the behavior or null if not found
  5963. */
  5964. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5965. }
  5966. }
  5967. declare module BABYLON {
  5968. /**
  5969. * Defines an array and its length.
  5970. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5971. */
  5972. export interface ISmartArrayLike<T> {
  5973. /**
  5974. * The data of the array.
  5975. */
  5976. data: Array<T>;
  5977. /**
  5978. * The active length of the array.
  5979. */
  5980. length: number;
  5981. }
  5982. /**
  5983. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5984. */
  5985. export class SmartArray<T> implements ISmartArrayLike<T> {
  5986. /**
  5987. * The full set of data from the array.
  5988. */
  5989. data: Array<T>;
  5990. /**
  5991. * The active length of the array.
  5992. */
  5993. length: number;
  5994. protected _id: number;
  5995. /**
  5996. * Instantiates a Smart Array.
  5997. * @param capacity defines the default capacity of the array.
  5998. */
  5999. constructor(capacity: number);
  6000. /**
  6001. * Pushes a value at the end of the active data.
  6002. * @param value defines the object to push in the array.
  6003. */
  6004. push(value: T): void;
  6005. /**
  6006. * Iterates over the active data and apply the lambda to them.
  6007. * @param func defines the action to apply on each value.
  6008. */
  6009. forEach(func: (content: T) => void): void;
  6010. /**
  6011. * Sorts the full sets of data.
  6012. * @param compareFn defines the comparison function to apply.
  6013. */
  6014. sort(compareFn: (a: T, b: T) => number): void;
  6015. /**
  6016. * Resets the active data to an empty array.
  6017. */
  6018. reset(): void;
  6019. /**
  6020. * Releases all the data from the array as well as the array.
  6021. */
  6022. dispose(): void;
  6023. /**
  6024. * Concats the active data with a given array.
  6025. * @param array defines the data to concatenate with.
  6026. */
  6027. concat(array: any): void;
  6028. /**
  6029. * Returns the position of a value in the active data.
  6030. * @param value defines the value to find the index for
  6031. * @returns the index if found in the active data otherwise -1
  6032. */
  6033. indexOf(value: T): number;
  6034. /**
  6035. * Returns whether an element is part of the active data.
  6036. * @param value defines the value to look for
  6037. * @returns true if found in the active data otherwise false
  6038. */
  6039. contains(value: T): boolean;
  6040. private static _GlobalId;
  6041. }
  6042. /**
  6043. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6044. * The data in this array can only be present once
  6045. */
  6046. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6047. private _duplicateId;
  6048. /**
  6049. * Pushes a value at the end of the active data.
  6050. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6051. * @param value defines the object to push in the array.
  6052. */
  6053. push(value: T): void;
  6054. /**
  6055. * Pushes a value at the end of the active data.
  6056. * If the data is already present, it won t be added again
  6057. * @param value defines the object to push in the array.
  6058. * @returns true if added false if it was already present
  6059. */
  6060. pushNoDuplicate(value: T): boolean;
  6061. /**
  6062. * Resets the active data to an empty array.
  6063. */
  6064. reset(): void;
  6065. /**
  6066. * Concats the active data with a given array.
  6067. * This ensures no dupplicate will be present in the result.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concatWithNoDuplicate(array: any): void;
  6071. }
  6072. }
  6073. declare module BABYLON {
  6074. /**
  6075. * @ignore
  6076. * This is a list of all the different input types that are available in the application.
  6077. * Fo instance: ArcRotateCameraGamepadInput...
  6078. */
  6079. export var CameraInputTypes: {};
  6080. /**
  6081. * This is the contract to implement in order to create a new input class.
  6082. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6083. */
  6084. export interface ICameraInput<TCamera extends Camera> {
  6085. /**
  6086. * Defines the camera the input is attached to.
  6087. */
  6088. camera: Nullable<TCamera>;
  6089. /**
  6090. * Gets the class name of the current intput.
  6091. * @returns the class name
  6092. */
  6093. getClassName(): string;
  6094. /**
  6095. * Get the friendly name associated with the input class.
  6096. * @returns the input friendly name
  6097. */
  6098. getSimpleName(): string;
  6099. /**
  6100. * Attach the input controls to a specific dom element to get the input from.
  6101. * @param element Defines the element the controls should be listened from
  6102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6103. */
  6104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6105. /**
  6106. * Detach the current controls from the specified dom element.
  6107. * @param element Defines the element to stop listening the inputs from
  6108. */
  6109. detachControl(element: Nullable<HTMLElement>): void;
  6110. /**
  6111. * Update the current camera state depending on the inputs that have been used this frame.
  6112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6113. */
  6114. checkInputs?: () => void;
  6115. }
  6116. /**
  6117. * Represents a map of input types to input instance or input index to input instance.
  6118. */
  6119. export interface CameraInputsMap<TCamera extends Camera> {
  6120. /**
  6121. * Accessor to the input by input type.
  6122. */
  6123. [name: string]: ICameraInput<TCamera>;
  6124. /**
  6125. * Accessor to the input by input index.
  6126. */
  6127. [idx: number]: ICameraInput<TCamera>;
  6128. }
  6129. /**
  6130. * This represents the input manager used within a camera.
  6131. * It helps dealing with all the different kind of input attached to a camera.
  6132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6133. */
  6134. export class CameraInputsManager<TCamera extends Camera> {
  6135. /**
  6136. * Defines the list of inputs attahed to the camera.
  6137. */
  6138. attached: CameraInputsMap<TCamera>;
  6139. /**
  6140. * Defines the dom element the camera is collecting inputs from.
  6141. * This is null if the controls have not been attached.
  6142. */
  6143. attachedElement: Nullable<HTMLElement>;
  6144. /**
  6145. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. noPreventDefault: boolean;
  6148. /**
  6149. * Defined the camera the input manager belongs to.
  6150. */
  6151. camera: TCamera;
  6152. /**
  6153. * Update the current camera state depending on the inputs that have been used this frame.
  6154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6155. */
  6156. checkInputs: () => void;
  6157. /**
  6158. * Instantiate a new Camera Input Manager.
  6159. * @param camera Defines the camera the input manager blongs to
  6160. */
  6161. constructor(camera: TCamera);
  6162. /**
  6163. * Add an input method to a camera
  6164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6165. * @param input camera input method
  6166. */
  6167. add(input: ICameraInput<TCamera>): void;
  6168. /**
  6169. * Remove a specific input method from a camera
  6170. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6171. * @param inputToRemove camera input method
  6172. */
  6173. remove(inputToRemove: ICameraInput<TCamera>): void;
  6174. /**
  6175. * Remove a specific input type from a camera
  6176. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6177. * @param inputType the type of the input to remove
  6178. */
  6179. removeByType(inputType: string): void;
  6180. private _addCheckInputs;
  6181. /**
  6182. * Attach the input controls to the currently attached dom element to listen the events from.
  6183. * @param input Defines the input to attach
  6184. */
  6185. attachInput(input: ICameraInput<TCamera>): void;
  6186. /**
  6187. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6188. * @param element Defines the dom element to collect the events from
  6189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6190. */
  6191. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6192. /**
  6193. * Detach the current manager inputs controls from a specific dom element.
  6194. * @param element Defines the dom element to collect the events from
  6195. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6196. */
  6197. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6198. /**
  6199. * Rebuild the dynamic inputCheck function from the current list of
  6200. * defined inputs in the manager.
  6201. */
  6202. rebuildInputCheck(): void;
  6203. /**
  6204. * Remove all attached input methods from a camera
  6205. */
  6206. clear(): void;
  6207. /**
  6208. * Serialize the current input manager attached to a camera.
  6209. * This ensures than once parsed,
  6210. * the input associated to the camera will be identical to the current ones
  6211. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6212. */
  6213. serialize(serializedCamera: any): void;
  6214. /**
  6215. * Parses an input manager serialized JSON to restore the previous list of inputs
  6216. * and states associated to a camera.
  6217. * @param parsedCamera Defines the JSON to parse
  6218. */
  6219. parse(parsedCamera: any): void;
  6220. }
  6221. }
  6222. declare module BABYLON {
  6223. /**
  6224. * Class used to store data that will be store in GPU memory
  6225. */
  6226. export class Buffer {
  6227. private _engine;
  6228. private _buffer;
  6229. /** @hidden */
  6230. _data: Nullable<DataArray>;
  6231. private _updatable;
  6232. private _instanced;
  6233. private _divisor;
  6234. /**
  6235. * Gets the byte stride.
  6236. */
  6237. readonly byteStride: number;
  6238. /**
  6239. * Constructor
  6240. * @param engine the engine
  6241. * @param data the data to use for this buffer
  6242. * @param updatable whether the data is updatable
  6243. * @param stride the stride (optional)
  6244. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6245. * @param instanced whether the buffer is instanced (optional)
  6246. * @param useBytes set to true if the stride in in bytes (optional)
  6247. * @param divisor sets an optional divisor for instances (1 by default)
  6248. */
  6249. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6250. /**
  6251. * Create a new VertexBuffer based on the current buffer
  6252. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6253. * @param offset defines offset in the buffer (0 by default)
  6254. * @param size defines the size in floats of attributes (position is 3 for instance)
  6255. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6256. * @param instanced defines if the vertex buffer contains indexed data
  6257. * @param useBytes defines if the offset and stride are in bytes *
  6258. * @param divisor sets an optional divisor for instances (1 by default)
  6259. * @returns the new vertex buffer
  6260. */
  6261. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6262. /**
  6263. * Gets a boolean indicating if the Buffer is updatable?
  6264. * @returns true if the buffer is updatable
  6265. */
  6266. isUpdatable(): boolean;
  6267. /**
  6268. * Gets current buffer's data
  6269. * @returns a DataArray or null
  6270. */
  6271. getData(): Nullable<DataArray>;
  6272. /**
  6273. * Gets underlying native buffer
  6274. * @returns underlying native buffer
  6275. */
  6276. getBuffer(): Nullable<DataBuffer>;
  6277. /**
  6278. * Gets the stride in float32 units (i.e. byte stride / 4).
  6279. * May not be an integer if the byte stride is not divisible by 4.
  6280. * @returns the stride in float32 units
  6281. * @deprecated Please use byteStride instead.
  6282. */
  6283. getStrideSize(): number;
  6284. /**
  6285. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6286. * @param data defines the data to store
  6287. */
  6288. create(data?: Nullable<DataArray>): void;
  6289. /** @hidden */
  6290. _rebuild(): void;
  6291. /**
  6292. * Update current buffer data
  6293. * @param data defines the data to store
  6294. */
  6295. update(data: DataArray): void;
  6296. /**
  6297. * Updates the data directly.
  6298. * @param data the new data
  6299. * @param offset the new offset
  6300. * @param vertexCount the vertex count (optional)
  6301. * @param useBytes set to true if the offset is in bytes
  6302. */
  6303. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6304. /**
  6305. * Release all resources
  6306. */
  6307. dispose(): void;
  6308. }
  6309. /**
  6310. * Specialized buffer used to store vertex data
  6311. */
  6312. export class VertexBuffer {
  6313. /** @hidden */
  6314. _buffer: Buffer;
  6315. private _kind;
  6316. private _size;
  6317. private _ownsBuffer;
  6318. private _instanced;
  6319. private _instanceDivisor;
  6320. /**
  6321. * The byte type.
  6322. */
  6323. static readonly BYTE: number;
  6324. /**
  6325. * The unsigned byte type.
  6326. */
  6327. static readonly UNSIGNED_BYTE: number;
  6328. /**
  6329. * The short type.
  6330. */
  6331. static readonly SHORT: number;
  6332. /**
  6333. * The unsigned short type.
  6334. */
  6335. static readonly UNSIGNED_SHORT: number;
  6336. /**
  6337. * The integer type.
  6338. */
  6339. static readonly INT: number;
  6340. /**
  6341. * The unsigned integer type.
  6342. */
  6343. static readonly UNSIGNED_INT: number;
  6344. /**
  6345. * The float type.
  6346. */
  6347. static readonly FLOAT: number;
  6348. /**
  6349. * Gets or sets the instance divisor when in instanced mode
  6350. */
  6351. instanceDivisor: number;
  6352. /**
  6353. * Gets the byte stride.
  6354. */
  6355. readonly byteStride: number;
  6356. /**
  6357. * Gets the byte offset.
  6358. */
  6359. readonly byteOffset: number;
  6360. /**
  6361. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6362. */
  6363. readonly normalized: boolean;
  6364. /**
  6365. * Gets the data type of each component in the array.
  6366. */
  6367. readonly type: number;
  6368. /**
  6369. * Constructor
  6370. * @param engine the engine
  6371. * @param data the data to use for this vertex buffer
  6372. * @param kind the vertex buffer kind
  6373. * @param updatable whether the data is updatable
  6374. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6375. * @param stride the stride (optional)
  6376. * @param instanced whether the buffer is instanced (optional)
  6377. * @param offset the offset of the data (optional)
  6378. * @param size the number of components (optional)
  6379. * @param type the type of the component (optional)
  6380. * @param normalized whether the data contains normalized data (optional)
  6381. * @param useBytes set to true if stride and offset are in bytes (optional)
  6382. * @param divisor defines the instance divisor to use (1 by default)
  6383. */
  6384. 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);
  6385. /** @hidden */
  6386. _rebuild(): void;
  6387. /**
  6388. * Returns the kind of the VertexBuffer (string)
  6389. * @returns a string
  6390. */
  6391. getKind(): string;
  6392. /**
  6393. * Gets a boolean indicating if the VertexBuffer is updatable?
  6394. * @returns true if the buffer is updatable
  6395. */
  6396. isUpdatable(): boolean;
  6397. /**
  6398. * Gets current buffer's data
  6399. * @returns a DataArray or null
  6400. */
  6401. getData(): Nullable<DataArray>;
  6402. /**
  6403. * Gets underlying native buffer
  6404. * @returns underlying native buffer
  6405. */
  6406. getBuffer(): Nullable<DataBuffer>;
  6407. /**
  6408. * Gets the stride in float32 units (i.e. byte stride / 4).
  6409. * May not be an integer if the byte stride is not divisible by 4.
  6410. * @returns the stride in float32 units
  6411. * @deprecated Please use byteStride instead.
  6412. */
  6413. getStrideSize(): number;
  6414. /**
  6415. * Returns the offset as a multiple of the type byte length.
  6416. * @returns the offset in bytes
  6417. * @deprecated Please use byteOffset instead.
  6418. */
  6419. getOffset(): number;
  6420. /**
  6421. * Returns the number of components per vertex attribute (integer)
  6422. * @returns the size in float
  6423. */
  6424. getSize(): number;
  6425. /**
  6426. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6427. * @returns true if this buffer is instanced
  6428. */
  6429. getIsInstanced(): boolean;
  6430. /**
  6431. * Returns the instancing divisor, zero for non-instanced (integer).
  6432. * @returns a number
  6433. */
  6434. getInstanceDivisor(): number;
  6435. /**
  6436. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6437. * @param data defines the data to store
  6438. */
  6439. create(data?: DataArray): void;
  6440. /**
  6441. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6442. * This function will create a new buffer if the current one is not updatable
  6443. * @param data defines the data to store
  6444. */
  6445. update(data: DataArray): void;
  6446. /**
  6447. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6448. * Returns the directly updated WebGLBuffer.
  6449. * @param data the new data
  6450. * @param offset the new offset
  6451. * @param useBytes set to true if the offset is in bytes
  6452. */
  6453. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6454. /**
  6455. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6456. */
  6457. dispose(): void;
  6458. /**
  6459. * Enumerates each value of this vertex buffer as numbers.
  6460. * @param count the number of values to enumerate
  6461. * @param callback the callback function called for each value
  6462. */
  6463. forEach(count: number, callback: (value: number, index: number) => void): void;
  6464. /**
  6465. * Positions
  6466. */
  6467. static readonly PositionKind: string;
  6468. /**
  6469. * Normals
  6470. */
  6471. static readonly NormalKind: string;
  6472. /**
  6473. * Tangents
  6474. */
  6475. static readonly TangentKind: string;
  6476. /**
  6477. * Texture coordinates
  6478. */
  6479. static readonly UVKind: string;
  6480. /**
  6481. * Texture coordinates 2
  6482. */
  6483. static readonly UV2Kind: string;
  6484. /**
  6485. * Texture coordinates 3
  6486. */
  6487. static readonly UV3Kind: string;
  6488. /**
  6489. * Texture coordinates 4
  6490. */
  6491. static readonly UV4Kind: string;
  6492. /**
  6493. * Texture coordinates 5
  6494. */
  6495. static readonly UV5Kind: string;
  6496. /**
  6497. * Texture coordinates 6
  6498. */
  6499. static readonly UV6Kind: string;
  6500. /**
  6501. * Colors
  6502. */
  6503. static readonly ColorKind: string;
  6504. /**
  6505. * Matrix indices (for bones)
  6506. */
  6507. static readonly MatricesIndicesKind: string;
  6508. /**
  6509. * Matrix weights (for bones)
  6510. */
  6511. static readonly MatricesWeightsKind: string;
  6512. /**
  6513. * Additional matrix indices (for bones)
  6514. */
  6515. static readonly MatricesIndicesExtraKind: string;
  6516. /**
  6517. * Additional matrix weights (for bones)
  6518. */
  6519. static readonly MatricesWeightsExtraKind: string;
  6520. /**
  6521. * Deduces the stride given a kind.
  6522. * @param kind The kind string to deduce
  6523. * @returns The deduced stride
  6524. */
  6525. static DeduceStride(kind: string): number;
  6526. /**
  6527. * Gets the byte length of the given type.
  6528. * @param type the type
  6529. * @returns the number of bytes
  6530. */
  6531. static GetTypeByteLength(type: number): number;
  6532. /**
  6533. * Enumerates each value of the given parameters as numbers.
  6534. * @param data the data to enumerate
  6535. * @param byteOffset the byte offset of the data
  6536. * @param byteStride the byte stride of the data
  6537. * @param componentCount the number of components per element
  6538. * @param componentType the type of the component
  6539. * @param count the number of values to enumerate
  6540. * @param normalized whether the data is normalized
  6541. * @param callback the callback function called for each value
  6542. */
  6543. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6544. private static _GetFloatValue;
  6545. }
  6546. }
  6547. declare module BABYLON {
  6548. /**
  6549. * @hidden
  6550. */
  6551. export class IntersectionInfo {
  6552. bu: Nullable<number>;
  6553. bv: Nullable<number>;
  6554. distance: number;
  6555. faceId: number;
  6556. subMeshId: number;
  6557. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6558. }
  6559. }
  6560. declare module BABYLON {
  6561. /**
  6562. * Represens a plane by the equation ax + by + cz + d = 0
  6563. */
  6564. export class Plane {
  6565. private static _TmpMatrix;
  6566. /**
  6567. * Normal of the plane (a,b,c)
  6568. */
  6569. normal: Vector3;
  6570. /**
  6571. * d component of the plane
  6572. */
  6573. d: number;
  6574. /**
  6575. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6576. * @param a a component of the plane
  6577. * @param b b component of the plane
  6578. * @param c c component of the plane
  6579. * @param d d component of the plane
  6580. */
  6581. constructor(a: number, b: number, c: number, d: number);
  6582. /**
  6583. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6584. */
  6585. asArray(): number[];
  6586. /**
  6587. * @returns a new plane copied from the current Plane.
  6588. */
  6589. clone(): Plane;
  6590. /**
  6591. * @returns the string "Plane".
  6592. */
  6593. getClassName(): string;
  6594. /**
  6595. * @returns the Plane hash code.
  6596. */
  6597. getHashCode(): number;
  6598. /**
  6599. * Normalize the current Plane in place.
  6600. * @returns the updated Plane.
  6601. */
  6602. normalize(): Plane;
  6603. /**
  6604. * Applies a transformation the plane and returns the result
  6605. * @param transformation the transformation matrix to be applied to the plane
  6606. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6607. */
  6608. transform(transformation: DeepImmutable<Matrix>): Plane;
  6609. /**
  6610. * Calcualtte the dot product between the point and the plane normal
  6611. * @param point point to calculate the dot product with
  6612. * @returns the dot product (float) of the point coordinates and the plane normal.
  6613. */
  6614. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6615. /**
  6616. * Updates the current Plane from the plane defined by the three given points.
  6617. * @param point1 one of the points used to contruct the plane
  6618. * @param point2 one of the points used to contruct the plane
  6619. * @param point3 one of the points used to contruct the plane
  6620. * @returns the updated Plane.
  6621. */
  6622. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6623. /**
  6624. * Checks if the plane is facing a given direction
  6625. * @param direction the direction to check if the plane is facing
  6626. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6627. * @returns True is the vector "direction" is the same side than the plane normal.
  6628. */
  6629. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6630. /**
  6631. * Calculates the distance to a point
  6632. * @param point point to calculate distance to
  6633. * @returns the signed distance (float) from the given point to the Plane.
  6634. */
  6635. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6636. /**
  6637. * Creates a plane from an array
  6638. * @param array the array to create a plane from
  6639. * @returns a new Plane from the given array.
  6640. */
  6641. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6642. /**
  6643. * Creates a plane from three points
  6644. * @param point1 point used to create the plane
  6645. * @param point2 point used to create the plane
  6646. * @param point3 point used to create the plane
  6647. * @returns a new Plane defined by the three given points.
  6648. */
  6649. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6650. /**
  6651. * Creates a plane from an origin point and a normal
  6652. * @param origin origin of the plane to be constructed
  6653. * @param normal normal of the plane to be constructed
  6654. * @returns a new Plane the normal vector to this plane at the given origin point.
  6655. * Note : the vector "normal" is updated because normalized.
  6656. */
  6657. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6658. /**
  6659. * Calculates the distance from a plane and a point
  6660. * @param origin origin of the plane to be constructed
  6661. * @param normal normal of the plane to be constructed
  6662. * @param point point to calculate distance to
  6663. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6664. */
  6665. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6666. }
  6667. }
  6668. declare module BABYLON {
  6669. /**
  6670. * Class used to store bounding sphere information
  6671. */
  6672. export class BoundingSphere {
  6673. /**
  6674. * Gets the center of the bounding sphere in local space
  6675. */
  6676. readonly center: Vector3;
  6677. /**
  6678. * Radius of the bounding sphere in local space
  6679. */
  6680. radius: number;
  6681. /**
  6682. * Gets the center of the bounding sphere in world space
  6683. */
  6684. readonly centerWorld: Vector3;
  6685. /**
  6686. * Radius of the bounding sphere in world space
  6687. */
  6688. radiusWorld: number;
  6689. /**
  6690. * Gets the minimum vector in local space
  6691. */
  6692. readonly minimum: Vector3;
  6693. /**
  6694. * Gets the maximum vector in local space
  6695. */
  6696. readonly maximum: Vector3;
  6697. private _worldMatrix;
  6698. private static readonly TmpVector3;
  6699. /**
  6700. * Creates a new bounding sphere
  6701. * @param min defines the minimum vector (in local space)
  6702. * @param max defines the maximum vector (in local space)
  6703. * @param worldMatrix defines the new world matrix
  6704. */
  6705. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6706. /**
  6707. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6708. * @param min defines the new minimum vector (in local space)
  6709. * @param max defines the new maximum vector (in local space)
  6710. * @param worldMatrix defines the new world matrix
  6711. */
  6712. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6713. /**
  6714. * Scale the current bounding sphere by applying a scale factor
  6715. * @param factor defines the scale factor to apply
  6716. * @returns the current bounding box
  6717. */
  6718. scale(factor: number): BoundingSphere;
  6719. /**
  6720. * Gets the world matrix of the bounding box
  6721. * @returns a matrix
  6722. */
  6723. getWorldMatrix(): DeepImmutable<Matrix>;
  6724. /** @hidden */
  6725. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6726. /**
  6727. * Tests if the bounding sphere is intersecting the frustum planes
  6728. * @param frustumPlanes defines the frustum planes to test
  6729. * @returns true if there is an intersection
  6730. */
  6731. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6732. /**
  6733. * Tests if the bounding sphere center is in between the frustum planes.
  6734. * Used for optimistic fast inclusion.
  6735. * @param frustumPlanes defines the frustum planes to test
  6736. * @returns true if the sphere center is in between the frustum planes
  6737. */
  6738. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6739. /**
  6740. * Tests if a point is inside the bounding sphere
  6741. * @param point defines the point to test
  6742. * @returns true if the point is inside the bounding sphere
  6743. */
  6744. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6745. /**
  6746. * Checks if two sphere intersct
  6747. * @param sphere0 sphere 0
  6748. * @param sphere1 sphere 1
  6749. * @returns true if the speres intersect
  6750. */
  6751. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6752. }
  6753. }
  6754. declare module BABYLON {
  6755. /**
  6756. * Class used to store bounding box information
  6757. */
  6758. export class BoundingBox implements ICullable {
  6759. /**
  6760. * Gets the 8 vectors representing the bounding box in local space
  6761. */
  6762. readonly vectors: Vector3[];
  6763. /**
  6764. * Gets the center of the bounding box in local space
  6765. */
  6766. readonly center: Vector3;
  6767. /**
  6768. * Gets the center of the bounding box in world space
  6769. */
  6770. readonly centerWorld: Vector3;
  6771. /**
  6772. * Gets the extend size in local space
  6773. */
  6774. readonly extendSize: Vector3;
  6775. /**
  6776. * Gets the extend size in world space
  6777. */
  6778. readonly extendSizeWorld: Vector3;
  6779. /**
  6780. * Gets the OBB (object bounding box) directions
  6781. */
  6782. readonly directions: Vector3[];
  6783. /**
  6784. * Gets the 8 vectors representing the bounding box in world space
  6785. */
  6786. readonly vectorsWorld: Vector3[];
  6787. /**
  6788. * Gets the minimum vector in world space
  6789. */
  6790. readonly minimumWorld: Vector3;
  6791. /**
  6792. * Gets the maximum vector in world space
  6793. */
  6794. readonly maximumWorld: Vector3;
  6795. /**
  6796. * Gets the minimum vector in local space
  6797. */
  6798. readonly minimum: Vector3;
  6799. /**
  6800. * Gets the maximum vector in local space
  6801. */
  6802. readonly maximum: Vector3;
  6803. private _worldMatrix;
  6804. private static readonly TmpVector3;
  6805. /**
  6806. * @hidden
  6807. */
  6808. _tag: number;
  6809. /**
  6810. * Creates a new bounding box
  6811. * @param min defines the minimum vector (in local space)
  6812. * @param max defines the maximum vector (in local space)
  6813. * @param worldMatrix defines the new world matrix
  6814. */
  6815. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6816. /**
  6817. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6818. * @param min defines the new minimum vector (in local space)
  6819. * @param max defines the new maximum vector (in local space)
  6820. * @param worldMatrix defines the new world matrix
  6821. */
  6822. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6823. /**
  6824. * Scale the current bounding box by applying a scale factor
  6825. * @param factor defines the scale factor to apply
  6826. * @returns the current bounding box
  6827. */
  6828. scale(factor: number): BoundingBox;
  6829. /**
  6830. * Gets the world matrix of the bounding box
  6831. * @returns a matrix
  6832. */
  6833. getWorldMatrix(): DeepImmutable<Matrix>;
  6834. /** @hidden */
  6835. _update(world: DeepImmutable<Matrix>): void;
  6836. /**
  6837. * Tests if the bounding box is intersecting the frustum planes
  6838. * @param frustumPlanes defines the frustum planes to test
  6839. * @returns true if there is an intersection
  6840. */
  6841. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6842. /**
  6843. * Tests if the bounding box is entirely inside the frustum planes
  6844. * @param frustumPlanes defines the frustum planes to test
  6845. * @returns true if there is an inclusion
  6846. */
  6847. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6848. /**
  6849. * Tests if a point is inside the bounding box
  6850. * @param point defines the point to test
  6851. * @returns true if the point is inside the bounding box
  6852. */
  6853. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6854. /**
  6855. * Tests if the bounding box intersects with a bounding sphere
  6856. * @param sphere defines the sphere to test
  6857. * @returns true if there is an intersection
  6858. */
  6859. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6860. /**
  6861. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6862. * @param min defines the min vector to use
  6863. * @param max defines the max vector to use
  6864. * @returns true if there is an intersection
  6865. */
  6866. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6867. /**
  6868. * Tests if two bounding boxes are intersections
  6869. * @param box0 defines the first box to test
  6870. * @param box1 defines the second box to test
  6871. * @returns true if there is an intersection
  6872. */
  6873. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6874. /**
  6875. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6876. * @param minPoint defines the minimum vector of the bounding box
  6877. * @param maxPoint defines the maximum vector of the bounding box
  6878. * @param sphereCenter defines the sphere center
  6879. * @param sphereRadius defines the sphere radius
  6880. * @returns true if there is an intersection
  6881. */
  6882. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6883. /**
  6884. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6885. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6886. * @param frustumPlanes defines the frustum planes to test
  6887. * @return true if there is an inclusion
  6888. */
  6889. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6890. /**
  6891. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6892. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @return true if there is an intersection
  6895. */
  6896. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. }
  6898. }
  6899. declare module BABYLON {
  6900. /** @hidden */
  6901. export class Collider {
  6902. /** Define if a collision was found */
  6903. collisionFound: boolean;
  6904. /**
  6905. * Define last intersection point in local space
  6906. */
  6907. intersectionPoint: Vector3;
  6908. /**
  6909. * Define last collided mesh
  6910. */
  6911. collidedMesh: Nullable<AbstractMesh>;
  6912. private _collisionPoint;
  6913. private _planeIntersectionPoint;
  6914. private _tempVector;
  6915. private _tempVector2;
  6916. private _tempVector3;
  6917. private _tempVector4;
  6918. private _edge;
  6919. private _baseToVertex;
  6920. private _destinationPoint;
  6921. private _slidePlaneNormal;
  6922. private _displacementVector;
  6923. /** @hidden */
  6924. _radius: Vector3;
  6925. /** @hidden */
  6926. _retry: number;
  6927. private _velocity;
  6928. private _basePoint;
  6929. private _epsilon;
  6930. /** @hidden */
  6931. _velocityWorldLength: number;
  6932. /** @hidden */
  6933. _basePointWorld: Vector3;
  6934. private _velocityWorld;
  6935. private _normalizedVelocity;
  6936. /** @hidden */
  6937. _initialVelocity: Vector3;
  6938. /** @hidden */
  6939. _initialPosition: Vector3;
  6940. private _nearestDistance;
  6941. private _collisionMask;
  6942. collisionMask: number;
  6943. /**
  6944. * Gets the plane normal used to compute the sliding response (in local space)
  6945. */
  6946. readonly slidePlaneNormal: Vector3;
  6947. /** @hidden */
  6948. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6949. /** @hidden */
  6950. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6951. /** @hidden */
  6952. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6953. /** @hidden */
  6954. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6955. /** @hidden */
  6956. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6957. /** @hidden */
  6958. _getResponse(pos: Vector3, vel: Vector3): void;
  6959. }
  6960. }
  6961. declare module BABYLON {
  6962. /**
  6963. * Interface for cullable objects
  6964. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6965. */
  6966. export interface ICullable {
  6967. /**
  6968. * Checks if the object or part of the object is in the frustum
  6969. * @param frustumPlanes Camera near/planes
  6970. * @returns true if the object is in frustum otherwise false
  6971. */
  6972. isInFrustum(frustumPlanes: Plane[]): boolean;
  6973. /**
  6974. * Checks if a cullable object (mesh...) is in the camera frustum
  6975. * Unlike isInFrustum this cheks the full bounding box
  6976. * @param frustumPlanes Camera near/planes
  6977. * @returns true if the object is in frustum otherwise false
  6978. */
  6979. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6980. }
  6981. /**
  6982. * Info for a bounding data of a mesh
  6983. */
  6984. export class BoundingInfo implements ICullable {
  6985. /**
  6986. * Bounding box for the mesh
  6987. */
  6988. readonly boundingBox: BoundingBox;
  6989. /**
  6990. * Bounding sphere for the mesh
  6991. */
  6992. readonly boundingSphere: BoundingSphere;
  6993. private _isLocked;
  6994. private static readonly TmpVector3;
  6995. /**
  6996. * Constructs bounding info
  6997. * @param minimum min vector of the bounding box/sphere
  6998. * @param maximum max vector of the bounding box/sphere
  6999. * @param worldMatrix defines the new world matrix
  7000. */
  7001. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7002. /**
  7003. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7004. * @param min defines the new minimum vector (in local space)
  7005. * @param max defines the new maximum vector (in local space)
  7006. * @param worldMatrix defines the new world matrix
  7007. */
  7008. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7009. /**
  7010. * min vector of the bounding box/sphere
  7011. */
  7012. readonly minimum: Vector3;
  7013. /**
  7014. * max vector of the bounding box/sphere
  7015. */
  7016. readonly maximum: Vector3;
  7017. /**
  7018. * If the info is locked and won't be updated to avoid perf overhead
  7019. */
  7020. isLocked: boolean;
  7021. /**
  7022. * Updates the bounding sphere and box
  7023. * @param world world matrix to be used to update
  7024. */
  7025. update(world: DeepImmutable<Matrix>): void;
  7026. /**
  7027. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7028. * @param center New center of the bounding info
  7029. * @param extend New extend of the bounding info
  7030. * @returns the current bounding info
  7031. */
  7032. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7033. /**
  7034. * Scale the current bounding info by applying a scale factor
  7035. * @param factor defines the scale factor to apply
  7036. * @returns the current bounding info
  7037. */
  7038. scale(factor: number): BoundingInfo;
  7039. /**
  7040. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7041. * @param frustumPlanes defines the frustum to test
  7042. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7043. * @returns true if the bounding info is in the frustum planes
  7044. */
  7045. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7046. /**
  7047. * Gets the world distance between the min and max points of the bounding box
  7048. */
  7049. readonly diagonalLength: number;
  7050. /**
  7051. * Checks if a cullable object (mesh...) is in the camera frustum
  7052. * Unlike isInFrustum this cheks the full bounding box
  7053. * @param frustumPlanes Camera near/planes
  7054. * @returns true if the object is in frustum otherwise false
  7055. */
  7056. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /** @hidden */
  7058. _checkCollision(collider: Collider): boolean;
  7059. /**
  7060. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7061. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7062. * @param point the point to check intersection with
  7063. * @returns if the point intersects
  7064. */
  7065. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7066. /**
  7067. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7068. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7069. * @param boundingInfo the bounding info to check intersection with
  7070. * @param precise if the intersection should be done using OBB
  7071. * @returns if the bounding info intersects
  7072. */
  7073. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7074. }
  7075. }
  7076. declare module BABYLON {
  7077. /**
  7078. * Extracts minimum and maximum values from a list of indexed positions
  7079. * @param positions defines the positions to use
  7080. * @param indices defines the indices to the positions
  7081. * @param indexStart defines the start index
  7082. * @param indexCount defines the end index
  7083. * @param bias defines bias value to add to the result
  7084. * @return minimum and maximum values
  7085. */
  7086. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7087. minimum: Vector3;
  7088. maximum: Vector3;
  7089. };
  7090. /**
  7091. * Extracts minimum and maximum values from a list of positions
  7092. * @param positions defines the positions to use
  7093. * @param start defines the start index in the positions array
  7094. * @param count defines the number of positions to handle
  7095. * @param bias defines bias value to add to the result
  7096. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7097. * @return minimum and maximum values
  7098. */
  7099. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7100. minimum: Vector3;
  7101. maximum: Vector3;
  7102. };
  7103. }
  7104. declare module BABYLON {
  7105. /** @hidden */
  7106. export class WebGLDataBuffer extends DataBuffer {
  7107. private _buffer;
  7108. constructor(resource: WebGLBuffer);
  7109. readonly underlyingResource: any;
  7110. }
  7111. }
  7112. declare module BABYLON {
  7113. /** @hidden */
  7114. export class WebGLPipelineContext implements IPipelineContext {
  7115. engine: ThinEngine;
  7116. program: Nullable<WebGLProgram>;
  7117. context?: WebGLRenderingContext;
  7118. vertexShader?: WebGLShader;
  7119. fragmentShader?: WebGLShader;
  7120. isParallelCompiled: boolean;
  7121. onCompiled?: () => void;
  7122. transformFeedback?: WebGLTransformFeedback | null;
  7123. vertexCompilationError: Nullable<string>;
  7124. fragmentCompilationError: Nullable<string>;
  7125. programLinkError: Nullable<string>;
  7126. programValidationError: Nullable<string>;
  7127. readonly isAsync: boolean;
  7128. readonly isReady: boolean;
  7129. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7130. }
  7131. }
  7132. declare module BABYLON {
  7133. interface ThinEngine {
  7134. /**
  7135. * Create an uniform buffer
  7136. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7137. * @param elements defines the content of the uniform buffer
  7138. * @returns the webGL uniform buffer
  7139. */
  7140. createUniformBuffer(elements: FloatArray): DataBuffer;
  7141. /**
  7142. * Create a dynamic uniform buffer
  7143. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7144. * @param elements defines the content of the uniform buffer
  7145. * @returns the webGL uniform buffer
  7146. */
  7147. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7148. /**
  7149. * Update an existing uniform buffer
  7150. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7151. * @param uniformBuffer defines the target uniform buffer
  7152. * @param elements defines the content to update
  7153. * @param offset defines the offset in the uniform buffer where update should start
  7154. * @param count defines the size of the data to update
  7155. */
  7156. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7157. /**
  7158. * Bind an uniform buffer to the current webGL context
  7159. * @param buffer defines the buffer to bind
  7160. */
  7161. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7162. /**
  7163. * Bind a buffer to the current webGL context at a given location
  7164. * @param buffer defines the buffer to bind
  7165. * @param location defines the index where to bind the buffer
  7166. */
  7167. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7168. /**
  7169. * Bind a specific block at a given index in a specific shader program
  7170. * @param pipelineContext defines the pipeline context to use
  7171. * @param blockName defines the block name
  7172. * @param index defines the index where to bind the block
  7173. */
  7174. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7175. }
  7176. }
  7177. declare module BABYLON {
  7178. /**
  7179. * Uniform buffer objects.
  7180. *
  7181. * Handles blocks of uniform on the GPU.
  7182. *
  7183. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7184. *
  7185. * For more information, please refer to :
  7186. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7187. */
  7188. export class UniformBuffer {
  7189. private _engine;
  7190. private _buffer;
  7191. private _data;
  7192. private _bufferData;
  7193. private _dynamic?;
  7194. private _uniformLocations;
  7195. private _uniformSizes;
  7196. private _uniformLocationPointer;
  7197. private _needSync;
  7198. private _noUBO;
  7199. private _currentEffect;
  7200. /** @hidden */
  7201. _alreadyBound: boolean;
  7202. private static _MAX_UNIFORM_SIZE;
  7203. private static _tempBuffer;
  7204. /**
  7205. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7206. * This is dynamic to allow compat with webgl 1 and 2.
  7207. * You will need to pass the name of the uniform as well as the value.
  7208. */
  7209. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7210. /**
  7211. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7212. * This is dynamic to allow compat with webgl 1 and 2.
  7213. * You will need to pass the name of the uniform as well as the value.
  7214. */
  7215. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7216. /**
  7217. * Lambda to Update a single float in a uniform buffer.
  7218. * This is dynamic to allow compat with webgl 1 and 2.
  7219. * You will need to pass the name of the uniform as well as the value.
  7220. */
  7221. updateFloat: (name: string, x: number) => void;
  7222. /**
  7223. * Lambda to Update a vec2 of float in a uniform buffer.
  7224. * This is dynamic to allow compat with webgl 1 and 2.
  7225. * You will need to pass the name of the uniform as well as the value.
  7226. */
  7227. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7228. /**
  7229. * Lambda to Update a vec3 of float in a uniform buffer.
  7230. * This is dynamic to allow compat with webgl 1 and 2.
  7231. * You will need to pass the name of the uniform as well as the value.
  7232. */
  7233. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7234. /**
  7235. * Lambda to Update a vec4 of float in a uniform buffer.
  7236. * This is dynamic to allow compat with webgl 1 and 2.
  7237. * You will need to pass the name of the uniform as well as the value.
  7238. */
  7239. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7240. /**
  7241. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7242. * This is dynamic to allow compat with webgl 1 and 2.
  7243. * You will need to pass the name of the uniform as well as the value.
  7244. */
  7245. updateMatrix: (name: string, mat: Matrix) => void;
  7246. /**
  7247. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7248. * This is dynamic to allow compat with webgl 1 and 2.
  7249. * You will need to pass the name of the uniform as well as the value.
  7250. */
  7251. updateVector3: (name: string, vector: Vector3) => void;
  7252. /**
  7253. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7254. * This is dynamic to allow compat with webgl 1 and 2.
  7255. * You will need to pass the name of the uniform as well as the value.
  7256. */
  7257. updateVector4: (name: string, vector: Vector4) => void;
  7258. /**
  7259. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7260. * This is dynamic to allow compat with webgl 1 and 2.
  7261. * You will need to pass the name of the uniform as well as the value.
  7262. */
  7263. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7264. /**
  7265. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7266. * This is dynamic to allow compat with webgl 1 and 2.
  7267. * You will need to pass the name of the uniform as well as the value.
  7268. */
  7269. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7270. /**
  7271. * Instantiates a new Uniform buffer objects.
  7272. *
  7273. * Handles blocks of uniform on the GPU.
  7274. *
  7275. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7276. *
  7277. * For more information, please refer to :
  7278. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7279. * @param engine Define the engine the buffer is associated with
  7280. * @param data Define the data contained in the buffer
  7281. * @param dynamic Define if the buffer is updatable
  7282. */
  7283. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7284. /**
  7285. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7286. * or just falling back on setUniformXXX calls.
  7287. */
  7288. readonly useUbo: boolean;
  7289. /**
  7290. * Indicates if the WebGL underlying uniform buffer is in sync
  7291. * with the javascript cache data.
  7292. */
  7293. readonly isSync: boolean;
  7294. /**
  7295. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7296. * Also, a dynamic UniformBuffer will disable cache verification and always
  7297. * update the underlying WebGL uniform buffer to the GPU.
  7298. * @returns if Dynamic, otherwise false
  7299. */
  7300. isDynamic(): boolean;
  7301. /**
  7302. * The data cache on JS side.
  7303. * @returns the underlying data as a float array
  7304. */
  7305. getData(): Float32Array;
  7306. /**
  7307. * The underlying WebGL Uniform buffer.
  7308. * @returns the webgl buffer
  7309. */
  7310. getBuffer(): Nullable<DataBuffer>;
  7311. /**
  7312. * std140 layout specifies how to align data within an UBO structure.
  7313. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7314. * for specs.
  7315. */
  7316. private _fillAlignment;
  7317. /**
  7318. * Adds an uniform in the buffer.
  7319. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7320. * for the layout to be correct !
  7321. * @param name Name of the uniform, as used in the uniform block in the shader.
  7322. * @param size Data size, or data directly.
  7323. */
  7324. addUniform(name: string, size: number | number[]): void;
  7325. /**
  7326. * Adds a Matrix 4x4 to the uniform buffer.
  7327. * @param name Name of the uniform, as used in the uniform block in the shader.
  7328. * @param mat A 4x4 matrix.
  7329. */
  7330. addMatrix(name: string, mat: Matrix): void;
  7331. /**
  7332. * Adds a vec2 to the uniform buffer.
  7333. * @param name Name of the uniform, as used in the uniform block in the shader.
  7334. * @param x Define the x component value of the vec2
  7335. * @param y Define the y component value of the vec2
  7336. */
  7337. addFloat2(name: string, x: number, y: number): void;
  7338. /**
  7339. * Adds a vec3 to the uniform buffer.
  7340. * @param name Name of the uniform, as used in the uniform block in the shader.
  7341. * @param x Define the x component value of the vec3
  7342. * @param y Define the y component value of the vec3
  7343. * @param z Define the z component value of the vec3
  7344. */
  7345. addFloat3(name: string, x: number, y: number, z: number): void;
  7346. /**
  7347. * Adds a vec3 to the uniform buffer.
  7348. * @param name Name of the uniform, as used in the uniform block in the shader.
  7349. * @param color Define the vec3 from a Color
  7350. */
  7351. addColor3(name: string, color: Color3): void;
  7352. /**
  7353. * Adds a vec4 to the uniform buffer.
  7354. * @param name Name of the uniform, as used in the uniform block in the shader.
  7355. * @param color Define the rgb components from a Color
  7356. * @param alpha Define the a component of the vec4
  7357. */
  7358. addColor4(name: string, color: Color3, alpha: number): void;
  7359. /**
  7360. * Adds a vec3 to the uniform buffer.
  7361. * @param name Name of the uniform, as used in the uniform block in the shader.
  7362. * @param vector Define the vec3 components from a Vector
  7363. */
  7364. addVector3(name: string, vector: Vector3): void;
  7365. /**
  7366. * Adds a Matrix 3x3 to the uniform buffer.
  7367. * @param name Name of the uniform, as used in the uniform block in the shader.
  7368. */
  7369. addMatrix3x3(name: string): void;
  7370. /**
  7371. * Adds a Matrix 2x2 to the uniform buffer.
  7372. * @param name Name of the uniform, as used in the uniform block in the shader.
  7373. */
  7374. addMatrix2x2(name: string): void;
  7375. /**
  7376. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7377. */
  7378. create(): void;
  7379. /** @hidden */
  7380. _rebuild(): void;
  7381. /**
  7382. * Updates the WebGL Uniform Buffer on the GPU.
  7383. * If the `dynamic` flag is set to true, no cache comparison is done.
  7384. * Otherwise, the buffer will be updated only if the cache differs.
  7385. */
  7386. update(): void;
  7387. /**
  7388. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7389. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7390. * @param data Define the flattened data
  7391. * @param size Define the size of the data.
  7392. */
  7393. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7394. private _valueCache;
  7395. private _cacheMatrix;
  7396. private _updateMatrix3x3ForUniform;
  7397. private _updateMatrix3x3ForEffect;
  7398. private _updateMatrix2x2ForEffect;
  7399. private _updateMatrix2x2ForUniform;
  7400. private _updateFloatForEffect;
  7401. private _updateFloatForUniform;
  7402. private _updateFloat2ForEffect;
  7403. private _updateFloat2ForUniform;
  7404. private _updateFloat3ForEffect;
  7405. private _updateFloat3ForUniform;
  7406. private _updateFloat4ForEffect;
  7407. private _updateFloat4ForUniform;
  7408. private _updateMatrixForEffect;
  7409. private _updateMatrixForUniform;
  7410. private _updateVector3ForEffect;
  7411. private _updateVector3ForUniform;
  7412. private _updateVector4ForEffect;
  7413. private _updateVector4ForUniform;
  7414. private _updateColor3ForEffect;
  7415. private _updateColor3ForUniform;
  7416. private _updateColor4ForEffect;
  7417. private _updateColor4ForUniform;
  7418. /**
  7419. * Sets a sampler uniform on the effect.
  7420. * @param name Define the name of the sampler.
  7421. * @param texture Define the texture to set in the sampler
  7422. */
  7423. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7424. /**
  7425. * Directly updates the value of the uniform in the cache AND on the GPU.
  7426. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7427. * @param data Define the flattened data
  7428. */
  7429. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7430. /**
  7431. * Binds this uniform buffer to an effect.
  7432. * @param effect Define the effect to bind the buffer to
  7433. * @param name Name of the uniform block in the shader.
  7434. */
  7435. bindToEffect(effect: Effect, name: string): void;
  7436. /**
  7437. * Disposes the uniform buffer.
  7438. */
  7439. dispose(): void;
  7440. }
  7441. }
  7442. declare module BABYLON {
  7443. /**
  7444. * Enum that determines the text-wrapping mode to use.
  7445. */
  7446. export enum InspectableType {
  7447. /**
  7448. * Checkbox for booleans
  7449. */
  7450. Checkbox = 0,
  7451. /**
  7452. * Sliders for numbers
  7453. */
  7454. Slider = 1,
  7455. /**
  7456. * Vector3
  7457. */
  7458. Vector3 = 2,
  7459. /**
  7460. * Quaternions
  7461. */
  7462. Quaternion = 3,
  7463. /**
  7464. * Color3
  7465. */
  7466. Color3 = 4,
  7467. /**
  7468. * String
  7469. */
  7470. String = 5
  7471. }
  7472. /**
  7473. * Interface used to define custom inspectable properties.
  7474. * This interface is used by the inspector to display custom property grids
  7475. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7476. */
  7477. export interface IInspectable {
  7478. /**
  7479. * Gets the label to display
  7480. */
  7481. label: string;
  7482. /**
  7483. * Gets the name of the property to edit
  7484. */
  7485. propertyName: string;
  7486. /**
  7487. * Gets the type of the editor to use
  7488. */
  7489. type: InspectableType;
  7490. /**
  7491. * Gets the minimum value of the property when using in "slider" mode
  7492. */
  7493. min?: number;
  7494. /**
  7495. * Gets the maximum value of the property when using in "slider" mode
  7496. */
  7497. max?: number;
  7498. /**
  7499. * Gets the setp to use when using in "slider" mode
  7500. */
  7501. step?: number;
  7502. }
  7503. }
  7504. declare module BABYLON {
  7505. /**
  7506. * Class used to provide helper for timing
  7507. */
  7508. export class TimingTools {
  7509. /**
  7510. * Polyfill for setImmediate
  7511. * @param action defines the action to execute after the current execution block
  7512. */
  7513. static SetImmediate(action: () => void): void;
  7514. }
  7515. }
  7516. declare module BABYLON {
  7517. /**
  7518. * Class used to enable instatition of objects by class name
  7519. */
  7520. export class InstantiationTools {
  7521. /**
  7522. * Use this object to register external classes like custom textures or material
  7523. * to allow the laoders to instantiate them
  7524. */
  7525. static RegisteredExternalClasses: {
  7526. [key: string]: Object;
  7527. };
  7528. /**
  7529. * Tries to instantiate a new object from a given class name
  7530. * @param className defines the class name to instantiate
  7531. * @returns the new object or null if the system was not able to do the instantiation
  7532. */
  7533. static Instantiate(className: string): any;
  7534. }
  7535. }
  7536. declare module BABYLON {
  7537. /**
  7538. * Define options used to create a depth texture
  7539. */
  7540. export class DepthTextureCreationOptions {
  7541. /** Specifies whether or not a stencil should be allocated in the texture */
  7542. generateStencil?: boolean;
  7543. /** Specifies whether or not bilinear filtering is enable on the texture */
  7544. bilinearFiltering?: boolean;
  7545. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7546. comparisonFunction?: number;
  7547. /** Specifies if the created texture is a cube texture */
  7548. isCube?: boolean;
  7549. }
  7550. }
  7551. declare module BABYLON {
  7552. interface ThinEngine {
  7553. /**
  7554. * Creates a depth stencil cube texture.
  7555. * This is only available in WebGL 2.
  7556. * @param size The size of face edge in the cube texture.
  7557. * @param options The options defining the cube texture.
  7558. * @returns The cube texture
  7559. */
  7560. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7561. /**
  7562. * Creates a cube texture
  7563. * @param rootUrl defines the url where the files to load is located
  7564. * @param scene defines the current scene
  7565. * @param files defines the list of files to load (1 per face)
  7566. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7567. * @param onLoad defines an optional callback raised when the texture is loaded
  7568. * @param onError defines an optional callback raised if there is an issue to load the texture
  7569. * @param format defines the format of the data
  7570. * @param forcedExtension defines the extension to use to pick the right loader
  7571. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7572. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7573. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7574. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7575. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7576. * @returns the cube texture as an InternalTexture
  7577. */
  7578. 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;
  7579. /**
  7580. * Creates a cube texture
  7581. * @param rootUrl defines the url where the files to load is located
  7582. * @param scene defines the current scene
  7583. * @param files defines the list of files to load (1 per face)
  7584. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7585. * @param onLoad defines an optional callback raised when the texture is loaded
  7586. * @param onError defines an optional callback raised if there is an issue to load the texture
  7587. * @param format defines the format of the data
  7588. * @param forcedExtension defines the extension to use to pick the right loader
  7589. * @returns the cube texture as an InternalTexture
  7590. */
  7591. 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;
  7592. /**
  7593. * Creates a cube texture
  7594. * @param rootUrl defines the url where the files to load is located
  7595. * @param scene defines the current scene
  7596. * @param files defines the list of files to load (1 per face)
  7597. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7598. * @param onLoad defines an optional callback raised when the texture is loaded
  7599. * @param onError defines an optional callback raised if there is an issue to load the texture
  7600. * @param format defines the format of the data
  7601. * @param forcedExtension defines the extension to use to pick the right loader
  7602. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7603. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7604. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7605. * @returns the cube texture as an InternalTexture
  7606. */
  7607. 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;
  7608. /** @hidden */
  7609. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7610. /** @hidden */
  7611. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7612. /** @hidden */
  7613. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7614. /** @hidden */
  7615. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7616. /**
  7617. * @hidden
  7618. */
  7619. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7620. }
  7621. }
  7622. declare module BABYLON {
  7623. /**
  7624. * Class for creating a cube texture
  7625. */
  7626. export class CubeTexture extends BaseTexture {
  7627. private _delayedOnLoad;
  7628. /**
  7629. * The url of the texture
  7630. */
  7631. url: string;
  7632. /**
  7633. * Gets or sets the center of the bounding box associated with the cube texture.
  7634. * It must define where the camera used to render the texture was set
  7635. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7636. */
  7637. boundingBoxPosition: Vector3;
  7638. private _boundingBoxSize;
  7639. /**
  7640. * Gets or sets the size of the bounding box associated with the cube texture
  7641. * When defined, the cubemap will switch to local mode
  7642. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7643. * @example https://www.babylonjs-playground.com/#RNASML
  7644. */
  7645. /**
  7646. * Returns the bounding box size
  7647. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7648. */
  7649. boundingBoxSize: Vector3;
  7650. protected _rotationY: number;
  7651. /**
  7652. * Sets texture matrix rotation angle around Y axis in radians.
  7653. */
  7654. /**
  7655. * Gets texture matrix rotation angle around Y axis radians.
  7656. */
  7657. rotationY: number;
  7658. /**
  7659. * Are mip maps generated for this texture or not.
  7660. */
  7661. readonly noMipmap: boolean;
  7662. private _noMipmap;
  7663. private _files;
  7664. protected _forcedExtension: Nullable<string>;
  7665. private _extensions;
  7666. private _textureMatrix;
  7667. private _format;
  7668. private _createPolynomials;
  7669. /** @hidden */
  7670. _prefiltered: boolean;
  7671. /**
  7672. * Creates a cube texture from an array of image urls
  7673. * @param files defines an array of image urls
  7674. * @param scene defines the hosting scene
  7675. * @param noMipmap specifies if mip maps are not used
  7676. * @returns a cube texture
  7677. */
  7678. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7679. /**
  7680. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7681. * @param url defines the url of the prefiltered texture
  7682. * @param scene defines the scene the texture is attached to
  7683. * @param forcedExtension defines the extension of the file if different from the url
  7684. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7685. * @return the prefiltered texture
  7686. */
  7687. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7688. /**
  7689. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7690. * as prefiltered data.
  7691. * @param rootUrl defines the url of the texture or the root name of the six images
  7692. * @param scene defines the scene the texture is attached to
  7693. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7694. * @param noMipmap defines if mipmaps should be created or not
  7695. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7696. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7697. * @param onError defines a callback triggered in case of error during load
  7698. * @param format defines the internal format to use for the texture once loaded
  7699. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7700. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7701. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7702. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7703. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7704. * @return the cube texture
  7705. */
  7706. 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);
  7707. /**
  7708. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7709. */
  7710. readonly isPrefiltered: boolean;
  7711. /**
  7712. * Get the current class name of the texture useful for serialization or dynamic coding.
  7713. * @returns "CubeTexture"
  7714. */
  7715. getClassName(): string;
  7716. /**
  7717. * Update the url (and optional buffer) of this texture if url was null during construction.
  7718. * @param url the url of the texture
  7719. * @param forcedExtension defines the extension to use
  7720. * @param onLoad callback called when the texture is loaded (defaults to null)
  7721. */
  7722. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7723. /**
  7724. * Delays loading of the cube texture
  7725. * @param forcedExtension defines the extension to use
  7726. */
  7727. delayLoad(forcedExtension?: string): void;
  7728. /**
  7729. * Returns the reflection texture matrix
  7730. * @returns the reflection texture matrix
  7731. */
  7732. getReflectionTextureMatrix(): Matrix;
  7733. /**
  7734. * Sets the reflection texture matrix
  7735. * @param value Reflection texture matrix
  7736. */
  7737. setReflectionTextureMatrix(value: Matrix): void;
  7738. /**
  7739. * Parses text to create a cube texture
  7740. * @param parsedTexture define the serialized text to read from
  7741. * @param scene defines the hosting scene
  7742. * @param rootUrl defines the root url of the cube texture
  7743. * @returns a cube texture
  7744. */
  7745. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7746. /**
  7747. * Makes a clone, or deep copy, of the cube texture
  7748. * @returns a new cube texture
  7749. */
  7750. clone(): CubeTexture;
  7751. }
  7752. }
  7753. declare module BABYLON {
  7754. /**
  7755. * Manages the defines for the Material
  7756. */
  7757. export class MaterialDefines {
  7758. /** @hidden */
  7759. protected _keys: string[];
  7760. private _isDirty;
  7761. /** @hidden */
  7762. _renderId: number;
  7763. /** @hidden */
  7764. _areLightsDirty: boolean;
  7765. /** @hidden */
  7766. _areLightsDisposed: boolean;
  7767. /** @hidden */
  7768. _areAttributesDirty: boolean;
  7769. /** @hidden */
  7770. _areTexturesDirty: boolean;
  7771. /** @hidden */
  7772. _areFresnelDirty: boolean;
  7773. /** @hidden */
  7774. _areMiscDirty: boolean;
  7775. /** @hidden */
  7776. _areImageProcessingDirty: boolean;
  7777. /** @hidden */
  7778. _normals: boolean;
  7779. /** @hidden */
  7780. _uvs: boolean;
  7781. /** @hidden */
  7782. _needNormals: boolean;
  7783. /** @hidden */
  7784. _needUVs: boolean;
  7785. [id: string]: any;
  7786. /**
  7787. * Specifies if the material needs to be re-calculated
  7788. */
  7789. readonly isDirty: boolean;
  7790. /**
  7791. * Marks the material to indicate that it has been re-calculated
  7792. */
  7793. markAsProcessed(): void;
  7794. /**
  7795. * Marks the material to indicate that it needs to be re-calculated
  7796. */
  7797. markAsUnprocessed(): void;
  7798. /**
  7799. * Marks the material to indicate all of its defines need to be re-calculated
  7800. */
  7801. markAllAsDirty(): void;
  7802. /**
  7803. * Marks the material to indicate that image processing needs to be re-calculated
  7804. */
  7805. markAsImageProcessingDirty(): void;
  7806. /**
  7807. * Marks the material to indicate the lights need to be re-calculated
  7808. * @param disposed Defines whether the light is dirty due to dispose or not
  7809. */
  7810. markAsLightDirty(disposed?: boolean): void;
  7811. /**
  7812. * Marks the attribute state as changed
  7813. */
  7814. markAsAttributesDirty(): void;
  7815. /**
  7816. * Marks the texture state as changed
  7817. */
  7818. markAsTexturesDirty(): void;
  7819. /**
  7820. * Marks the fresnel state as changed
  7821. */
  7822. markAsFresnelDirty(): void;
  7823. /**
  7824. * Marks the misc state as changed
  7825. */
  7826. markAsMiscDirty(): void;
  7827. /**
  7828. * Rebuilds the material defines
  7829. */
  7830. rebuild(): void;
  7831. /**
  7832. * Specifies if two material defines are equal
  7833. * @param other - A material define instance to compare to
  7834. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7835. */
  7836. isEqual(other: MaterialDefines): boolean;
  7837. /**
  7838. * Clones this instance's defines to another instance
  7839. * @param other - material defines to clone values to
  7840. */
  7841. cloneTo(other: MaterialDefines): void;
  7842. /**
  7843. * Resets the material define values
  7844. */
  7845. reset(): void;
  7846. /**
  7847. * Converts the material define values to a string
  7848. * @returns - String of material define information
  7849. */
  7850. toString(): string;
  7851. }
  7852. }
  7853. declare module BABYLON {
  7854. /**
  7855. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7856. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7857. * 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;
  7858. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7859. */
  7860. export class ColorCurves {
  7861. private _dirty;
  7862. private _tempColor;
  7863. private _globalCurve;
  7864. private _highlightsCurve;
  7865. private _midtonesCurve;
  7866. private _shadowsCurve;
  7867. private _positiveCurve;
  7868. private _negativeCurve;
  7869. private _globalHue;
  7870. private _globalDensity;
  7871. private _globalSaturation;
  7872. private _globalExposure;
  7873. /**
  7874. * Gets the global Hue value.
  7875. * 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).
  7876. */
  7877. /**
  7878. * Sets the global Hue value.
  7879. * 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).
  7880. */
  7881. globalHue: number;
  7882. /**
  7883. * Gets the global Density value.
  7884. * 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.
  7885. * Values less than zero provide a filter of opposite hue.
  7886. */
  7887. /**
  7888. * Sets the global Density value.
  7889. * 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.
  7890. * Values less than zero provide a filter of opposite hue.
  7891. */
  7892. globalDensity: number;
  7893. /**
  7894. * Gets the global Saturation value.
  7895. * 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.
  7896. */
  7897. /**
  7898. * Sets the global Saturation value.
  7899. * 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.
  7900. */
  7901. globalSaturation: number;
  7902. /**
  7903. * Gets the global Exposure value.
  7904. * 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.
  7905. */
  7906. /**
  7907. * Sets the global Exposure value.
  7908. * 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.
  7909. */
  7910. globalExposure: number;
  7911. private _highlightsHue;
  7912. private _highlightsDensity;
  7913. private _highlightsSaturation;
  7914. private _highlightsExposure;
  7915. /**
  7916. * Gets the highlights Hue value.
  7917. * 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).
  7918. */
  7919. /**
  7920. * Sets the highlights Hue value.
  7921. * 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).
  7922. */
  7923. highlightsHue: number;
  7924. /**
  7925. * Gets the highlights Density value.
  7926. * 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.
  7927. * Values less than zero provide a filter of opposite hue.
  7928. */
  7929. /**
  7930. * Sets the highlights Density value.
  7931. * 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.
  7932. * Values less than zero provide a filter of opposite hue.
  7933. */
  7934. highlightsDensity: number;
  7935. /**
  7936. * Gets the highlights Saturation value.
  7937. * 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.
  7938. */
  7939. /**
  7940. * Sets the highlights Saturation value.
  7941. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7942. */
  7943. highlightsSaturation: number;
  7944. /**
  7945. * Gets the highlights Exposure value.
  7946. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7947. */
  7948. /**
  7949. * Sets the highlights Exposure value.
  7950. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7951. */
  7952. highlightsExposure: number;
  7953. private _midtonesHue;
  7954. private _midtonesDensity;
  7955. private _midtonesSaturation;
  7956. private _midtonesExposure;
  7957. /**
  7958. * Gets the midtones Hue value.
  7959. * 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).
  7960. */
  7961. /**
  7962. * Sets the midtones Hue value.
  7963. * 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).
  7964. */
  7965. midtonesHue: number;
  7966. /**
  7967. * Gets the midtones Density value.
  7968. * 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.
  7969. * Values less than zero provide a filter of opposite hue.
  7970. */
  7971. /**
  7972. * Sets the midtones Density value.
  7973. * 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.
  7974. * Values less than zero provide a filter of opposite hue.
  7975. */
  7976. midtonesDensity: number;
  7977. /**
  7978. * Gets the midtones Saturation value.
  7979. * 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.
  7980. */
  7981. /**
  7982. * Sets the midtones Saturation value.
  7983. * 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.
  7984. */
  7985. midtonesSaturation: number;
  7986. /**
  7987. * Gets the midtones Exposure value.
  7988. * 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.
  7989. */
  7990. /**
  7991. * Sets the midtones Exposure value.
  7992. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7993. */
  7994. midtonesExposure: number;
  7995. private _shadowsHue;
  7996. private _shadowsDensity;
  7997. private _shadowsSaturation;
  7998. private _shadowsExposure;
  7999. /**
  8000. * Gets the shadows Hue value.
  8001. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8002. */
  8003. /**
  8004. * Sets the shadows Hue value.
  8005. * 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).
  8006. */
  8007. shadowsHue: number;
  8008. /**
  8009. * Gets the shadows Density value.
  8010. * 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.
  8011. * Values less than zero provide a filter of opposite hue.
  8012. */
  8013. /**
  8014. * Sets the shadows Density value.
  8015. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8016. * Values less than zero provide a filter of opposite hue.
  8017. */
  8018. shadowsDensity: number;
  8019. /**
  8020. * Gets the shadows Saturation value.
  8021. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8022. */
  8023. /**
  8024. * Sets the shadows Saturation value.
  8025. * 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.
  8026. */
  8027. shadowsSaturation: number;
  8028. /**
  8029. * Gets the shadows Exposure value.
  8030. * 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.
  8031. */
  8032. /**
  8033. * Sets the shadows Exposure value.
  8034. * 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.
  8035. */
  8036. shadowsExposure: number;
  8037. /**
  8038. * Returns the class name
  8039. * @returns The class name
  8040. */
  8041. getClassName(): string;
  8042. /**
  8043. * Binds the color curves to the shader.
  8044. * @param colorCurves The color curve to bind
  8045. * @param effect The effect to bind to
  8046. * @param positiveUniform The positive uniform shader parameter
  8047. * @param neutralUniform The neutral uniform shader parameter
  8048. * @param negativeUniform The negative uniform shader parameter
  8049. */
  8050. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8051. /**
  8052. * Prepare the list of uniforms associated with the ColorCurves effects.
  8053. * @param uniformsList The list of uniforms used in the effect
  8054. */
  8055. static PrepareUniforms(uniformsList: string[]): void;
  8056. /**
  8057. * Returns color grading data based on a hue, density, saturation and exposure value.
  8058. * @param filterHue The hue of the color filter.
  8059. * @param filterDensity The density of the color filter.
  8060. * @param saturation The saturation.
  8061. * @param exposure The exposure.
  8062. * @param result The result data container.
  8063. */
  8064. private getColorGradingDataToRef;
  8065. /**
  8066. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8067. * @param value The input slider value in range [-100,100].
  8068. * @returns Adjusted value.
  8069. */
  8070. private static applyColorGradingSliderNonlinear;
  8071. /**
  8072. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8073. * @param hue The hue (H) input.
  8074. * @param saturation The saturation (S) input.
  8075. * @param brightness The brightness (B) input.
  8076. * @result An RGBA color represented as Vector4.
  8077. */
  8078. private static fromHSBToRef;
  8079. /**
  8080. * Returns a value clamped between min and max
  8081. * @param value The value to clamp
  8082. * @param min The minimum of value
  8083. * @param max The maximum of value
  8084. * @returns The clamped value.
  8085. */
  8086. private static clamp;
  8087. /**
  8088. * Clones the current color curve instance.
  8089. * @return The cloned curves
  8090. */
  8091. clone(): ColorCurves;
  8092. /**
  8093. * Serializes the current color curve instance to a json representation.
  8094. * @return a JSON representation
  8095. */
  8096. serialize(): any;
  8097. /**
  8098. * Parses the color curve from a json representation.
  8099. * @param source the JSON source to parse
  8100. * @return The parsed curves
  8101. */
  8102. static Parse(source: any): ColorCurves;
  8103. }
  8104. }
  8105. declare module BABYLON {
  8106. /**
  8107. * Interface to follow in your material defines to integrate easily the
  8108. * Image proccessing functions.
  8109. * @hidden
  8110. */
  8111. export interface IImageProcessingConfigurationDefines {
  8112. IMAGEPROCESSING: boolean;
  8113. VIGNETTE: boolean;
  8114. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8115. VIGNETTEBLENDMODEOPAQUE: boolean;
  8116. TONEMAPPING: boolean;
  8117. TONEMAPPING_ACES: boolean;
  8118. CONTRAST: boolean;
  8119. EXPOSURE: boolean;
  8120. COLORCURVES: boolean;
  8121. COLORGRADING: boolean;
  8122. COLORGRADING3D: boolean;
  8123. SAMPLER3DGREENDEPTH: boolean;
  8124. SAMPLER3DBGRMAP: boolean;
  8125. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8126. }
  8127. /**
  8128. * @hidden
  8129. */
  8130. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8131. IMAGEPROCESSING: boolean;
  8132. VIGNETTE: boolean;
  8133. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8134. VIGNETTEBLENDMODEOPAQUE: boolean;
  8135. TONEMAPPING: boolean;
  8136. TONEMAPPING_ACES: boolean;
  8137. CONTRAST: boolean;
  8138. COLORCURVES: boolean;
  8139. COLORGRADING: boolean;
  8140. COLORGRADING3D: boolean;
  8141. SAMPLER3DGREENDEPTH: boolean;
  8142. SAMPLER3DBGRMAP: boolean;
  8143. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8144. EXPOSURE: boolean;
  8145. constructor();
  8146. }
  8147. /**
  8148. * This groups together the common properties used for image processing either in direct forward pass
  8149. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8150. * or not.
  8151. */
  8152. export class ImageProcessingConfiguration {
  8153. /**
  8154. * Default tone mapping applied in BabylonJS.
  8155. */
  8156. static readonly TONEMAPPING_STANDARD: number;
  8157. /**
  8158. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8159. * to other engines rendering to increase portability.
  8160. */
  8161. static readonly TONEMAPPING_ACES: number;
  8162. /**
  8163. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8164. */
  8165. colorCurves: Nullable<ColorCurves>;
  8166. private _colorCurvesEnabled;
  8167. /**
  8168. * Gets wether the color curves effect is enabled.
  8169. */
  8170. /**
  8171. * Sets wether the color curves effect is enabled.
  8172. */
  8173. colorCurvesEnabled: boolean;
  8174. private _colorGradingTexture;
  8175. /**
  8176. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8177. */
  8178. /**
  8179. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8180. */
  8181. colorGradingTexture: Nullable<BaseTexture>;
  8182. private _colorGradingEnabled;
  8183. /**
  8184. * Gets wether the color grading effect is enabled.
  8185. */
  8186. /**
  8187. * Sets wether the color grading effect is enabled.
  8188. */
  8189. colorGradingEnabled: boolean;
  8190. private _colorGradingWithGreenDepth;
  8191. /**
  8192. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8193. */
  8194. /**
  8195. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8196. */
  8197. colorGradingWithGreenDepth: boolean;
  8198. private _colorGradingBGR;
  8199. /**
  8200. * Gets wether the color grading texture contains BGR values.
  8201. */
  8202. /**
  8203. * Sets wether the color grading texture contains BGR values.
  8204. */
  8205. colorGradingBGR: boolean;
  8206. /** @hidden */
  8207. _exposure: number;
  8208. /**
  8209. * Gets the Exposure used in the effect.
  8210. */
  8211. /**
  8212. * Sets the Exposure used in the effect.
  8213. */
  8214. exposure: number;
  8215. private _toneMappingEnabled;
  8216. /**
  8217. * Gets wether the tone mapping effect is enabled.
  8218. */
  8219. /**
  8220. * Sets wether the tone mapping effect is enabled.
  8221. */
  8222. toneMappingEnabled: boolean;
  8223. private _toneMappingType;
  8224. /**
  8225. * Gets the type of tone mapping effect.
  8226. */
  8227. /**
  8228. * Sets the type of tone mapping effect used in BabylonJS.
  8229. */
  8230. toneMappingType: number;
  8231. protected _contrast: number;
  8232. /**
  8233. * Gets the contrast used in the effect.
  8234. */
  8235. /**
  8236. * Sets the contrast used in the effect.
  8237. */
  8238. contrast: number;
  8239. /**
  8240. * Vignette stretch size.
  8241. */
  8242. vignetteStretch: number;
  8243. /**
  8244. * Vignette centre X Offset.
  8245. */
  8246. vignetteCentreX: number;
  8247. /**
  8248. * Vignette centre Y Offset.
  8249. */
  8250. vignetteCentreY: number;
  8251. /**
  8252. * Vignette weight or intensity of the vignette effect.
  8253. */
  8254. vignetteWeight: number;
  8255. /**
  8256. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8257. * if vignetteEnabled is set to true.
  8258. */
  8259. vignetteColor: Color4;
  8260. /**
  8261. * Camera field of view used by the Vignette effect.
  8262. */
  8263. vignetteCameraFov: number;
  8264. private _vignetteBlendMode;
  8265. /**
  8266. * Gets the vignette blend mode allowing different kind of effect.
  8267. */
  8268. /**
  8269. * Sets the vignette blend mode allowing different kind of effect.
  8270. */
  8271. vignetteBlendMode: number;
  8272. private _vignetteEnabled;
  8273. /**
  8274. * Gets wether the vignette effect is enabled.
  8275. */
  8276. /**
  8277. * Sets wether the vignette effect is enabled.
  8278. */
  8279. vignetteEnabled: boolean;
  8280. private _applyByPostProcess;
  8281. /**
  8282. * Gets wether the image processing is applied through a post process or not.
  8283. */
  8284. /**
  8285. * Sets wether the image processing is applied through a post process or not.
  8286. */
  8287. applyByPostProcess: boolean;
  8288. private _isEnabled;
  8289. /**
  8290. * Gets wether the image processing is enabled or not.
  8291. */
  8292. /**
  8293. * Sets wether the image processing is enabled or not.
  8294. */
  8295. isEnabled: boolean;
  8296. /**
  8297. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8298. */
  8299. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8300. /**
  8301. * Method called each time the image processing information changes requires to recompile the effect.
  8302. */
  8303. protected _updateParameters(): void;
  8304. /**
  8305. * Gets the current class name.
  8306. * @return "ImageProcessingConfiguration"
  8307. */
  8308. getClassName(): string;
  8309. /**
  8310. * Prepare the list of uniforms associated with the Image Processing effects.
  8311. * @param uniforms The list of uniforms used in the effect
  8312. * @param defines the list of defines currently in use
  8313. */
  8314. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8315. /**
  8316. * Prepare the list of samplers associated with the Image Processing effects.
  8317. * @param samplersList The list of uniforms used in the effect
  8318. * @param defines the list of defines currently in use
  8319. */
  8320. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8321. /**
  8322. * Prepare the list of defines associated to the shader.
  8323. * @param defines the list of defines to complete
  8324. * @param forPostProcess Define if we are currently in post process mode or not
  8325. */
  8326. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8327. /**
  8328. * Returns true if all the image processing information are ready.
  8329. * @returns True if ready, otherwise, false
  8330. */
  8331. isReady(): boolean;
  8332. /**
  8333. * Binds the image processing to the shader.
  8334. * @param effect The effect to bind to
  8335. * @param overrideAspectRatio Override the aspect ratio of the effect
  8336. */
  8337. bind(effect: Effect, overrideAspectRatio?: number): void;
  8338. /**
  8339. * Clones the current image processing instance.
  8340. * @return The cloned image processing
  8341. */
  8342. clone(): ImageProcessingConfiguration;
  8343. /**
  8344. * Serializes the current image processing instance to a json representation.
  8345. * @return a JSON representation
  8346. */
  8347. serialize(): any;
  8348. /**
  8349. * Parses the image processing from a json representation.
  8350. * @param source the JSON source to parse
  8351. * @return The parsed image processing
  8352. */
  8353. static Parse(source: any): ImageProcessingConfiguration;
  8354. private static _VIGNETTEMODE_MULTIPLY;
  8355. private static _VIGNETTEMODE_OPAQUE;
  8356. /**
  8357. * Used to apply the vignette as a mix with the pixel color.
  8358. */
  8359. static readonly VIGNETTEMODE_MULTIPLY: number;
  8360. /**
  8361. * Used to apply the vignette as a replacement of the pixel color.
  8362. */
  8363. static readonly VIGNETTEMODE_OPAQUE: number;
  8364. }
  8365. }
  8366. declare module BABYLON {
  8367. /** @hidden */
  8368. export var postprocessVertexShader: {
  8369. name: string;
  8370. shader: string;
  8371. };
  8372. }
  8373. declare module BABYLON {
  8374. interface ThinEngine {
  8375. /**
  8376. * Creates a new render target texture
  8377. * @param size defines the size of the texture
  8378. * @param options defines the options used to create the texture
  8379. * @returns a new render target texture stored in an InternalTexture
  8380. */
  8381. createRenderTargetTexture(size: number | {
  8382. width: number;
  8383. height: number;
  8384. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8385. /**
  8386. * Creates a depth stencil texture.
  8387. * This is only available in WebGL 2 or with the depth texture extension available.
  8388. * @param size The size of face edge in the texture.
  8389. * @param options The options defining the texture.
  8390. * @returns The texture
  8391. */
  8392. createDepthStencilTexture(size: number | {
  8393. width: number;
  8394. height: number;
  8395. }, options: DepthTextureCreationOptions): InternalTexture;
  8396. /** @hidden */
  8397. _createDepthStencilTexture(size: number | {
  8398. width: number;
  8399. height: number;
  8400. }, options: DepthTextureCreationOptions): InternalTexture;
  8401. }
  8402. }
  8403. declare module BABYLON {
  8404. /** Defines supported spaces */
  8405. export enum Space {
  8406. /** Local (object) space */
  8407. LOCAL = 0,
  8408. /** World space */
  8409. WORLD = 1,
  8410. /** Bone space */
  8411. BONE = 2
  8412. }
  8413. /** Defines the 3 main axes */
  8414. export class Axis {
  8415. /** X axis */
  8416. static X: Vector3;
  8417. /** Y axis */
  8418. static Y: Vector3;
  8419. /** Z axis */
  8420. static Z: Vector3;
  8421. }
  8422. }
  8423. declare module BABYLON {
  8424. /**
  8425. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8426. * This is the base of the follow, arc rotate cameras and Free camera
  8427. * @see http://doc.babylonjs.com/features/cameras
  8428. */
  8429. export class TargetCamera extends Camera {
  8430. private static _RigCamTransformMatrix;
  8431. private static _TargetTransformMatrix;
  8432. private static _TargetFocalPoint;
  8433. /**
  8434. * Define the current direction the camera is moving to
  8435. */
  8436. cameraDirection: Vector3;
  8437. /**
  8438. * Define the current rotation the camera is rotating to
  8439. */
  8440. cameraRotation: Vector2;
  8441. /**
  8442. * When set, the up vector of the camera will be updated by the rotation of the camera
  8443. */
  8444. updateUpVectorFromRotation: boolean;
  8445. private _tmpQuaternion;
  8446. /**
  8447. * Define the current rotation of the camera
  8448. */
  8449. rotation: Vector3;
  8450. /**
  8451. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8452. */
  8453. rotationQuaternion: Quaternion;
  8454. /**
  8455. * Define the current speed of the camera
  8456. */
  8457. speed: number;
  8458. /**
  8459. * Add constraint to the camera to prevent it to move freely in all directions and
  8460. * around all axis.
  8461. */
  8462. noRotationConstraint: boolean;
  8463. /**
  8464. * Define the current target of the camera as an object or a position.
  8465. */
  8466. lockedTarget: any;
  8467. /** @hidden */
  8468. _currentTarget: Vector3;
  8469. /** @hidden */
  8470. _initialFocalDistance: number;
  8471. /** @hidden */
  8472. _viewMatrix: Matrix;
  8473. /** @hidden */
  8474. _camMatrix: Matrix;
  8475. /** @hidden */
  8476. _cameraTransformMatrix: Matrix;
  8477. /** @hidden */
  8478. _cameraRotationMatrix: Matrix;
  8479. /** @hidden */
  8480. _referencePoint: Vector3;
  8481. /** @hidden */
  8482. _transformedReferencePoint: Vector3;
  8483. protected _globalCurrentTarget: Vector3;
  8484. protected _globalCurrentUpVector: Vector3;
  8485. /** @hidden */
  8486. _reset: () => void;
  8487. private _defaultUp;
  8488. /**
  8489. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8490. * This is the base of the follow, arc rotate cameras and Free camera
  8491. * @see http://doc.babylonjs.com/features/cameras
  8492. * @param name Defines the name of the camera in the scene
  8493. * @param position Defines the start position of the camera in the scene
  8494. * @param scene Defines the scene the camera belongs to
  8495. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8496. */
  8497. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8498. /**
  8499. * Gets the position in front of the camera at a given distance.
  8500. * @param distance The distance from the camera we want the position to be
  8501. * @returns the position
  8502. */
  8503. getFrontPosition(distance: number): Vector3;
  8504. /** @hidden */
  8505. _getLockedTargetPosition(): Nullable<Vector3>;
  8506. private _storedPosition;
  8507. private _storedRotation;
  8508. private _storedRotationQuaternion;
  8509. /**
  8510. * Store current camera state of the camera (fov, position, rotation, etc..)
  8511. * @returns the camera
  8512. */
  8513. storeState(): Camera;
  8514. /**
  8515. * Restored camera state. You must call storeState() first
  8516. * @returns whether it was successful or not
  8517. * @hidden
  8518. */
  8519. _restoreStateValues(): boolean;
  8520. /** @hidden */
  8521. _initCache(): void;
  8522. /** @hidden */
  8523. _updateCache(ignoreParentClass?: boolean): void;
  8524. /** @hidden */
  8525. _isSynchronizedViewMatrix(): boolean;
  8526. /** @hidden */
  8527. _computeLocalCameraSpeed(): number;
  8528. /**
  8529. * Defines the target the camera should look at.
  8530. * @param target Defines the new target as a Vector or a mesh
  8531. */
  8532. setTarget(target: Vector3): void;
  8533. /**
  8534. * Return the current target position of the camera. This value is expressed in local space.
  8535. * @returns the target position
  8536. */
  8537. getTarget(): Vector3;
  8538. /** @hidden */
  8539. _decideIfNeedsToMove(): boolean;
  8540. /** @hidden */
  8541. _updatePosition(): void;
  8542. /** @hidden */
  8543. _checkInputs(): void;
  8544. protected _updateCameraRotationMatrix(): void;
  8545. /**
  8546. * 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)
  8547. * @returns the current camera
  8548. */
  8549. private _rotateUpVectorWithCameraRotationMatrix;
  8550. private _cachedRotationZ;
  8551. private _cachedQuaternionRotationZ;
  8552. /** @hidden */
  8553. _getViewMatrix(): Matrix;
  8554. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8555. /**
  8556. * @hidden
  8557. */
  8558. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8559. /**
  8560. * @hidden
  8561. */
  8562. _updateRigCameras(): void;
  8563. private _getRigCamPositionAndTarget;
  8564. /**
  8565. * Gets the current object class name.
  8566. * @return the class name
  8567. */
  8568. getClassName(): string;
  8569. }
  8570. }
  8571. declare module BABYLON {
  8572. /**
  8573. * Gather the list of keyboard event types as constants.
  8574. */
  8575. export class KeyboardEventTypes {
  8576. /**
  8577. * The keydown event is fired when a key becomes active (pressed).
  8578. */
  8579. static readonly KEYDOWN: number;
  8580. /**
  8581. * The keyup event is fired when a key has been released.
  8582. */
  8583. static readonly KEYUP: number;
  8584. }
  8585. /**
  8586. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8587. */
  8588. export class KeyboardInfo {
  8589. /**
  8590. * Defines the type of event (KeyboardEventTypes)
  8591. */
  8592. type: number;
  8593. /**
  8594. * Defines the related dom event
  8595. */
  8596. event: KeyboardEvent;
  8597. /**
  8598. * Instantiates a new keyboard info.
  8599. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8600. * @param type Defines the type of event (KeyboardEventTypes)
  8601. * @param event Defines the related dom event
  8602. */
  8603. constructor(
  8604. /**
  8605. * Defines the type of event (KeyboardEventTypes)
  8606. */
  8607. type: number,
  8608. /**
  8609. * Defines the related dom event
  8610. */
  8611. event: KeyboardEvent);
  8612. }
  8613. /**
  8614. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8615. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8616. */
  8617. export class KeyboardInfoPre extends KeyboardInfo {
  8618. /**
  8619. * Defines the type of event (KeyboardEventTypes)
  8620. */
  8621. type: number;
  8622. /**
  8623. * Defines the related dom event
  8624. */
  8625. event: KeyboardEvent;
  8626. /**
  8627. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8628. */
  8629. skipOnPointerObservable: boolean;
  8630. /**
  8631. * Instantiates a new keyboard pre info.
  8632. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8633. * @param type Defines the type of event (KeyboardEventTypes)
  8634. * @param event Defines the related dom event
  8635. */
  8636. constructor(
  8637. /**
  8638. * Defines the type of event (KeyboardEventTypes)
  8639. */
  8640. type: number,
  8641. /**
  8642. * Defines the related dom event
  8643. */
  8644. event: KeyboardEvent);
  8645. }
  8646. }
  8647. declare module BABYLON {
  8648. /**
  8649. * Manage the keyboard inputs to control the movement of a free camera.
  8650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8651. */
  8652. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8653. /**
  8654. * Defines the camera the input is attached to.
  8655. */
  8656. camera: FreeCamera;
  8657. /**
  8658. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8659. */
  8660. keysUp: number[];
  8661. /**
  8662. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8663. */
  8664. keysDown: number[];
  8665. /**
  8666. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8667. */
  8668. keysLeft: number[];
  8669. /**
  8670. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8671. */
  8672. keysRight: number[];
  8673. private _keys;
  8674. private _onCanvasBlurObserver;
  8675. private _onKeyboardObserver;
  8676. private _engine;
  8677. private _scene;
  8678. /**
  8679. * Attach the input controls to a specific dom element to get the input from.
  8680. * @param element Defines the element the controls should be listened from
  8681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8682. */
  8683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8684. /**
  8685. * Detach the current controls from the specified dom element.
  8686. * @param element Defines the element to stop listening the inputs from
  8687. */
  8688. detachControl(element: Nullable<HTMLElement>): void;
  8689. /**
  8690. * Update the current camera state depending on the inputs that have been used this frame.
  8691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8692. */
  8693. checkInputs(): void;
  8694. /**
  8695. * Gets the class name of the current intput.
  8696. * @returns the class name
  8697. */
  8698. getClassName(): string;
  8699. /** @hidden */
  8700. _onLostFocus(): void;
  8701. /**
  8702. * Get the friendly name associated with the input class.
  8703. * @returns the input friendly name
  8704. */
  8705. getSimpleName(): string;
  8706. }
  8707. }
  8708. declare module BABYLON {
  8709. /**
  8710. * Interface describing all the common properties and methods a shadow light needs to implement.
  8711. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8712. * as well as binding the different shadow properties to the effects.
  8713. */
  8714. export interface IShadowLight extends Light {
  8715. /**
  8716. * The light id in the scene (used in scene.findLighById for instance)
  8717. */
  8718. id: string;
  8719. /**
  8720. * The position the shdow will be casted from.
  8721. */
  8722. position: Vector3;
  8723. /**
  8724. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8725. */
  8726. direction: Vector3;
  8727. /**
  8728. * The transformed position. Position of the light in world space taking parenting in account.
  8729. */
  8730. transformedPosition: Vector3;
  8731. /**
  8732. * The transformed direction. Direction of the light in world space taking parenting in account.
  8733. */
  8734. transformedDirection: Vector3;
  8735. /**
  8736. * The friendly name of the light in the scene.
  8737. */
  8738. name: string;
  8739. /**
  8740. * Defines the shadow projection clipping minimum z value.
  8741. */
  8742. shadowMinZ: number;
  8743. /**
  8744. * Defines the shadow projection clipping maximum z value.
  8745. */
  8746. shadowMaxZ: number;
  8747. /**
  8748. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8749. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8750. */
  8751. computeTransformedInformation(): boolean;
  8752. /**
  8753. * Gets the scene the light belongs to.
  8754. * @returns The scene
  8755. */
  8756. getScene(): Scene;
  8757. /**
  8758. * Callback defining a custom Projection Matrix Builder.
  8759. * This can be used to override the default projection matrix computation.
  8760. */
  8761. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8762. /**
  8763. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8764. * @param matrix The materix to updated with the projection information
  8765. * @param viewMatrix The transform matrix of the light
  8766. * @param renderList The list of mesh to render in the map
  8767. * @returns The current light
  8768. */
  8769. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8770. /**
  8771. * Gets the current depth scale used in ESM.
  8772. * @returns The scale
  8773. */
  8774. getDepthScale(): number;
  8775. /**
  8776. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8777. * @returns true if a cube texture needs to be use
  8778. */
  8779. needCube(): boolean;
  8780. /**
  8781. * Detects if the projection matrix requires to be recomputed this frame.
  8782. * @returns true if it requires to be recomputed otherwise, false.
  8783. */
  8784. needProjectionMatrixCompute(): boolean;
  8785. /**
  8786. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8787. */
  8788. forceProjectionMatrixCompute(): void;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Gets the minZ used for shadow according to both the scene and the light.
  8797. * @param activeCamera The camera we are returning the min for
  8798. * @returns the depth min z
  8799. */
  8800. getDepthMinZ(activeCamera: Camera): number;
  8801. /**
  8802. * Gets the maxZ used for shadow according to both the scene and the light.
  8803. * @param activeCamera The camera we are returning the max for
  8804. * @returns the depth max z
  8805. */
  8806. getDepthMaxZ(activeCamera: Camera): number;
  8807. }
  8808. /**
  8809. * Base implementation IShadowLight
  8810. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8811. */
  8812. export abstract class ShadowLight extends Light implements IShadowLight {
  8813. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8814. protected _position: Vector3;
  8815. protected _setPosition(value: Vector3): void;
  8816. /**
  8817. * Sets the position the shadow will be casted from. Also use as the light position for both
  8818. * point and spot lights.
  8819. */
  8820. /**
  8821. * Sets the position the shadow will be casted from. Also use as the light position for both
  8822. * point and spot lights.
  8823. */
  8824. position: Vector3;
  8825. protected _direction: Vector3;
  8826. protected _setDirection(value: Vector3): void;
  8827. /**
  8828. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8829. * Also use as the light direction on spot and directional lights.
  8830. */
  8831. /**
  8832. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8833. * Also use as the light direction on spot and directional lights.
  8834. */
  8835. direction: Vector3;
  8836. private _shadowMinZ;
  8837. /**
  8838. * Gets the shadow projection clipping minimum z value.
  8839. */
  8840. /**
  8841. * Sets the shadow projection clipping minimum z value.
  8842. */
  8843. shadowMinZ: number;
  8844. private _shadowMaxZ;
  8845. /**
  8846. * Sets the shadow projection clipping maximum z value.
  8847. */
  8848. /**
  8849. * Gets the shadow projection clipping maximum z value.
  8850. */
  8851. shadowMaxZ: number;
  8852. /**
  8853. * Callback defining a custom Projection Matrix Builder.
  8854. * This can be used to override the default projection matrix computation.
  8855. */
  8856. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8857. /**
  8858. * The transformed position. Position of the light in world space taking parenting in account.
  8859. */
  8860. transformedPosition: Vector3;
  8861. /**
  8862. * The transformed direction. Direction of the light in world space taking parenting in account.
  8863. */
  8864. transformedDirection: Vector3;
  8865. private _needProjectionMatrixCompute;
  8866. /**
  8867. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8868. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8869. */
  8870. computeTransformedInformation(): boolean;
  8871. /**
  8872. * Return the depth scale used for the shadow map.
  8873. * @returns the depth scale.
  8874. */
  8875. getDepthScale(): number;
  8876. /**
  8877. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8878. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8879. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8880. */
  8881. getShadowDirection(faceIndex?: number): Vector3;
  8882. /**
  8883. * Returns the ShadowLight absolute position in the World.
  8884. * @returns the position vector in world space
  8885. */
  8886. getAbsolutePosition(): Vector3;
  8887. /**
  8888. * Sets the ShadowLight direction toward the passed target.
  8889. * @param target The point to target in local space
  8890. * @returns the updated ShadowLight direction
  8891. */
  8892. setDirectionToTarget(target: Vector3): Vector3;
  8893. /**
  8894. * Returns the light rotation in euler definition.
  8895. * @returns the x y z rotation in local space.
  8896. */
  8897. getRotation(): Vector3;
  8898. /**
  8899. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8900. * @returns true if a cube texture needs to be use
  8901. */
  8902. needCube(): boolean;
  8903. /**
  8904. * Detects if the projection matrix requires to be recomputed this frame.
  8905. * @returns true if it requires to be recomputed otherwise, false.
  8906. */
  8907. needProjectionMatrixCompute(): boolean;
  8908. /**
  8909. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8910. */
  8911. forceProjectionMatrixCompute(): void;
  8912. /** @hidden */
  8913. _initCache(): void;
  8914. /** @hidden */
  8915. _isSynchronized(): boolean;
  8916. /**
  8917. * Computes the world matrix of the node
  8918. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8919. * @returns the world matrix
  8920. */
  8921. computeWorldMatrix(force?: boolean): Matrix;
  8922. /**
  8923. * Gets the minZ used for shadow according to both the scene and the light.
  8924. * @param activeCamera The camera we are returning the min for
  8925. * @returns the depth min z
  8926. */
  8927. getDepthMinZ(activeCamera: Camera): number;
  8928. /**
  8929. * Gets the maxZ used for shadow according to both the scene and the light.
  8930. * @param activeCamera The camera we are returning the max for
  8931. * @returns the depth max z
  8932. */
  8933. getDepthMaxZ(activeCamera: Camera): number;
  8934. /**
  8935. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8936. * @param matrix The materix to updated with the projection information
  8937. * @param viewMatrix The transform matrix of the light
  8938. * @param renderList The list of mesh to render in the map
  8939. * @returns The current light
  8940. */
  8941. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8942. }
  8943. }
  8944. declare module BABYLON {
  8945. /**
  8946. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8947. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8948. */
  8949. export class EffectFallbacks implements IEffectFallbacks {
  8950. private _defines;
  8951. private _currentRank;
  8952. private _maxRank;
  8953. private _mesh;
  8954. /**
  8955. * Removes the fallback from the bound mesh.
  8956. */
  8957. unBindMesh(): void;
  8958. /**
  8959. * Adds a fallback on the specified property.
  8960. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8961. * @param define The name of the define in the shader
  8962. */
  8963. addFallback(rank: number, define: string): void;
  8964. /**
  8965. * Sets the mesh to use CPU skinning when needing to fallback.
  8966. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8967. * @param mesh The mesh to use the fallbacks.
  8968. */
  8969. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8970. /**
  8971. * Checks to see if more fallbacks are still availible.
  8972. */
  8973. readonly hasMoreFallbacks: boolean;
  8974. /**
  8975. * Removes the defines that should be removed when falling back.
  8976. * @param currentDefines defines the current define statements for the shader.
  8977. * @param effect defines the current effect we try to compile
  8978. * @returns The resulting defines with defines of the current rank removed.
  8979. */
  8980. reduce(currentDefines: string, effect: Effect): string;
  8981. }
  8982. }
  8983. declare module BABYLON {
  8984. /**
  8985. * "Static Class" containing the most commonly used helper while dealing with material for
  8986. * rendering purpose.
  8987. *
  8988. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8989. *
  8990. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8991. */
  8992. export class MaterialHelper {
  8993. /**
  8994. * Bind the current view position to an effect.
  8995. * @param effect The effect to be bound
  8996. * @param scene The scene the eyes position is used from
  8997. */
  8998. static BindEyePosition(effect: Effect, scene: Scene): void;
  8999. /**
  9000. * Helps preparing the defines values about the UVs in used in the effect.
  9001. * UVs are shared as much as we can accross channels in the shaders.
  9002. * @param texture The texture we are preparing the UVs for
  9003. * @param defines The defines to update
  9004. * @param key The channel key "diffuse", "specular"... used in the shader
  9005. */
  9006. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9007. /**
  9008. * Binds a texture matrix value to its corrsponding uniform
  9009. * @param texture The texture to bind the matrix for
  9010. * @param uniformBuffer The uniform buffer receivin the data
  9011. * @param key The channel key "diffuse", "specular"... used in the shader
  9012. */
  9013. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9014. /**
  9015. * Gets the current status of the fog (should it be enabled?)
  9016. * @param mesh defines the mesh to evaluate for fog support
  9017. * @param scene defines the hosting scene
  9018. * @returns true if fog must be enabled
  9019. */
  9020. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9021. /**
  9022. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9023. * @param mesh defines the current mesh
  9024. * @param scene defines the current scene
  9025. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9026. * @param pointsCloud defines if point cloud rendering has to be turned on
  9027. * @param fogEnabled defines if fog has to be turned on
  9028. * @param alphaTest defines if alpha testing has to be turned on
  9029. * @param defines defines the current list of defines
  9030. */
  9031. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9032. /**
  9033. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9034. * @param scene defines the current scene
  9035. * @param engine defines the current engine
  9036. * @param defines specifies the list of active defines
  9037. * @param useInstances defines if instances have to be turned on
  9038. * @param useClipPlane defines if clip plane have to be turned on
  9039. */
  9040. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9041. /**
  9042. * Prepares the defines for bones
  9043. * @param mesh The mesh containing the geometry data we will draw
  9044. * @param defines The defines to update
  9045. */
  9046. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9047. /**
  9048. * Prepares the defines for morph targets
  9049. * @param mesh The mesh containing the geometry data we will draw
  9050. * @param defines The defines to update
  9051. */
  9052. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9053. /**
  9054. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9055. * @param mesh The mesh containing the geometry data we will draw
  9056. * @param defines The defines to update
  9057. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9058. * @param useBones Precise whether bones should be used or not (override mesh info)
  9059. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9060. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9061. * @returns false if defines are considered not dirty and have not been checked
  9062. */
  9063. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9064. /**
  9065. * Prepares the defines related to multiview
  9066. * @param scene The scene we are intending to draw
  9067. * @param defines The defines to update
  9068. */
  9069. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9070. /**
  9071. * Prepares the defines related to the light information passed in parameter
  9072. * @param scene The scene we are intending to draw
  9073. * @param mesh The mesh the effect is compiling for
  9074. * @param light The light the effect is compiling for
  9075. * @param lightIndex The index of the light
  9076. * @param defines The defines to update
  9077. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9078. * @param state Defines the current state regarding what is needed (normals, etc...)
  9079. */
  9080. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9081. needNormals: boolean;
  9082. needRebuild: boolean;
  9083. shadowEnabled: boolean;
  9084. specularEnabled: boolean;
  9085. lightmapMode: boolean;
  9086. }): void;
  9087. /**
  9088. * Prepares the defines related to the light information passed in parameter
  9089. * @param scene The scene we are intending to draw
  9090. * @param mesh The mesh the effect is compiling for
  9091. * @param defines The defines to update
  9092. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9093. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9094. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9095. * @returns true if normals will be required for the rest of the effect
  9096. */
  9097. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9098. /**
  9099. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9100. * @param lightIndex defines the light index
  9101. * @param uniformsList The uniform list
  9102. * @param samplersList The sampler list
  9103. * @param projectedLightTexture defines if projected texture must be used
  9104. * @param uniformBuffersList defines an optional list of uniform buffers
  9105. */
  9106. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9107. /**
  9108. * Prepares the uniforms and samplers list to be used in the effect
  9109. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9110. * @param samplersList The sampler list
  9111. * @param defines The defines helping in the list generation
  9112. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9113. */
  9114. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9115. /**
  9116. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9117. * @param defines The defines to update while falling back
  9118. * @param fallbacks The authorized effect fallbacks
  9119. * @param maxSimultaneousLights The maximum number of lights allowed
  9120. * @param rank the current rank of the Effect
  9121. * @returns The newly affected rank
  9122. */
  9123. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9124. private static _TmpMorphInfluencers;
  9125. /**
  9126. * Prepares the list of attributes required for morph targets according to the effect defines.
  9127. * @param attribs The current list of supported attribs
  9128. * @param mesh The mesh to prepare the morph targets attributes for
  9129. * @param influencers The number of influencers
  9130. */
  9131. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9132. /**
  9133. * Prepares the list of attributes required for morph targets according to the effect defines.
  9134. * @param attribs The current list of supported attribs
  9135. * @param mesh The mesh to prepare the morph targets attributes for
  9136. * @param defines The current Defines of the effect
  9137. */
  9138. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9139. /**
  9140. * Prepares the list of attributes required for bones according to the effect defines.
  9141. * @param attribs The current list of supported attribs
  9142. * @param mesh The mesh to prepare the bones attributes for
  9143. * @param defines The current Defines of the effect
  9144. * @param fallbacks The current efffect fallback strategy
  9145. */
  9146. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9147. /**
  9148. * Check and prepare the list of attributes required for instances according to the effect defines.
  9149. * @param attribs The current list of supported attribs
  9150. * @param defines The current MaterialDefines of the effect
  9151. */
  9152. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9153. /**
  9154. * Add the list of attributes required for instances to the attribs array.
  9155. * @param attribs The current list of supported attribs
  9156. */
  9157. static PushAttributesForInstances(attribs: string[]): void;
  9158. /**
  9159. * Binds the light information to the effect.
  9160. * @param light The light containing the generator
  9161. * @param effect The effect we are binding the data to
  9162. * @param lightIndex The light index in the effect used to render
  9163. */
  9164. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9165. /**
  9166. * Binds the lights information from the scene to the effect for the given mesh.
  9167. * @param light Light to bind
  9168. * @param lightIndex Light index
  9169. * @param scene The scene where the light belongs to
  9170. * @param effect The effect we are binding the data to
  9171. * @param useSpecular Defines if specular is supported
  9172. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9173. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9174. */
  9175. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9176. /**
  9177. * Binds the lights information from the scene to the effect for the given mesh.
  9178. * @param scene The scene the lights belongs to
  9179. * @param mesh The mesh we are binding the information to render
  9180. * @param effect The effect we are binding the data to
  9181. * @param defines The generated defines for the effect
  9182. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9183. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9184. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9185. */
  9186. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9187. private static _tempFogColor;
  9188. /**
  9189. * Binds the fog information from the scene to the effect for the given mesh.
  9190. * @param scene The scene the lights belongs to
  9191. * @param mesh The mesh we are binding the information to render
  9192. * @param effect The effect we are binding the data to
  9193. * @param linearSpace Defines if the fog effect is applied in linear space
  9194. */
  9195. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9196. /**
  9197. * Binds the bones information from the mesh to the effect.
  9198. * @param mesh The mesh we are binding the information to render
  9199. * @param effect The effect we are binding the data to
  9200. */
  9201. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9202. /**
  9203. * Binds the morph targets information from the mesh to the effect.
  9204. * @param abstractMesh The mesh we are binding the information to render
  9205. * @param effect The effect we are binding the data to
  9206. */
  9207. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9208. /**
  9209. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9210. * @param defines The generated defines used in the effect
  9211. * @param effect The effect we are binding the data to
  9212. * @param scene The scene we are willing to render with logarithmic scale for
  9213. */
  9214. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9215. /**
  9216. * Binds the clip plane information from the scene to the effect.
  9217. * @param scene The scene the clip plane information are extracted from
  9218. * @param effect The effect we are binding the data to
  9219. */
  9220. static BindClipPlane(effect: Effect, scene: Scene): void;
  9221. }
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var packingFunctions: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var shadowMapPixelShader: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var bonesDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var morphTargetsVertexGlobalDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var morphTargetsVertexDeclaration: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var instancesDeclaration: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var helperFunctions: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var morphTargetsVertex: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var instancesVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var bonesVertex: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var shadowMapVertexShader: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var depthBoxBlurPixelShader: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /**
  9309. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9310. */
  9311. export interface ICustomShaderOptions {
  9312. /**
  9313. * Gets or sets the custom shader name to use
  9314. */
  9315. shaderName: string;
  9316. /**
  9317. * The list of attribute names used in the shader
  9318. */
  9319. attributes?: string[];
  9320. /**
  9321. * The list of unifrom names used in the shader
  9322. */
  9323. uniforms?: string[];
  9324. /**
  9325. * The list of sampler names used in the shader
  9326. */
  9327. samplers?: string[];
  9328. /**
  9329. * The list of defines used in the shader
  9330. */
  9331. defines?: string[];
  9332. }
  9333. /**
  9334. * Interface to implement to create a shadow generator compatible with BJS.
  9335. */
  9336. export interface IShadowGenerator {
  9337. /**
  9338. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9339. * @returns The render target texture if present otherwise, null
  9340. */
  9341. getShadowMap(): Nullable<RenderTargetTexture>;
  9342. /**
  9343. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9344. * @returns The render target texture if the shadow map is present otherwise, null
  9345. */
  9346. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9347. /**
  9348. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9349. * @param subMesh The submesh we want to render in the shadow map
  9350. * @param useInstances Defines wether will draw in the map using instances
  9351. * @returns true if ready otherwise, false
  9352. */
  9353. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9354. /**
  9355. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9356. * @param defines Defines of the material we want to update
  9357. * @param lightIndex Index of the light in the enabled light list of the material
  9358. */
  9359. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9360. /**
  9361. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9362. * defined in the generator but impacting the effect).
  9363. * It implies the unifroms available on the materials are the standard BJS ones.
  9364. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9365. * @param effect The effect we are binfing the information for
  9366. */
  9367. bindShadowLight(lightIndex: string, effect: Effect): void;
  9368. /**
  9369. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9370. * (eq to shadow prjection matrix * light transform matrix)
  9371. * @returns The transform matrix used to create the shadow map
  9372. */
  9373. getTransformMatrix(): Matrix;
  9374. /**
  9375. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9376. * Cube and 2D textures for instance.
  9377. */
  9378. recreateShadowMap(): void;
  9379. /**
  9380. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9381. * @param onCompiled Callback triggered at the and of the effects compilation
  9382. * @param options Sets of optional options forcing the compilation with different modes
  9383. */
  9384. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9385. useInstances: boolean;
  9386. }>): void;
  9387. /**
  9388. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9389. * @param options Sets of optional options forcing the compilation with different modes
  9390. * @returns A promise that resolves when the compilation completes
  9391. */
  9392. forceCompilationAsync(options?: Partial<{
  9393. useInstances: boolean;
  9394. }>): Promise<void>;
  9395. /**
  9396. * Serializes the shadow generator setup to a json object.
  9397. * @returns The serialized JSON object
  9398. */
  9399. serialize(): any;
  9400. /**
  9401. * Disposes the Shadow map and related Textures and effects.
  9402. */
  9403. dispose(): void;
  9404. }
  9405. /**
  9406. * Default implementation IShadowGenerator.
  9407. * This is the main object responsible of generating shadows in the framework.
  9408. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9409. */
  9410. export class ShadowGenerator implements IShadowGenerator {
  9411. /**
  9412. * Shadow generator mode None: no filtering applied.
  9413. */
  9414. static readonly FILTER_NONE: number;
  9415. /**
  9416. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9417. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9418. */
  9419. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9420. /**
  9421. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9422. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9423. */
  9424. static readonly FILTER_POISSONSAMPLING: number;
  9425. /**
  9426. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9427. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9428. */
  9429. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9430. /**
  9431. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9432. * edge artifacts on steep falloff.
  9433. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9434. */
  9435. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9436. /**
  9437. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9438. * edge artifacts on steep falloff.
  9439. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9440. */
  9441. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9442. /**
  9443. * Shadow generator mode PCF: Percentage Closer Filtering
  9444. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9445. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9446. */
  9447. static readonly FILTER_PCF: number;
  9448. /**
  9449. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9450. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9451. * Contact Hardening
  9452. */
  9453. static readonly FILTER_PCSS: number;
  9454. /**
  9455. * Reserved for PCF and PCSS
  9456. * Highest Quality.
  9457. *
  9458. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9459. *
  9460. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9461. */
  9462. static readonly QUALITY_HIGH: number;
  9463. /**
  9464. * Reserved for PCF and PCSS
  9465. * Good tradeoff for quality/perf cross devices
  9466. *
  9467. * Execute PCF on a 3*3 kernel.
  9468. *
  9469. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9470. */
  9471. static readonly QUALITY_MEDIUM: number;
  9472. /**
  9473. * Reserved for PCF and PCSS
  9474. * The lowest quality but the fastest.
  9475. *
  9476. * Execute PCF on a 1*1 kernel.
  9477. *
  9478. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9479. */
  9480. static readonly QUALITY_LOW: number;
  9481. /** Gets or sets the custom shader name to use */
  9482. customShaderOptions: ICustomShaderOptions;
  9483. /**
  9484. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9485. */
  9486. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9487. /**
  9488. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9489. */
  9490. onAfterShadowMapRenderObservable: Observable<Effect>;
  9491. /**
  9492. * Observable triggered before a mesh is rendered in the shadow map.
  9493. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9494. */
  9495. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9496. /**
  9497. * Observable triggered after a mesh is rendered in the shadow map.
  9498. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9499. */
  9500. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9501. private _bias;
  9502. /**
  9503. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9504. */
  9505. /**
  9506. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9507. */
  9508. bias: number;
  9509. private _normalBias;
  9510. /**
  9511. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9512. */
  9513. /**
  9514. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9515. */
  9516. normalBias: number;
  9517. private _blurBoxOffset;
  9518. /**
  9519. * Gets the blur box offset: offset applied during the blur pass.
  9520. * Only useful if useKernelBlur = false
  9521. */
  9522. /**
  9523. * Sets the blur box offset: offset applied during the blur pass.
  9524. * Only useful if useKernelBlur = false
  9525. */
  9526. blurBoxOffset: number;
  9527. private _blurScale;
  9528. /**
  9529. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9530. * 2 means half of the size.
  9531. */
  9532. /**
  9533. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9534. * 2 means half of the size.
  9535. */
  9536. blurScale: number;
  9537. private _blurKernel;
  9538. /**
  9539. * Gets the blur kernel: kernel size of the blur pass.
  9540. * Only useful if useKernelBlur = true
  9541. */
  9542. /**
  9543. * Sets the blur kernel: kernel size of the blur pass.
  9544. * Only useful if useKernelBlur = true
  9545. */
  9546. blurKernel: number;
  9547. private _useKernelBlur;
  9548. /**
  9549. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9550. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9551. */
  9552. /**
  9553. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9554. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9555. */
  9556. useKernelBlur: boolean;
  9557. private _depthScale;
  9558. /**
  9559. * Gets the depth scale used in ESM mode.
  9560. */
  9561. /**
  9562. * Sets the depth scale used in ESM mode.
  9563. * This can override the scale stored on the light.
  9564. */
  9565. depthScale: number;
  9566. private _filter;
  9567. /**
  9568. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9569. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9570. */
  9571. /**
  9572. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9573. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9574. */
  9575. filter: number;
  9576. /**
  9577. * Gets if the current filter is set to Poisson Sampling.
  9578. */
  9579. /**
  9580. * Sets the current filter to Poisson Sampling.
  9581. */
  9582. usePoissonSampling: boolean;
  9583. /**
  9584. * Gets if the current filter is set to ESM.
  9585. */
  9586. /**
  9587. * Sets the current filter is to ESM.
  9588. */
  9589. useExponentialShadowMap: boolean;
  9590. /**
  9591. * Gets if the current filter is set to filtered ESM.
  9592. */
  9593. /**
  9594. * Gets if the current filter is set to filtered ESM.
  9595. */
  9596. useBlurExponentialShadowMap: boolean;
  9597. /**
  9598. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9599. * exponential to prevent steep falloff artifacts).
  9600. */
  9601. /**
  9602. * Sets the current filter to "close ESM" (using the inverse of the
  9603. * exponential to prevent steep falloff artifacts).
  9604. */
  9605. useCloseExponentialShadowMap: boolean;
  9606. /**
  9607. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9608. * exponential to prevent steep falloff artifacts).
  9609. */
  9610. /**
  9611. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9612. * exponential to prevent steep falloff artifacts).
  9613. */
  9614. useBlurCloseExponentialShadowMap: boolean;
  9615. /**
  9616. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9617. */
  9618. /**
  9619. * Sets the current filter to "PCF" (percentage closer filtering).
  9620. */
  9621. usePercentageCloserFiltering: boolean;
  9622. private _filteringQuality;
  9623. /**
  9624. * Gets the PCF or PCSS Quality.
  9625. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9626. */
  9627. /**
  9628. * Sets the PCF or PCSS Quality.
  9629. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9630. */
  9631. filteringQuality: number;
  9632. /**
  9633. * Gets if the current filter is set to "PCSS" (contact hardening).
  9634. */
  9635. /**
  9636. * Sets the current filter to "PCSS" (contact hardening).
  9637. */
  9638. useContactHardeningShadow: boolean;
  9639. private _contactHardeningLightSizeUVRatio;
  9640. /**
  9641. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9642. * Using a ratio helps keeping shape stability independently of the map size.
  9643. *
  9644. * It does not account for the light projection as it was having too much
  9645. * instability during the light setup or during light position changes.
  9646. *
  9647. * Only valid if useContactHardeningShadow is true.
  9648. */
  9649. /**
  9650. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9651. * Using a ratio helps keeping shape stability independently of the map size.
  9652. *
  9653. * It does not account for the light projection as it was having too much
  9654. * instability during the light setup or during light position changes.
  9655. *
  9656. * Only valid if useContactHardeningShadow is true.
  9657. */
  9658. contactHardeningLightSizeUVRatio: number;
  9659. private _darkness;
  9660. /** Gets or sets the actual darkness of a shadow */
  9661. darkness: number;
  9662. /**
  9663. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9664. * 0 means strongest and 1 would means no shadow.
  9665. * @returns the darkness.
  9666. */
  9667. getDarkness(): number;
  9668. /**
  9669. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9670. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9671. * @returns the shadow generator allowing fluent coding.
  9672. */
  9673. setDarkness(darkness: number): ShadowGenerator;
  9674. private _transparencyShadow;
  9675. /** Gets or sets the ability to have transparent shadow */
  9676. transparencyShadow: boolean;
  9677. /**
  9678. * Sets the ability to have transparent shadow (boolean).
  9679. * @param transparent True if transparent else False
  9680. * @returns the shadow generator allowing fluent coding
  9681. */
  9682. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9683. private _shadowMap;
  9684. private _shadowMap2;
  9685. /**
  9686. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9687. * @returns The render target texture if present otherwise, null
  9688. */
  9689. getShadowMap(): Nullable<RenderTargetTexture>;
  9690. /**
  9691. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9692. * @returns The render target texture if the shadow map is present otherwise, null
  9693. */
  9694. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9695. /**
  9696. * Gets the class name of that object
  9697. * @returns "ShadowGenerator"
  9698. */
  9699. getClassName(): string;
  9700. /**
  9701. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9702. * @param mesh Mesh to add
  9703. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9704. * @returns the Shadow Generator itself
  9705. */
  9706. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9707. /**
  9708. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9709. * @param mesh Mesh to remove
  9710. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9711. * @returns the Shadow Generator itself
  9712. */
  9713. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9714. /**
  9715. * Controls the extent to which the shadows fade out at the edge of the frustum
  9716. * Used only by directionals and spots
  9717. */
  9718. frustumEdgeFalloff: number;
  9719. private _light;
  9720. /**
  9721. * Returns the associated light object.
  9722. * @returns the light generating the shadow
  9723. */
  9724. getLight(): IShadowLight;
  9725. /**
  9726. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9727. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9728. * It might on the other hand introduce peter panning.
  9729. */
  9730. forceBackFacesOnly: boolean;
  9731. private _scene;
  9732. private _lightDirection;
  9733. private _effect;
  9734. private _viewMatrix;
  9735. private _projectionMatrix;
  9736. private _transformMatrix;
  9737. private _cachedPosition;
  9738. private _cachedDirection;
  9739. private _cachedDefines;
  9740. private _currentRenderID;
  9741. private _boxBlurPostprocess;
  9742. private _kernelBlurXPostprocess;
  9743. private _kernelBlurYPostprocess;
  9744. private _blurPostProcesses;
  9745. private _mapSize;
  9746. private _currentFaceIndex;
  9747. private _currentFaceIndexCache;
  9748. private _textureType;
  9749. private _defaultTextureMatrix;
  9750. private _storedUniqueId;
  9751. /** @hidden */
  9752. static _SceneComponentInitialization: (scene: Scene) => void;
  9753. /**
  9754. * Creates a ShadowGenerator object.
  9755. * A ShadowGenerator is the required tool to use the shadows.
  9756. * Each light casting shadows needs to use its own ShadowGenerator.
  9757. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9758. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9759. * @param light The light object generating the shadows.
  9760. * @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.
  9761. */
  9762. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9763. private _initializeGenerator;
  9764. private _initializeShadowMap;
  9765. private _initializeBlurRTTAndPostProcesses;
  9766. private _renderForShadowMap;
  9767. private _renderSubMeshForShadowMap;
  9768. private _applyFilterValues;
  9769. /**
  9770. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9771. * @param onCompiled Callback triggered at the and of the effects compilation
  9772. * @param options Sets of optional options forcing the compilation with different modes
  9773. */
  9774. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9775. useInstances: boolean;
  9776. }>): void;
  9777. /**
  9778. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9779. * @param options Sets of optional options forcing the compilation with different modes
  9780. * @returns A promise that resolves when the compilation completes
  9781. */
  9782. forceCompilationAsync(options?: Partial<{
  9783. useInstances: boolean;
  9784. }>): Promise<void>;
  9785. /**
  9786. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9787. * @param subMesh The submesh we want to render in the shadow map
  9788. * @param useInstances Defines wether will draw in the map using instances
  9789. * @returns true if ready otherwise, false
  9790. */
  9791. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9792. /**
  9793. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9794. * @param defines Defines of the material we want to update
  9795. * @param lightIndex Index of the light in the enabled light list of the material
  9796. */
  9797. prepareDefines(defines: any, lightIndex: number): void;
  9798. /**
  9799. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9800. * defined in the generator but impacting the effect).
  9801. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9802. * @param effect The effect we are binfing the information for
  9803. */
  9804. bindShadowLight(lightIndex: string, effect: Effect): void;
  9805. /**
  9806. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9807. * (eq to shadow prjection matrix * light transform matrix)
  9808. * @returns The transform matrix used to create the shadow map
  9809. */
  9810. getTransformMatrix(): Matrix;
  9811. /**
  9812. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9813. * Cube and 2D textures for instance.
  9814. */
  9815. recreateShadowMap(): void;
  9816. private _disposeBlurPostProcesses;
  9817. private _disposeRTTandPostProcesses;
  9818. /**
  9819. * Disposes the ShadowGenerator.
  9820. * Returns nothing.
  9821. */
  9822. dispose(): void;
  9823. /**
  9824. * Serializes the shadow generator setup to a json object.
  9825. * @returns The serialized JSON object
  9826. */
  9827. serialize(): any;
  9828. /**
  9829. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9830. * @param parsedShadowGenerator The JSON object to parse
  9831. * @param scene The scene to create the shadow map for
  9832. * @returns The parsed shadow generator
  9833. */
  9834. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9835. }
  9836. }
  9837. declare module BABYLON {
  9838. /**
  9839. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9840. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9841. * 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.
  9842. */
  9843. export abstract class Light extends Node {
  9844. /**
  9845. * Falloff Default: light is falling off following the material specification:
  9846. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9847. */
  9848. static readonly FALLOFF_DEFAULT: number;
  9849. /**
  9850. * Falloff Physical: light is falling off following the inverse squared distance law.
  9851. */
  9852. static readonly FALLOFF_PHYSICAL: number;
  9853. /**
  9854. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9855. * to enhance interoperability with other engines.
  9856. */
  9857. static readonly FALLOFF_GLTF: number;
  9858. /**
  9859. * Falloff Standard: light is falling off like in the standard material
  9860. * to enhance interoperability with other materials.
  9861. */
  9862. static readonly FALLOFF_STANDARD: number;
  9863. /**
  9864. * If every light affecting the material is in this lightmapMode,
  9865. * material.lightmapTexture adds or multiplies
  9866. * (depends on material.useLightmapAsShadowmap)
  9867. * after every other light calculations.
  9868. */
  9869. static readonly LIGHTMAP_DEFAULT: number;
  9870. /**
  9871. * material.lightmapTexture as only diffuse lighting from this light
  9872. * adds only specular lighting from this light
  9873. * adds dynamic shadows
  9874. */
  9875. static readonly LIGHTMAP_SPECULAR: number;
  9876. /**
  9877. * material.lightmapTexture as only lighting
  9878. * no light calculation from this light
  9879. * only adds dynamic shadows from this light
  9880. */
  9881. static readonly LIGHTMAP_SHADOWSONLY: number;
  9882. /**
  9883. * Each light type uses the default quantity according to its type:
  9884. * point/spot lights use luminous intensity
  9885. * directional lights use illuminance
  9886. */
  9887. static readonly INTENSITYMODE_AUTOMATIC: number;
  9888. /**
  9889. * lumen (lm)
  9890. */
  9891. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9892. /**
  9893. * candela (lm/sr)
  9894. */
  9895. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9896. /**
  9897. * lux (lm/m^2)
  9898. */
  9899. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9900. /**
  9901. * nit (cd/m^2)
  9902. */
  9903. static readonly INTENSITYMODE_LUMINANCE: number;
  9904. /**
  9905. * Light type const id of the point light.
  9906. */
  9907. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9908. /**
  9909. * Light type const id of the directional light.
  9910. */
  9911. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9912. /**
  9913. * Light type const id of the spot light.
  9914. */
  9915. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9916. /**
  9917. * Light type const id of the hemispheric light.
  9918. */
  9919. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9920. /**
  9921. * Diffuse gives the basic color to an object.
  9922. */
  9923. diffuse: Color3;
  9924. /**
  9925. * Specular produces a highlight color on an object.
  9926. * Note: This is note affecting PBR materials.
  9927. */
  9928. specular: Color3;
  9929. /**
  9930. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9931. * falling off base on range or angle.
  9932. * This can be set to any values in Light.FALLOFF_x.
  9933. *
  9934. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9935. * other types of materials.
  9936. */
  9937. falloffType: number;
  9938. /**
  9939. * Strength of the light.
  9940. * Note: By default it is define in the framework own unit.
  9941. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9942. */
  9943. intensity: number;
  9944. private _range;
  9945. protected _inverseSquaredRange: number;
  9946. /**
  9947. * Defines how far from the source the light is impacting in scene units.
  9948. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9949. */
  9950. /**
  9951. * Defines how far from the source the light is impacting in scene units.
  9952. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9953. */
  9954. range: number;
  9955. /**
  9956. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9957. * of light.
  9958. */
  9959. private _photometricScale;
  9960. private _intensityMode;
  9961. /**
  9962. * Gets the photometric scale used to interpret the intensity.
  9963. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9964. */
  9965. /**
  9966. * Sets the photometric scale used to interpret the intensity.
  9967. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9968. */
  9969. intensityMode: number;
  9970. private _radius;
  9971. /**
  9972. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9973. */
  9974. /**
  9975. * sets the light radius used by PBR Materials to simulate soft area lights.
  9976. */
  9977. radius: number;
  9978. private _renderPriority;
  9979. /**
  9980. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9981. * exceeding the number allowed of the materials.
  9982. */
  9983. renderPriority: number;
  9984. private _shadowEnabled;
  9985. /**
  9986. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9987. * the current shadow generator.
  9988. */
  9989. /**
  9990. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9991. * the current shadow generator.
  9992. */
  9993. shadowEnabled: boolean;
  9994. private _includedOnlyMeshes;
  9995. /**
  9996. * Gets the only meshes impacted by this light.
  9997. */
  9998. /**
  9999. * Sets the only meshes impacted by this light.
  10000. */
  10001. includedOnlyMeshes: AbstractMesh[];
  10002. private _excludedMeshes;
  10003. /**
  10004. * Gets the meshes not impacted by this light.
  10005. */
  10006. /**
  10007. * Sets the meshes not impacted by this light.
  10008. */
  10009. excludedMeshes: AbstractMesh[];
  10010. private _excludeWithLayerMask;
  10011. /**
  10012. * Gets the layer id use to find what meshes are not impacted by the light.
  10013. * Inactive if 0
  10014. */
  10015. /**
  10016. * Sets the layer id use to find what meshes are not impacted by the light.
  10017. * Inactive if 0
  10018. */
  10019. excludeWithLayerMask: number;
  10020. private _includeOnlyWithLayerMask;
  10021. /**
  10022. * Gets the layer id use to find what meshes are impacted by the light.
  10023. * Inactive if 0
  10024. */
  10025. /**
  10026. * Sets the layer id use to find what meshes are impacted by the light.
  10027. * Inactive if 0
  10028. */
  10029. includeOnlyWithLayerMask: number;
  10030. private _lightmapMode;
  10031. /**
  10032. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10033. */
  10034. /**
  10035. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10036. */
  10037. lightmapMode: number;
  10038. /**
  10039. * Shadow generator associted to the light.
  10040. * @hidden Internal use only.
  10041. */
  10042. _shadowGenerator: Nullable<IShadowGenerator>;
  10043. /**
  10044. * @hidden Internal use only.
  10045. */
  10046. _excludedMeshesIds: string[];
  10047. /**
  10048. * @hidden Internal use only.
  10049. */
  10050. _includedOnlyMeshesIds: string[];
  10051. /**
  10052. * The current light unifom buffer.
  10053. * @hidden Internal use only.
  10054. */
  10055. _uniformBuffer: UniformBuffer;
  10056. /** @hidden */
  10057. _renderId: number;
  10058. /**
  10059. * Creates a Light object in the scene.
  10060. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10061. * @param name The firendly name of the light
  10062. * @param scene The scene the light belongs too
  10063. */
  10064. constructor(name: string, scene: Scene);
  10065. protected abstract _buildUniformLayout(): void;
  10066. /**
  10067. * Sets the passed Effect "effect" with the Light information.
  10068. * @param effect The effect to update
  10069. * @param lightIndex The index of the light in the effect to update
  10070. * @returns The light
  10071. */
  10072. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10073. /**
  10074. * Sets the passed Effect "effect" with the Light textures.
  10075. * @param effect The effect to update
  10076. * @param lightIndex The index of the light in the effect to update
  10077. * @returns The light
  10078. */
  10079. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10080. /**
  10081. * Binds the lights information from the scene to the effect for the given mesh.
  10082. * @param lightIndex Light index
  10083. * @param scene The scene where the light belongs to
  10084. * @param effect The effect we are binding the data to
  10085. * @param useSpecular Defines if specular is supported
  10086. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10087. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10088. */
  10089. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10090. /**
  10091. * Sets the passed Effect "effect" with the Light information.
  10092. * @param effect The effect to update
  10093. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10094. * @returns The light
  10095. */
  10096. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10097. /**
  10098. * Returns the string "Light".
  10099. * @returns the class name
  10100. */
  10101. getClassName(): string;
  10102. /** @hidden */
  10103. readonly _isLight: boolean;
  10104. /**
  10105. * Converts the light information to a readable string for debug purpose.
  10106. * @param fullDetails Supports for multiple levels of logging within scene loading
  10107. * @returns the human readable light info
  10108. */
  10109. toString(fullDetails?: boolean): string;
  10110. /** @hidden */
  10111. protected _syncParentEnabledState(): void;
  10112. /**
  10113. * Set the enabled state of this node.
  10114. * @param value - the new enabled state
  10115. */
  10116. setEnabled(value: boolean): void;
  10117. /**
  10118. * Returns the Light associated shadow generator if any.
  10119. * @return the associated shadow generator.
  10120. */
  10121. getShadowGenerator(): Nullable<IShadowGenerator>;
  10122. /**
  10123. * Returns a Vector3, the absolute light position in the World.
  10124. * @returns the world space position of the light
  10125. */
  10126. getAbsolutePosition(): Vector3;
  10127. /**
  10128. * Specifies if the light will affect the passed mesh.
  10129. * @param mesh The mesh to test against the light
  10130. * @return true the mesh is affected otherwise, false.
  10131. */
  10132. canAffectMesh(mesh: AbstractMesh): boolean;
  10133. /**
  10134. * Sort function to order lights for rendering.
  10135. * @param a First Light object to compare to second.
  10136. * @param b Second Light object to compare first.
  10137. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10138. */
  10139. static CompareLightsPriority(a: Light, b: Light): number;
  10140. /**
  10141. * Releases resources associated with this node.
  10142. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10143. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10144. */
  10145. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10146. /**
  10147. * Returns the light type ID (integer).
  10148. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10149. */
  10150. getTypeID(): number;
  10151. /**
  10152. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10153. * @returns the scaled intensity in intensity mode unit
  10154. */
  10155. getScaledIntensity(): number;
  10156. /**
  10157. * Returns a new Light object, named "name", from the current one.
  10158. * @param name The name of the cloned light
  10159. * @returns the new created light
  10160. */
  10161. clone(name: string): Nullable<Light>;
  10162. /**
  10163. * Serializes the current light into a Serialization object.
  10164. * @returns the serialized object.
  10165. */
  10166. serialize(): any;
  10167. /**
  10168. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10169. * This new light is named "name" and added to the passed scene.
  10170. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10171. * @param name The friendly name of the light
  10172. * @param scene The scene the new light will belong to
  10173. * @returns the constructor function
  10174. */
  10175. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10176. /**
  10177. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10178. * @param parsedLight The JSON representation of the light
  10179. * @param scene The scene to create the parsed light in
  10180. * @returns the created light after parsing
  10181. */
  10182. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10183. private _hookArrayForExcluded;
  10184. private _hookArrayForIncludedOnly;
  10185. private _resyncMeshes;
  10186. /**
  10187. * Forces the meshes to update their light related information in their rendering used effects
  10188. * @hidden Internal Use Only
  10189. */
  10190. _markMeshesAsLightDirty(): void;
  10191. /**
  10192. * Recomputes the cached photometric scale if needed.
  10193. */
  10194. private _computePhotometricScale;
  10195. /**
  10196. * Returns the Photometric Scale according to the light type and intensity mode.
  10197. */
  10198. private _getPhotometricScale;
  10199. /**
  10200. * Reorder the light in the scene according to their defined priority.
  10201. * @hidden Internal Use Only
  10202. */
  10203. _reorderLightsInScene(): void;
  10204. /**
  10205. * Prepares the list of defines specific to the light type.
  10206. * @param defines the list of defines
  10207. * @param lightIndex defines the index of the light for the effect
  10208. */
  10209. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10210. }
  10211. }
  10212. declare module BABYLON {
  10213. /**
  10214. * Interface used to define Action
  10215. */
  10216. export interface IAction {
  10217. /**
  10218. * Trigger for the action
  10219. */
  10220. trigger: number;
  10221. /** Options of the trigger */
  10222. triggerOptions: any;
  10223. /**
  10224. * Gets the trigger parameters
  10225. * @returns the trigger parameters
  10226. */
  10227. getTriggerParameter(): any;
  10228. /**
  10229. * Internal only - executes current action event
  10230. * @hidden
  10231. */
  10232. _executeCurrent(evt?: ActionEvent): void;
  10233. /**
  10234. * Serialize placeholder for child classes
  10235. * @param parent of child
  10236. * @returns the serialized object
  10237. */
  10238. serialize(parent: any): any;
  10239. /**
  10240. * Internal only
  10241. * @hidden
  10242. */
  10243. _prepare(): void;
  10244. /**
  10245. * Internal only - manager for action
  10246. * @hidden
  10247. */
  10248. _actionManager: AbstractActionManager;
  10249. /**
  10250. * Adds action to chain of actions, may be a DoNothingAction
  10251. * @param action defines the next action to execute
  10252. * @returns The action passed in
  10253. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10254. */
  10255. then(action: IAction): IAction;
  10256. }
  10257. /**
  10258. * The action to be carried out following a trigger
  10259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10260. */
  10261. export class Action implements IAction {
  10262. /** the trigger, with or without parameters, for the action */
  10263. triggerOptions: any;
  10264. /**
  10265. * Trigger for the action
  10266. */
  10267. trigger: number;
  10268. /**
  10269. * Internal only - manager for action
  10270. * @hidden
  10271. */
  10272. _actionManager: ActionManager;
  10273. private _nextActiveAction;
  10274. private _child;
  10275. private _condition?;
  10276. private _triggerParameter;
  10277. /**
  10278. * An event triggered prior to action being executed.
  10279. */
  10280. onBeforeExecuteObservable: Observable<Action>;
  10281. /**
  10282. * Creates a new Action
  10283. * @param triggerOptions the trigger, with or without parameters, for the action
  10284. * @param condition an optional determinant of action
  10285. */
  10286. constructor(
  10287. /** the trigger, with or without parameters, for the action */
  10288. triggerOptions: any, condition?: Condition);
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _prepare(): void;
  10294. /**
  10295. * Gets the trigger parameters
  10296. * @returns the trigger parameters
  10297. */
  10298. getTriggerParameter(): any;
  10299. /**
  10300. * Internal only - executes current action event
  10301. * @hidden
  10302. */
  10303. _executeCurrent(evt?: ActionEvent): void;
  10304. /**
  10305. * Execute placeholder for child classes
  10306. * @param evt optional action event
  10307. */
  10308. execute(evt?: ActionEvent): void;
  10309. /**
  10310. * Skips to next active action
  10311. */
  10312. skipToNextActiveAction(): void;
  10313. /**
  10314. * Adds action to chain of actions, may be a DoNothingAction
  10315. * @param action defines the next action to execute
  10316. * @returns The action passed in
  10317. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10318. */
  10319. then(action: Action): Action;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. _getProperty(propertyPath: string): string;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. _getEffectiveTarget(target: any, propertyPath: string): any;
  10330. /**
  10331. * Serialize placeholder for child classes
  10332. * @param parent of child
  10333. * @returns the serialized object
  10334. */
  10335. serialize(parent: any): any;
  10336. /**
  10337. * Internal only called by serialize
  10338. * @hidden
  10339. */
  10340. protected _serialize(serializedAction: any, parent?: any): any;
  10341. /**
  10342. * Internal only
  10343. * @hidden
  10344. */
  10345. static _SerializeValueAsString: (value: any) => string;
  10346. /**
  10347. * Internal only
  10348. * @hidden
  10349. */
  10350. static _GetTargetProperty: (target: Node | Scene) => {
  10351. name: string;
  10352. targetType: string;
  10353. value: string;
  10354. };
  10355. }
  10356. }
  10357. declare module BABYLON {
  10358. /**
  10359. * A Condition applied to an Action
  10360. */
  10361. export class Condition {
  10362. /**
  10363. * Internal only - manager for action
  10364. * @hidden
  10365. */
  10366. _actionManager: ActionManager;
  10367. /**
  10368. * Internal only
  10369. * @hidden
  10370. */
  10371. _evaluationId: number;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. _currentResult: boolean;
  10377. /**
  10378. * Creates a new Condition
  10379. * @param actionManager the manager of the action the condition is applied to
  10380. */
  10381. constructor(actionManager: ActionManager);
  10382. /**
  10383. * Check if the current condition is valid
  10384. * @returns a boolean
  10385. */
  10386. isValid(): boolean;
  10387. /**
  10388. * Internal only
  10389. * @hidden
  10390. */
  10391. _getProperty(propertyPath: string): string;
  10392. /**
  10393. * Internal only
  10394. * @hidden
  10395. */
  10396. _getEffectiveTarget(target: any, propertyPath: string): any;
  10397. /**
  10398. * Serialize placeholder for child classes
  10399. * @returns the serialized object
  10400. */
  10401. serialize(): any;
  10402. /**
  10403. * Internal only
  10404. * @hidden
  10405. */
  10406. protected _serialize(serializedCondition: any): any;
  10407. }
  10408. /**
  10409. * Defines specific conditional operators as extensions of Condition
  10410. */
  10411. export class ValueCondition extends Condition {
  10412. /** path to specify the property of the target the conditional operator uses */
  10413. propertyPath: string;
  10414. /** the value compared by the conditional operator against the current value of the property */
  10415. value: any;
  10416. /** the conditional operator, default ValueCondition.IsEqual */
  10417. operator: number;
  10418. /**
  10419. * Internal only
  10420. * @hidden
  10421. */
  10422. private static _IsEqual;
  10423. /**
  10424. * Internal only
  10425. * @hidden
  10426. */
  10427. private static _IsDifferent;
  10428. /**
  10429. * Internal only
  10430. * @hidden
  10431. */
  10432. private static _IsGreater;
  10433. /**
  10434. * Internal only
  10435. * @hidden
  10436. */
  10437. private static _IsLesser;
  10438. /**
  10439. * returns the number for IsEqual
  10440. */
  10441. static readonly IsEqual: number;
  10442. /**
  10443. * Returns the number for IsDifferent
  10444. */
  10445. static readonly IsDifferent: number;
  10446. /**
  10447. * Returns the number for IsGreater
  10448. */
  10449. static readonly IsGreater: number;
  10450. /**
  10451. * Returns the number for IsLesser
  10452. */
  10453. static readonly IsLesser: number;
  10454. /**
  10455. * Internal only The action manager for the condition
  10456. * @hidden
  10457. */
  10458. _actionManager: ActionManager;
  10459. /**
  10460. * Internal only
  10461. * @hidden
  10462. */
  10463. private _target;
  10464. /**
  10465. * Internal only
  10466. * @hidden
  10467. */
  10468. private _effectiveTarget;
  10469. /**
  10470. * Internal only
  10471. * @hidden
  10472. */
  10473. private _property;
  10474. /**
  10475. * Creates a new ValueCondition
  10476. * @param actionManager manager for the action the condition applies to
  10477. * @param target for the action
  10478. * @param propertyPath path to specify the property of the target the conditional operator uses
  10479. * @param value the value compared by the conditional operator against the current value of the property
  10480. * @param operator the conditional operator, default ValueCondition.IsEqual
  10481. */
  10482. constructor(actionManager: ActionManager, target: any,
  10483. /** path to specify the property of the target the conditional operator uses */
  10484. propertyPath: string,
  10485. /** the value compared by the conditional operator against the current value of the property */
  10486. value: any,
  10487. /** the conditional operator, default ValueCondition.IsEqual */
  10488. operator?: number);
  10489. /**
  10490. * Compares the given value with the property value for the specified conditional operator
  10491. * @returns the result of the comparison
  10492. */
  10493. isValid(): boolean;
  10494. /**
  10495. * Serialize the ValueCondition into a JSON compatible object
  10496. * @returns serialization object
  10497. */
  10498. serialize(): any;
  10499. /**
  10500. * Gets the name of the conditional operator for the ValueCondition
  10501. * @param operator the conditional operator
  10502. * @returns the name
  10503. */
  10504. static GetOperatorName(operator: number): string;
  10505. }
  10506. /**
  10507. * Defines a predicate condition as an extension of Condition
  10508. */
  10509. export class PredicateCondition extends Condition {
  10510. /** defines the predicate function used to validate the condition */
  10511. predicate: () => boolean;
  10512. /**
  10513. * Internal only - manager for action
  10514. * @hidden
  10515. */
  10516. _actionManager: ActionManager;
  10517. /**
  10518. * Creates a new PredicateCondition
  10519. * @param actionManager manager for the action the condition applies to
  10520. * @param predicate defines the predicate function used to validate the condition
  10521. */
  10522. constructor(actionManager: ActionManager,
  10523. /** defines the predicate function used to validate the condition */
  10524. predicate: () => boolean);
  10525. /**
  10526. * @returns the validity of the predicate condition
  10527. */
  10528. isValid(): boolean;
  10529. }
  10530. /**
  10531. * Defines a state condition as an extension of Condition
  10532. */
  10533. export class StateCondition extends Condition {
  10534. /** Value to compare with target state */
  10535. value: string;
  10536. /**
  10537. * Internal only - manager for action
  10538. * @hidden
  10539. */
  10540. _actionManager: ActionManager;
  10541. /**
  10542. * Internal only
  10543. * @hidden
  10544. */
  10545. private _target;
  10546. /**
  10547. * Creates a new StateCondition
  10548. * @param actionManager manager for the action the condition applies to
  10549. * @param target of the condition
  10550. * @param value to compare with target state
  10551. */
  10552. constructor(actionManager: ActionManager, target: any,
  10553. /** Value to compare with target state */
  10554. value: string);
  10555. /**
  10556. * Gets a boolean indicating if the current condition is met
  10557. * @returns the validity of the state
  10558. */
  10559. isValid(): boolean;
  10560. /**
  10561. * Serialize the StateCondition into a JSON compatible object
  10562. * @returns serialization object
  10563. */
  10564. serialize(): any;
  10565. }
  10566. }
  10567. declare module BABYLON {
  10568. /**
  10569. * This defines an action responsible to toggle a boolean once triggered.
  10570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10571. */
  10572. export class SwitchBooleanAction extends Action {
  10573. /**
  10574. * The path to the boolean property in the target object
  10575. */
  10576. propertyPath: string;
  10577. private _target;
  10578. private _effectiveTarget;
  10579. private _property;
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param target defines the object containing the boolean
  10584. * @param propertyPath defines the path to the boolean property in the target object
  10585. * @param condition defines the trigger related conditions
  10586. */
  10587. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10588. /** @hidden */
  10589. _prepare(): void;
  10590. /**
  10591. * Execute the action toggle the boolean value.
  10592. */
  10593. execute(): void;
  10594. /**
  10595. * Serializes the actions and its related information.
  10596. * @param parent defines the object to serialize in
  10597. * @returns the serialized object
  10598. */
  10599. serialize(parent: any): any;
  10600. }
  10601. /**
  10602. * This defines an action responsible to set a the state field of the target
  10603. * to a desired value once triggered.
  10604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10605. */
  10606. export class SetStateAction extends Action {
  10607. /**
  10608. * The value to store in the state field.
  10609. */
  10610. value: string;
  10611. private _target;
  10612. /**
  10613. * Instantiate the action
  10614. * @param triggerOptions defines the trigger options
  10615. * @param target defines the object containing the state property
  10616. * @param value defines the value to store in the state field
  10617. * @param condition defines the trigger related conditions
  10618. */
  10619. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10620. /**
  10621. * Execute the action and store the value on the target state property.
  10622. */
  10623. execute(): void;
  10624. /**
  10625. * Serializes the actions and its related information.
  10626. * @param parent defines the object to serialize in
  10627. * @returns the serialized object
  10628. */
  10629. serialize(parent: any): any;
  10630. }
  10631. /**
  10632. * This defines an action responsible to set a property of the target
  10633. * to a desired value once triggered.
  10634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10635. */
  10636. export class SetValueAction extends Action {
  10637. /**
  10638. * The path of the property to set in the target.
  10639. */
  10640. propertyPath: string;
  10641. /**
  10642. * The value to set in the property
  10643. */
  10644. value: any;
  10645. private _target;
  10646. private _effectiveTarget;
  10647. private _property;
  10648. /**
  10649. * Instantiate the action
  10650. * @param triggerOptions defines the trigger options
  10651. * @param target defines the object containing the property
  10652. * @param propertyPath defines the path of the property to set in the target
  10653. * @param value defines the value to set in the property
  10654. * @param condition defines the trigger related conditions
  10655. */
  10656. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10657. /** @hidden */
  10658. _prepare(): void;
  10659. /**
  10660. * Execute the action and set the targetted property to the desired value.
  10661. */
  10662. execute(): void;
  10663. /**
  10664. * Serializes the actions and its related information.
  10665. * @param parent defines the object to serialize in
  10666. * @returns the serialized object
  10667. */
  10668. serialize(parent: any): any;
  10669. }
  10670. /**
  10671. * This defines an action responsible to increment the target value
  10672. * to a desired value once triggered.
  10673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10674. */
  10675. export class IncrementValueAction extends Action {
  10676. /**
  10677. * The path of the property to increment in the target.
  10678. */
  10679. propertyPath: string;
  10680. /**
  10681. * The value we should increment the property by.
  10682. */
  10683. value: any;
  10684. private _target;
  10685. private _effectiveTarget;
  10686. private _property;
  10687. /**
  10688. * Instantiate the action
  10689. * @param triggerOptions defines the trigger options
  10690. * @param target defines the object containing the property
  10691. * @param propertyPath defines the path of the property to increment in the target
  10692. * @param value defines the value value we should increment the property by
  10693. * @param condition defines the trigger related conditions
  10694. */
  10695. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10696. /** @hidden */
  10697. _prepare(): void;
  10698. /**
  10699. * Execute the action and increment the target of the value amount.
  10700. */
  10701. execute(): void;
  10702. /**
  10703. * Serializes the actions and its related information.
  10704. * @param parent defines the object to serialize in
  10705. * @returns the serialized object
  10706. */
  10707. serialize(parent: any): any;
  10708. }
  10709. /**
  10710. * This defines an action responsible to start an animation once triggered.
  10711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10712. */
  10713. export class PlayAnimationAction extends Action {
  10714. /**
  10715. * Where the animation should start (animation frame)
  10716. */
  10717. from: number;
  10718. /**
  10719. * Where the animation should stop (animation frame)
  10720. */
  10721. to: number;
  10722. /**
  10723. * Define if the animation should loop or stop after the first play.
  10724. */
  10725. loop?: boolean;
  10726. private _target;
  10727. /**
  10728. * Instantiate the action
  10729. * @param triggerOptions defines the trigger options
  10730. * @param target defines the target animation or animation name
  10731. * @param from defines from where the animation should start (animation frame)
  10732. * @param end defines where the animation should stop (animation frame)
  10733. * @param loop defines if the animation should loop or stop after the first play
  10734. * @param condition defines the trigger related conditions
  10735. */
  10736. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10737. /** @hidden */
  10738. _prepare(): void;
  10739. /**
  10740. * Execute the action and play the animation.
  10741. */
  10742. execute(): void;
  10743. /**
  10744. * Serializes the actions and its related information.
  10745. * @param parent defines the object to serialize in
  10746. * @returns the serialized object
  10747. */
  10748. serialize(parent: any): any;
  10749. }
  10750. /**
  10751. * This defines an action responsible to stop an animation once triggered.
  10752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10753. */
  10754. export class StopAnimationAction extends Action {
  10755. private _target;
  10756. /**
  10757. * Instantiate the action
  10758. * @param triggerOptions defines the trigger options
  10759. * @param target defines the target animation or animation name
  10760. * @param condition defines the trigger related conditions
  10761. */
  10762. constructor(triggerOptions: any, target: any, condition?: Condition);
  10763. /** @hidden */
  10764. _prepare(): void;
  10765. /**
  10766. * Execute the action and stop the animation.
  10767. */
  10768. execute(): void;
  10769. /**
  10770. * Serializes the actions and its related information.
  10771. * @param parent defines the object to serialize in
  10772. * @returns the serialized object
  10773. */
  10774. serialize(parent: any): any;
  10775. }
  10776. /**
  10777. * This defines an action responsible that does nothing once triggered.
  10778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10779. */
  10780. export class DoNothingAction extends Action {
  10781. /**
  10782. * Instantiate the action
  10783. * @param triggerOptions defines the trigger options
  10784. * @param condition defines the trigger related conditions
  10785. */
  10786. constructor(triggerOptions?: any, condition?: Condition);
  10787. /**
  10788. * Execute the action and do nothing.
  10789. */
  10790. execute(): void;
  10791. /**
  10792. * Serializes the actions and its related information.
  10793. * @param parent defines the object to serialize in
  10794. * @returns the serialized object
  10795. */
  10796. serialize(parent: any): any;
  10797. }
  10798. /**
  10799. * This defines an action responsible to trigger several actions once triggered.
  10800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10801. */
  10802. export class CombineAction extends Action {
  10803. /**
  10804. * The list of aggregated animations to run.
  10805. */
  10806. children: Action[];
  10807. /**
  10808. * Instantiate the action
  10809. * @param triggerOptions defines the trigger options
  10810. * @param children defines the list of aggregated animations to run
  10811. * @param condition defines the trigger related conditions
  10812. */
  10813. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10814. /** @hidden */
  10815. _prepare(): void;
  10816. /**
  10817. * Execute the action and executes all the aggregated actions.
  10818. */
  10819. execute(evt: ActionEvent): void;
  10820. /**
  10821. * Serializes the actions and its related information.
  10822. * @param parent defines the object to serialize in
  10823. * @returns the serialized object
  10824. */
  10825. serialize(parent: any): any;
  10826. }
  10827. /**
  10828. * This defines an action responsible to run code (external event) once triggered.
  10829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10830. */
  10831. export class ExecuteCodeAction extends Action {
  10832. /**
  10833. * The callback function to run.
  10834. */
  10835. func: (evt: ActionEvent) => void;
  10836. /**
  10837. * Instantiate the action
  10838. * @param triggerOptions defines the trigger options
  10839. * @param func defines the callback function to run
  10840. * @param condition defines the trigger related conditions
  10841. */
  10842. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10843. /**
  10844. * Execute the action and run the attached code.
  10845. */
  10846. execute(evt: ActionEvent): void;
  10847. }
  10848. /**
  10849. * This defines an action responsible to set the parent property of the target once triggered.
  10850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10851. */
  10852. export class SetParentAction extends Action {
  10853. private _parent;
  10854. private _target;
  10855. /**
  10856. * Instantiate the action
  10857. * @param triggerOptions defines the trigger options
  10858. * @param target defines the target containing the parent property
  10859. * @param parent defines from where the animation should start (animation frame)
  10860. * @param condition defines the trigger related conditions
  10861. */
  10862. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10863. /** @hidden */
  10864. _prepare(): void;
  10865. /**
  10866. * Execute the action and set the parent property.
  10867. */
  10868. execute(): void;
  10869. /**
  10870. * Serializes the actions and its related information.
  10871. * @param parent defines the object to serialize in
  10872. * @returns the serialized object
  10873. */
  10874. serialize(parent: any): any;
  10875. }
  10876. }
  10877. declare module BABYLON {
  10878. /**
  10879. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10880. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10882. */
  10883. export class ActionManager extends AbstractActionManager {
  10884. /**
  10885. * Nothing
  10886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10887. */
  10888. static readonly NothingTrigger: number;
  10889. /**
  10890. * On pick
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10892. */
  10893. static readonly OnPickTrigger: number;
  10894. /**
  10895. * On left pick
  10896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10897. */
  10898. static readonly OnLeftPickTrigger: number;
  10899. /**
  10900. * On right pick
  10901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10902. */
  10903. static readonly OnRightPickTrigger: number;
  10904. /**
  10905. * On center pick
  10906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10907. */
  10908. static readonly OnCenterPickTrigger: number;
  10909. /**
  10910. * On pick down
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10912. */
  10913. static readonly OnPickDownTrigger: number;
  10914. /**
  10915. * On double pick
  10916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10917. */
  10918. static readonly OnDoublePickTrigger: number;
  10919. /**
  10920. * On pick up
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10922. */
  10923. static readonly OnPickUpTrigger: number;
  10924. /**
  10925. * On pick out.
  10926. * This trigger will only be raised if you also declared a OnPickDown
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10928. */
  10929. static readonly OnPickOutTrigger: number;
  10930. /**
  10931. * On long press
  10932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10933. */
  10934. static readonly OnLongPressTrigger: number;
  10935. /**
  10936. * On pointer over
  10937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10938. */
  10939. static readonly OnPointerOverTrigger: number;
  10940. /**
  10941. * On pointer out
  10942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10943. */
  10944. static readonly OnPointerOutTrigger: number;
  10945. /**
  10946. * On every frame
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10948. */
  10949. static readonly OnEveryFrameTrigger: number;
  10950. /**
  10951. * On intersection enter
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10953. */
  10954. static readonly OnIntersectionEnterTrigger: number;
  10955. /**
  10956. * On intersection exit
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10958. */
  10959. static readonly OnIntersectionExitTrigger: number;
  10960. /**
  10961. * On key down
  10962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10963. */
  10964. static readonly OnKeyDownTrigger: number;
  10965. /**
  10966. * On key up
  10967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10968. */
  10969. static readonly OnKeyUpTrigger: number;
  10970. private _scene;
  10971. /**
  10972. * Creates a new action manager
  10973. * @param scene defines the hosting scene
  10974. */
  10975. constructor(scene: Scene);
  10976. /**
  10977. * Releases all associated resources
  10978. */
  10979. dispose(): void;
  10980. /**
  10981. * Gets hosting scene
  10982. * @returns the hosting scene
  10983. */
  10984. getScene(): Scene;
  10985. /**
  10986. * Does this action manager handles actions of any of the given triggers
  10987. * @param triggers defines the triggers to be tested
  10988. * @return a boolean indicating whether one (or more) of the triggers is handled
  10989. */
  10990. hasSpecificTriggers(triggers: number[]): boolean;
  10991. /**
  10992. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10993. * speed.
  10994. * @param triggerA defines the trigger to be tested
  10995. * @param triggerB defines the trigger to be tested
  10996. * @return a boolean indicating whether one (or more) of the triggers is handled
  10997. */
  10998. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10999. /**
  11000. * Does this action manager handles actions of a given trigger
  11001. * @param trigger defines the trigger to be tested
  11002. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11003. * @return whether the trigger is handled
  11004. */
  11005. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11006. /**
  11007. * Does this action manager has pointer triggers
  11008. */
  11009. readonly hasPointerTriggers: boolean;
  11010. /**
  11011. * Does this action manager has pick triggers
  11012. */
  11013. readonly hasPickTriggers: boolean;
  11014. /**
  11015. * Registers an action to this action manager
  11016. * @param action defines the action to be registered
  11017. * @return the action amended (prepared) after registration
  11018. */
  11019. registerAction(action: IAction): Nullable<IAction>;
  11020. /**
  11021. * Unregisters an action to this action manager
  11022. * @param action defines the action to be unregistered
  11023. * @return a boolean indicating whether the action has been unregistered
  11024. */
  11025. unregisterAction(action: IAction): Boolean;
  11026. /**
  11027. * Process a specific trigger
  11028. * @param trigger defines the trigger to process
  11029. * @param evt defines the event details to be processed
  11030. */
  11031. processTrigger(trigger: number, evt?: IActionEvent): void;
  11032. /** @hidden */
  11033. _getEffectiveTarget(target: any, propertyPath: string): any;
  11034. /** @hidden */
  11035. _getProperty(propertyPath: string): string;
  11036. /**
  11037. * Serialize this manager to a JSON object
  11038. * @param name defines the property name to store this manager
  11039. * @returns a JSON representation of this manager
  11040. */
  11041. serialize(name: string): any;
  11042. /**
  11043. * Creates a new ActionManager from a JSON data
  11044. * @param parsedActions defines the JSON data to read from
  11045. * @param object defines the hosting mesh
  11046. * @param scene defines the hosting scene
  11047. */
  11048. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11049. /**
  11050. * Get a trigger name by index
  11051. * @param trigger defines the trigger index
  11052. * @returns a trigger name
  11053. */
  11054. static GetTriggerName(trigger: number): string;
  11055. }
  11056. }
  11057. declare module BABYLON {
  11058. /**
  11059. * Class representing a ray with position and direction
  11060. */
  11061. export class Ray {
  11062. /** origin point */
  11063. origin: Vector3;
  11064. /** direction */
  11065. direction: Vector3;
  11066. /** length of the ray */
  11067. length: number;
  11068. private static readonly TmpVector3;
  11069. private _tmpRay;
  11070. /**
  11071. * Creates a new ray
  11072. * @param origin origin point
  11073. * @param direction direction
  11074. * @param length length of the ray
  11075. */
  11076. constructor(
  11077. /** origin point */
  11078. origin: Vector3,
  11079. /** direction */
  11080. direction: Vector3,
  11081. /** length of the ray */
  11082. length?: number);
  11083. /**
  11084. * Checks if the ray intersects a box
  11085. * @param minimum bound of the box
  11086. * @param maximum bound of the box
  11087. * @param intersectionTreshold extra extend to be added to the box in all direction
  11088. * @returns if the box was hit
  11089. */
  11090. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11091. /**
  11092. * Checks if the ray intersects a box
  11093. * @param box the bounding box to check
  11094. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11095. * @returns if the box was hit
  11096. */
  11097. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11098. /**
  11099. * If the ray hits a sphere
  11100. * @param sphere the bounding sphere to check
  11101. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11102. * @returns true if it hits the sphere
  11103. */
  11104. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11105. /**
  11106. * If the ray hits a triange
  11107. * @param vertex0 triangle vertex
  11108. * @param vertex1 triangle vertex
  11109. * @param vertex2 triangle vertex
  11110. * @returns intersection information if hit
  11111. */
  11112. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11113. /**
  11114. * Checks if ray intersects a plane
  11115. * @param plane the plane to check
  11116. * @returns the distance away it was hit
  11117. */
  11118. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11119. /**
  11120. * Calculate the intercept of a ray on a given axis
  11121. * @param axis to check 'x' | 'y' | 'z'
  11122. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11123. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11124. */
  11125. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11126. /**
  11127. * Checks if ray intersects a mesh
  11128. * @param mesh the mesh to check
  11129. * @param fastCheck if only the bounding box should checked
  11130. * @returns picking info of the intersecton
  11131. */
  11132. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11133. /**
  11134. * Checks if ray intersects a mesh
  11135. * @param meshes the meshes to check
  11136. * @param fastCheck if only the bounding box should checked
  11137. * @param results array to store result in
  11138. * @returns Array of picking infos
  11139. */
  11140. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11141. private _comparePickingInfo;
  11142. private static smallnum;
  11143. private static rayl;
  11144. /**
  11145. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11146. * @param sega the first point of the segment to test the intersection against
  11147. * @param segb the second point of the segment to test the intersection against
  11148. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11149. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11150. */
  11151. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11152. /**
  11153. * Update the ray from viewport position
  11154. * @param x position
  11155. * @param y y position
  11156. * @param viewportWidth viewport width
  11157. * @param viewportHeight viewport height
  11158. * @param world world matrix
  11159. * @param view view matrix
  11160. * @param projection projection matrix
  11161. * @returns this ray updated
  11162. */
  11163. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11164. /**
  11165. * Creates a ray with origin and direction of 0,0,0
  11166. * @returns the new ray
  11167. */
  11168. static Zero(): Ray;
  11169. /**
  11170. * Creates a new ray from screen space and viewport
  11171. * @param x position
  11172. * @param y y position
  11173. * @param viewportWidth viewport width
  11174. * @param viewportHeight viewport height
  11175. * @param world world matrix
  11176. * @param view view matrix
  11177. * @param projection projection matrix
  11178. * @returns new ray
  11179. */
  11180. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11181. /**
  11182. * 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
  11183. * transformed to the given world matrix.
  11184. * @param origin The origin point
  11185. * @param end The end point
  11186. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11187. * @returns the new ray
  11188. */
  11189. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11190. /**
  11191. * Transforms a ray by a matrix
  11192. * @param ray ray to transform
  11193. * @param matrix matrix to apply
  11194. * @returns the resulting new ray
  11195. */
  11196. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11197. /**
  11198. * Transforms a ray by a matrix
  11199. * @param ray ray to transform
  11200. * @param matrix matrix to apply
  11201. * @param result ray to store result in
  11202. */
  11203. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11204. /**
  11205. * Unproject a ray from screen space to object space
  11206. * @param sourceX defines the screen space x coordinate to use
  11207. * @param sourceY defines the screen space y coordinate to use
  11208. * @param viewportWidth defines the current width of the viewport
  11209. * @param viewportHeight defines the current height of the viewport
  11210. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11211. * @param view defines the view matrix to use
  11212. * @param projection defines the projection matrix to use
  11213. */
  11214. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11215. }
  11216. /**
  11217. * Type used to define predicate used to select faces when a mesh intersection is detected
  11218. */
  11219. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11220. interface Scene {
  11221. /** @hidden */
  11222. _tempPickingRay: Nullable<Ray>;
  11223. /** @hidden */
  11224. _cachedRayForTransform: Ray;
  11225. /** @hidden */
  11226. _pickWithRayInverseMatrix: Matrix;
  11227. /** @hidden */
  11228. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11229. /** @hidden */
  11230. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11231. }
  11232. }
  11233. declare module BABYLON {
  11234. /**
  11235. * Groups all the scene component constants in one place to ease maintenance.
  11236. * @hidden
  11237. */
  11238. export class SceneComponentConstants {
  11239. static readonly NAME_EFFECTLAYER: string;
  11240. static readonly NAME_LAYER: string;
  11241. static readonly NAME_LENSFLARESYSTEM: string;
  11242. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11243. static readonly NAME_PARTICLESYSTEM: string;
  11244. static readonly NAME_GAMEPAD: string;
  11245. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11246. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11247. static readonly NAME_DEPTHRENDERER: string;
  11248. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11249. static readonly NAME_SPRITE: string;
  11250. static readonly NAME_OUTLINERENDERER: string;
  11251. static readonly NAME_PROCEDURALTEXTURE: string;
  11252. static readonly NAME_SHADOWGENERATOR: string;
  11253. static readonly NAME_OCTREE: string;
  11254. static readonly NAME_PHYSICSENGINE: string;
  11255. static readonly NAME_AUDIO: string;
  11256. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11257. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11258. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11259. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11260. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11261. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11262. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11263. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11264. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11265. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11266. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11267. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11268. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11269. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11270. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11271. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11272. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11273. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11274. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11275. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11276. static readonly STEP_AFTERRENDER_AUDIO: number;
  11277. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11278. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11279. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11280. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11281. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11282. static readonly STEP_POINTERMOVE_SPRITE: number;
  11283. static readonly STEP_POINTERDOWN_SPRITE: number;
  11284. static readonly STEP_POINTERUP_SPRITE: number;
  11285. }
  11286. /**
  11287. * This represents a scene component.
  11288. *
  11289. * This is used to decouple the dependency the scene is having on the different workloads like
  11290. * layers, post processes...
  11291. */
  11292. export interface ISceneComponent {
  11293. /**
  11294. * The name of the component. Each component must have a unique name.
  11295. */
  11296. name: string;
  11297. /**
  11298. * The scene the component belongs to.
  11299. */
  11300. scene: Scene;
  11301. /**
  11302. * Register the component to one instance of a scene.
  11303. */
  11304. register(): void;
  11305. /**
  11306. * Rebuilds the elements related to this component in case of
  11307. * context lost for instance.
  11308. */
  11309. rebuild(): void;
  11310. /**
  11311. * Disposes the component and the associated ressources.
  11312. */
  11313. dispose(): void;
  11314. }
  11315. /**
  11316. * This represents a SERIALIZABLE scene component.
  11317. *
  11318. * This extends Scene Component to add Serialization methods on top.
  11319. */
  11320. export interface ISceneSerializableComponent extends ISceneComponent {
  11321. /**
  11322. * Adds all the elements from the container to the scene
  11323. * @param container the container holding the elements
  11324. */
  11325. addFromContainer(container: AbstractScene): void;
  11326. /**
  11327. * Removes all the elements in the container from the scene
  11328. * @param container contains the elements to remove
  11329. * @param dispose if the removed element should be disposed (default: false)
  11330. */
  11331. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11332. /**
  11333. * Serializes the component data to the specified json object
  11334. * @param serializationObject The object to serialize to
  11335. */
  11336. serialize(serializationObject: any): void;
  11337. }
  11338. /**
  11339. * Strong typing of a Mesh related stage step action
  11340. */
  11341. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11342. /**
  11343. * Strong typing of a Evaluate Sub Mesh related stage step action
  11344. */
  11345. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11346. /**
  11347. * Strong typing of a Active Mesh related stage step action
  11348. */
  11349. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11350. /**
  11351. * Strong typing of a Camera related stage step action
  11352. */
  11353. export type CameraStageAction = (camera: Camera) => void;
  11354. /**
  11355. * Strong typing of a Camera Frame buffer related stage step action
  11356. */
  11357. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11358. /**
  11359. * Strong typing of a Render Target related stage step action
  11360. */
  11361. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11362. /**
  11363. * Strong typing of a RenderingGroup related stage step action
  11364. */
  11365. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11366. /**
  11367. * Strong typing of a Mesh Render related stage step action
  11368. */
  11369. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11370. /**
  11371. * Strong typing of a simple stage step action
  11372. */
  11373. export type SimpleStageAction = () => void;
  11374. /**
  11375. * Strong typing of a render target action.
  11376. */
  11377. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11378. /**
  11379. * Strong typing of a pointer move action.
  11380. */
  11381. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11382. /**
  11383. * Strong typing of a pointer up/down action.
  11384. */
  11385. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11386. /**
  11387. * Representation of a stage in the scene (Basically a list of ordered steps)
  11388. * @hidden
  11389. */
  11390. export class Stage<T extends Function> extends Array<{
  11391. index: number;
  11392. component: ISceneComponent;
  11393. action: T;
  11394. }> {
  11395. /**
  11396. * Hide ctor from the rest of the world.
  11397. * @param items The items to add.
  11398. */
  11399. private constructor();
  11400. /**
  11401. * Creates a new Stage.
  11402. * @returns A new instance of a Stage
  11403. */
  11404. static Create<T extends Function>(): Stage<T>;
  11405. /**
  11406. * Registers a step in an ordered way in the targeted stage.
  11407. * @param index Defines the position to register the step in
  11408. * @param component Defines the component attached to the step
  11409. * @param action Defines the action to launch during the step
  11410. */
  11411. registerStep(index: number, component: ISceneComponent, action: T): void;
  11412. /**
  11413. * Clears all the steps from the stage.
  11414. */
  11415. clear(): void;
  11416. }
  11417. }
  11418. declare module BABYLON {
  11419. interface Scene {
  11420. /** @hidden */
  11421. _pointerOverSprite: Nullable<Sprite>;
  11422. /** @hidden */
  11423. _pickedDownSprite: Nullable<Sprite>;
  11424. /** @hidden */
  11425. _tempSpritePickingRay: Nullable<Ray>;
  11426. /**
  11427. * All of the sprite managers added to this scene
  11428. * @see http://doc.babylonjs.com/babylon101/sprites
  11429. */
  11430. spriteManagers: Array<ISpriteManager>;
  11431. /**
  11432. * An event triggered when sprites rendering is about to start
  11433. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11434. */
  11435. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11436. /**
  11437. * An event triggered when sprites rendering is done
  11438. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11439. */
  11440. onAfterSpritesRenderingObservable: Observable<Scene>;
  11441. /** @hidden */
  11442. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11443. /** Launch a ray to try to pick a sprite in the scene
  11444. * @param x position on screen
  11445. * @param y position on screen
  11446. * @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
  11447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11448. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11449. * @returns a PickingInfo
  11450. */
  11451. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11452. /** Use the given ray to pick a sprite in the scene
  11453. * @param ray The ray (in world space) to use to pick meshes
  11454. * @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
  11455. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11456. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11457. * @returns a PickingInfo
  11458. */
  11459. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11460. /** @hidden */
  11461. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11462. /** Launch a ray to try to pick sprites in the scene
  11463. * @param x position on screen
  11464. * @param y position on screen
  11465. * @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
  11466. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11467. * @returns a PickingInfo array
  11468. */
  11469. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11470. /** Use the given ray to pick sprites in the scene
  11471. * @param ray The ray (in world space) to use to pick meshes
  11472. * @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
  11473. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11474. * @returns a PickingInfo array
  11475. */
  11476. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11477. /**
  11478. * Force the sprite under the pointer
  11479. * @param sprite defines the sprite to use
  11480. */
  11481. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11482. /**
  11483. * Gets the sprite under the pointer
  11484. * @returns a Sprite or null if no sprite is under the pointer
  11485. */
  11486. getPointerOverSprite(): Nullable<Sprite>;
  11487. }
  11488. /**
  11489. * Defines the sprite scene component responsible to manage sprites
  11490. * in a given scene.
  11491. */
  11492. export class SpriteSceneComponent implements ISceneComponent {
  11493. /**
  11494. * The component name helpfull to identify the component in the list of scene components.
  11495. */
  11496. readonly name: string;
  11497. /**
  11498. * The scene the component belongs to.
  11499. */
  11500. scene: Scene;
  11501. /** @hidden */
  11502. private _spritePredicate;
  11503. /**
  11504. * Creates a new instance of the component for the given scene
  11505. * @param scene Defines the scene to register the component in
  11506. */
  11507. constructor(scene: Scene);
  11508. /**
  11509. * Registers the component in a given scene
  11510. */
  11511. register(): void;
  11512. /**
  11513. * Rebuilds the elements related to this component in case of
  11514. * context lost for instance.
  11515. */
  11516. rebuild(): void;
  11517. /**
  11518. * Disposes the component and the associated ressources.
  11519. */
  11520. dispose(): void;
  11521. private _pickSpriteButKeepRay;
  11522. private _pointerMove;
  11523. private _pointerDown;
  11524. private _pointerUp;
  11525. }
  11526. }
  11527. declare module BABYLON {
  11528. /** @hidden */
  11529. export var fogFragmentDeclaration: {
  11530. name: string;
  11531. shader: string;
  11532. };
  11533. }
  11534. declare module BABYLON {
  11535. /** @hidden */
  11536. export var fogFragment: {
  11537. name: string;
  11538. shader: string;
  11539. };
  11540. }
  11541. declare module BABYLON {
  11542. /** @hidden */
  11543. export var spritesPixelShader: {
  11544. name: string;
  11545. shader: string;
  11546. };
  11547. }
  11548. declare module BABYLON {
  11549. /** @hidden */
  11550. export var fogVertexDeclaration: {
  11551. name: string;
  11552. shader: string;
  11553. };
  11554. }
  11555. declare module BABYLON {
  11556. /** @hidden */
  11557. export var spritesVertexShader: {
  11558. name: string;
  11559. shader: string;
  11560. };
  11561. }
  11562. declare module BABYLON {
  11563. /**
  11564. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11565. */
  11566. export interface ISpriteManager extends IDisposable {
  11567. /**
  11568. * Restricts the camera to viewing objects with the same layerMask.
  11569. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11570. */
  11571. layerMask: number;
  11572. /**
  11573. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11574. */
  11575. isPickable: boolean;
  11576. /**
  11577. * Specifies the rendering group id for this mesh (0 by default)
  11578. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11579. */
  11580. renderingGroupId: number;
  11581. /**
  11582. * Defines the list of sprites managed by the manager.
  11583. */
  11584. sprites: Array<Sprite>;
  11585. /**
  11586. * Tests the intersection of a sprite with a specific ray.
  11587. * @param ray The ray we are sending to test the collision
  11588. * @param camera The camera space we are sending rays in
  11589. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11590. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11591. * @returns picking info or null.
  11592. */
  11593. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11594. /**
  11595. * Intersects the sprites with a ray
  11596. * @param ray defines the ray to intersect with
  11597. * @param camera defines the current active camera
  11598. * @param predicate defines a predicate used to select candidate sprites
  11599. * @returns null if no hit or a PickingInfo array
  11600. */
  11601. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11602. /**
  11603. * Renders the list of sprites on screen.
  11604. */
  11605. render(): void;
  11606. }
  11607. /**
  11608. * Class used to manage multiple sprites on the same spritesheet
  11609. * @see http://doc.babylonjs.com/babylon101/sprites
  11610. */
  11611. export class SpriteManager implements ISpriteManager {
  11612. /** defines the manager's name */
  11613. name: string;
  11614. /** Gets the list of sprites */
  11615. sprites: Sprite[];
  11616. /** Gets or sets the rendering group id (0 by default) */
  11617. renderingGroupId: number;
  11618. /** Gets or sets camera layer mask */
  11619. layerMask: number;
  11620. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11621. fogEnabled: boolean;
  11622. /** Gets or sets a boolean indicating if the sprites are pickable */
  11623. isPickable: boolean;
  11624. /** Defines the default width of a cell in the spritesheet */
  11625. cellWidth: number;
  11626. /** Defines the default height of a cell in the spritesheet */
  11627. cellHeight: number;
  11628. /** Associative array from JSON sprite data file */
  11629. private _cellData;
  11630. /** Array of sprite names from JSON sprite data file */
  11631. private _spriteMap;
  11632. /** True when packed cell data from JSON file is ready*/
  11633. private _packedAndReady;
  11634. /**
  11635. * An event triggered when the manager is disposed.
  11636. */
  11637. onDisposeObservable: Observable<SpriteManager>;
  11638. private _onDisposeObserver;
  11639. /**
  11640. * Callback called when the manager is disposed
  11641. */
  11642. onDispose: () => void;
  11643. private _capacity;
  11644. private _fromPacked;
  11645. private _spriteTexture;
  11646. private _epsilon;
  11647. private _scene;
  11648. private _vertexData;
  11649. private _buffer;
  11650. private _vertexBuffers;
  11651. private _indexBuffer;
  11652. private _effectBase;
  11653. private _effectFog;
  11654. /**
  11655. * Gets or sets the spritesheet texture
  11656. */
  11657. texture: Texture;
  11658. /**
  11659. * Creates a new sprite manager
  11660. * @param name defines the manager's name
  11661. * @param imgUrl defines the sprite sheet url
  11662. * @param capacity defines the maximum allowed number of sprites
  11663. * @param cellSize defines the size of a sprite cell
  11664. * @param scene defines the hosting scene
  11665. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11666. * @param samplingMode defines the smapling mode to use with spritesheet
  11667. * @param fromPacked set to false; do not alter
  11668. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11669. */
  11670. constructor(
  11671. /** defines the manager's name */
  11672. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11673. private _makePacked;
  11674. private _appendSpriteVertex;
  11675. /**
  11676. * Intersects the sprites with a ray
  11677. * @param ray defines the ray to intersect with
  11678. * @param camera defines the current active camera
  11679. * @param predicate defines a predicate used to select candidate sprites
  11680. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11681. * @returns null if no hit or a PickingInfo
  11682. */
  11683. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11684. /**
  11685. * Intersects the sprites with a ray
  11686. * @param ray defines the ray to intersect with
  11687. * @param camera defines the current active camera
  11688. * @param predicate defines a predicate used to select candidate sprites
  11689. * @returns null if no hit or a PickingInfo array
  11690. */
  11691. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11692. /**
  11693. * Render all child sprites
  11694. */
  11695. render(): void;
  11696. /**
  11697. * Release associated resources
  11698. */
  11699. dispose(): void;
  11700. }
  11701. }
  11702. declare module BABYLON {
  11703. /**
  11704. * Class used to represent a sprite
  11705. * @see http://doc.babylonjs.com/babylon101/sprites
  11706. */
  11707. export class Sprite {
  11708. /** defines the name */
  11709. name: string;
  11710. /** Gets or sets the current world position */
  11711. position: Vector3;
  11712. /** Gets or sets the main color */
  11713. color: Color4;
  11714. /** Gets or sets the width */
  11715. width: number;
  11716. /** Gets or sets the height */
  11717. height: number;
  11718. /** Gets or sets rotation angle */
  11719. angle: number;
  11720. /** Gets or sets the cell index in the sprite sheet */
  11721. cellIndex: number;
  11722. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11723. cellRef: string;
  11724. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11725. invertU: number;
  11726. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11727. invertV: number;
  11728. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11729. disposeWhenFinishedAnimating: boolean;
  11730. /** Gets the list of attached animations */
  11731. animations: Animation[];
  11732. /** Gets or sets a boolean indicating if the sprite can be picked */
  11733. isPickable: boolean;
  11734. /**
  11735. * Gets or sets the associated action manager
  11736. */
  11737. actionManager: Nullable<ActionManager>;
  11738. private _animationStarted;
  11739. private _loopAnimation;
  11740. private _fromIndex;
  11741. private _toIndex;
  11742. private _delay;
  11743. private _direction;
  11744. private _manager;
  11745. private _time;
  11746. private _onAnimationEnd;
  11747. /**
  11748. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11749. */
  11750. isVisible: boolean;
  11751. /**
  11752. * Gets or sets the sprite size
  11753. */
  11754. size: number;
  11755. /**
  11756. * Creates a new Sprite
  11757. * @param name defines the name
  11758. * @param manager defines the manager
  11759. */
  11760. constructor(
  11761. /** defines the name */
  11762. name: string, manager: ISpriteManager);
  11763. /**
  11764. * Starts an animation
  11765. * @param from defines the initial key
  11766. * @param to defines the end key
  11767. * @param loop defines if the animation must loop
  11768. * @param delay defines the start delay (in ms)
  11769. * @param onAnimationEnd defines a callback to call when animation ends
  11770. */
  11771. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11772. /** Stops current animation (if any) */
  11773. stopAnimation(): void;
  11774. /** @hidden */
  11775. _animate(deltaTime: number): void;
  11776. /** Release associated resources */
  11777. dispose(): void;
  11778. }
  11779. }
  11780. declare module BABYLON {
  11781. /**
  11782. * Information about the result of picking within a scene
  11783. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11784. */
  11785. export class PickingInfo {
  11786. /** @hidden */
  11787. _pickingUnavailable: boolean;
  11788. /**
  11789. * If the pick collided with an object
  11790. */
  11791. hit: boolean;
  11792. /**
  11793. * Distance away where the pick collided
  11794. */
  11795. distance: number;
  11796. /**
  11797. * The location of pick collision
  11798. */
  11799. pickedPoint: Nullable<Vector3>;
  11800. /**
  11801. * The mesh corresponding the the pick collision
  11802. */
  11803. pickedMesh: Nullable<AbstractMesh>;
  11804. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11805. bu: number;
  11806. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11807. bv: number;
  11808. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11809. faceId: number;
  11810. /** Id of the the submesh that was picked */
  11811. subMeshId: number;
  11812. /** If a sprite was picked, this will be the sprite the pick collided with */
  11813. pickedSprite: Nullable<Sprite>;
  11814. /**
  11815. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11816. */
  11817. originMesh: Nullable<AbstractMesh>;
  11818. /**
  11819. * The ray that was used to perform the picking.
  11820. */
  11821. ray: Nullable<Ray>;
  11822. /**
  11823. * Gets the normal correspodning to the face the pick collided with
  11824. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11825. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11826. * @returns The normal correspodning to the face the pick collided with
  11827. */
  11828. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11829. /**
  11830. * Gets the texture coordinates of where the pick occured
  11831. * @returns the vector containing the coordnates of the texture
  11832. */
  11833. getTextureCoordinates(): Nullable<Vector2>;
  11834. }
  11835. }
  11836. declare module BABYLON {
  11837. /**
  11838. * Gather the list of pointer event types as constants.
  11839. */
  11840. export class PointerEventTypes {
  11841. /**
  11842. * 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.
  11843. */
  11844. static readonly POINTERDOWN: number;
  11845. /**
  11846. * The pointerup event is fired when a pointer is no longer active.
  11847. */
  11848. static readonly POINTERUP: number;
  11849. /**
  11850. * The pointermove event is fired when a pointer changes coordinates.
  11851. */
  11852. static readonly POINTERMOVE: number;
  11853. /**
  11854. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11855. */
  11856. static readonly POINTERWHEEL: number;
  11857. /**
  11858. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11859. */
  11860. static readonly POINTERPICK: number;
  11861. /**
  11862. * The pointertap event is fired when a the object has been touched and released without drag.
  11863. */
  11864. static readonly POINTERTAP: number;
  11865. /**
  11866. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11867. */
  11868. static readonly POINTERDOUBLETAP: number;
  11869. }
  11870. /**
  11871. * Base class of pointer info types.
  11872. */
  11873. export class PointerInfoBase {
  11874. /**
  11875. * Defines the type of event (PointerEventTypes)
  11876. */
  11877. type: number;
  11878. /**
  11879. * Defines the related dom event
  11880. */
  11881. event: PointerEvent | MouseWheelEvent;
  11882. /**
  11883. * Instantiates the base class of pointers info.
  11884. * @param type Defines the type of event (PointerEventTypes)
  11885. * @param event Defines the related dom event
  11886. */
  11887. constructor(
  11888. /**
  11889. * Defines the type of event (PointerEventTypes)
  11890. */
  11891. type: number,
  11892. /**
  11893. * Defines the related dom event
  11894. */
  11895. event: PointerEvent | MouseWheelEvent);
  11896. }
  11897. /**
  11898. * This class is used to store pointer related info for the onPrePointerObservable event.
  11899. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11900. */
  11901. export class PointerInfoPre extends PointerInfoBase {
  11902. /**
  11903. * Ray from a pointer if availible (eg. 6dof controller)
  11904. */
  11905. ray: Nullable<Ray>;
  11906. /**
  11907. * Defines the local position of the pointer on the canvas.
  11908. */
  11909. localPosition: Vector2;
  11910. /**
  11911. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11912. */
  11913. skipOnPointerObservable: boolean;
  11914. /**
  11915. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11916. * @param type Defines the type of event (PointerEventTypes)
  11917. * @param event Defines the related dom event
  11918. * @param localX Defines the local x coordinates of the pointer when the event occured
  11919. * @param localY Defines the local y coordinates of the pointer when the event occured
  11920. */
  11921. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11922. }
  11923. /**
  11924. * This type contains all the data related to a pointer event in Babylon.js.
  11925. * 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.
  11926. */
  11927. export class PointerInfo extends PointerInfoBase {
  11928. /**
  11929. * Defines the picking info associated to the info (if any)\
  11930. */
  11931. pickInfo: Nullable<PickingInfo>;
  11932. /**
  11933. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11934. * @param type Defines the type of event (PointerEventTypes)
  11935. * @param event Defines the related dom event
  11936. * @param pickInfo Defines the picking info associated to the info (if any)\
  11937. */
  11938. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11939. /**
  11940. * Defines the picking info associated to the info (if any)\
  11941. */
  11942. pickInfo: Nullable<PickingInfo>);
  11943. }
  11944. /**
  11945. * Data relating to a touch event on the screen.
  11946. */
  11947. export interface PointerTouch {
  11948. /**
  11949. * X coordinate of touch.
  11950. */
  11951. x: number;
  11952. /**
  11953. * Y coordinate of touch.
  11954. */
  11955. y: number;
  11956. /**
  11957. * Id of touch. Unique for each finger.
  11958. */
  11959. pointerId: number;
  11960. /**
  11961. * Event type passed from DOM.
  11962. */
  11963. type: any;
  11964. }
  11965. }
  11966. declare module BABYLON {
  11967. /**
  11968. * Manage the mouse inputs to control the movement of a free camera.
  11969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11970. */
  11971. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11972. /**
  11973. * Define if touch is enabled in the mouse input
  11974. */
  11975. touchEnabled: boolean;
  11976. /**
  11977. * Defines the camera the input is attached to.
  11978. */
  11979. camera: FreeCamera;
  11980. /**
  11981. * Defines the buttons associated with the input to handle camera move.
  11982. */
  11983. buttons: number[];
  11984. /**
  11985. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11986. */
  11987. angularSensibility: number;
  11988. private _pointerInput;
  11989. private _onMouseMove;
  11990. private _observer;
  11991. private previousPosition;
  11992. /**
  11993. * Observable for when a pointer move event occurs containing the move offset
  11994. */
  11995. onPointerMovedObservable: Observable<{
  11996. offsetX: number;
  11997. offsetY: number;
  11998. }>;
  11999. /**
  12000. * @hidden
  12001. * If the camera should be rotated automatically based on pointer movement
  12002. */
  12003. _allowCameraRotation: boolean;
  12004. /**
  12005. * Manage the mouse inputs to control the movement of a free camera.
  12006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12007. * @param touchEnabled Defines if touch is enabled or not
  12008. */
  12009. constructor(
  12010. /**
  12011. * Define if touch is enabled in the mouse input
  12012. */
  12013. touchEnabled?: boolean);
  12014. /**
  12015. * Attach the input controls to a specific dom element to get the input from.
  12016. * @param element Defines the element the controls should be listened from
  12017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12018. */
  12019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12020. /**
  12021. * Called on JS contextmenu event.
  12022. * Override this method to provide functionality.
  12023. */
  12024. protected onContextMenu(evt: PointerEvent): void;
  12025. /**
  12026. * Detach the current controls from the specified dom element.
  12027. * @param element Defines the element to stop listening the inputs from
  12028. */
  12029. detachControl(element: Nullable<HTMLElement>): void;
  12030. /**
  12031. * Gets the class name of the current intput.
  12032. * @returns the class name
  12033. */
  12034. getClassName(): string;
  12035. /**
  12036. * Get the friendly name associated with the input class.
  12037. * @returns the input friendly name
  12038. */
  12039. getSimpleName(): string;
  12040. }
  12041. }
  12042. declare module BABYLON {
  12043. /**
  12044. * Manage the touch inputs to control the movement of a free camera.
  12045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12046. */
  12047. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12048. /**
  12049. * Defines the camera the input is attached to.
  12050. */
  12051. camera: FreeCamera;
  12052. /**
  12053. * Defines the touch sensibility for rotation.
  12054. * The higher the faster.
  12055. */
  12056. touchAngularSensibility: number;
  12057. /**
  12058. * Defines the touch sensibility for move.
  12059. * The higher the faster.
  12060. */
  12061. touchMoveSensibility: number;
  12062. private _offsetX;
  12063. private _offsetY;
  12064. private _pointerPressed;
  12065. private _pointerInput;
  12066. private _observer;
  12067. private _onLostFocus;
  12068. /**
  12069. * Attach the input controls to a specific dom element to get the input from.
  12070. * @param element Defines the element the controls should be listened from
  12071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12072. */
  12073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12074. /**
  12075. * Detach the current controls from the specified dom element.
  12076. * @param element Defines the element to stop listening the inputs from
  12077. */
  12078. detachControl(element: Nullable<HTMLElement>): void;
  12079. /**
  12080. * Update the current camera state depending on the inputs that have been used this frame.
  12081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12082. */
  12083. checkInputs(): void;
  12084. /**
  12085. * Gets the class name of the current intput.
  12086. * @returns the class name
  12087. */
  12088. getClassName(): string;
  12089. /**
  12090. * Get the friendly name associated with the input class.
  12091. * @returns the input friendly name
  12092. */
  12093. getSimpleName(): string;
  12094. }
  12095. }
  12096. declare module BABYLON {
  12097. /**
  12098. * Default Inputs manager for the FreeCamera.
  12099. * It groups all the default supported inputs for ease of use.
  12100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12101. */
  12102. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12103. /**
  12104. * @hidden
  12105. */
  12106. _mouseInput: Nullable<FreeCameraMouseInput>;
  12107. /**
  12108. * Instantiates a new FreeCameraInputsManager.
  12109. * @param camera Defines the camera the inputs belong to
  12110. */
  12111. constructor(camera: FreeCamera);
  12112. /**
  12113. * Add keyboard input support to the input manager.
  12114. * @returns the current input manager
  12115. */
  12116. addKeyboard(): FreeCameraInputsManager;
  12117. /**
  12118. * Add mouse input support to the input manager.
  12119. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12120. * @returns the current input manager
  12121. */
  12122. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12123. /**
  12124. * Removes the mouse input support from the manager
  12125. * @returns the current input manager
  12126. */
  12127. removeMouse(): FreeCameraInputsManager;
  12128. /**
  12129. * Add touch input support to the input manager.
  12130. * @returns the current input manager
  12131. */
  12132. addTouch(): FreeCameraInputsManager;
  12133. /**
  12134. * Remove all attached input methods from a camera
  12135. */
  12136. clear(): void;
  12137. }
  12138. }
  12139. declare module BABYLON {
  12140. /**
  12141. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12142. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12143. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12144. */
  12145. export class FreeCamera extends TargetCamera {
  12146. /**
  12147. * Define the collision ellipsoid of the camera.
  12148. * This is helpful to simulate a camera body like the player body around the camera
  12149. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12150. */
  12151. ellipsoid: Vector3;
  12152. /**
  12153. * Define an offset for the position of the ellipsoid around the camera.
  12154. * This can be helpful to determine the center of the body near the gravity center of the body
  12155. * instead of its head.
  12156. */
  12157. ellipsoidOffset: Vector3;
  12158. /**
  12159. * Enable or disable collisions of the camera with the rest of the scene objects.
  12160. */
  12161. checkCollisions: boolean;
  12162. /**
  12163. * Enable or disable gravity on the camera.
  12164. */
  12165. applyGravity: boolean;
  12166. /**
  12167. * Define the input manager associated to the camera.
  12168. */
  12169. inputs: FreeCameraInputsManager;
  12170. /**
  12171. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12172. * Higher values reduce sensitivity.
  12173. */
  12174. /**
  12175. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12176. * Higher values reduce sensitivity.
  12177. */
  12178. angularSensibility: number;
  12179. /**
  12180. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12181. */
  12182. keysUp: number[];
  12183. /**
  12184. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12185. */
  12186. keysDown: number[];
  12187. /**
  12188. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12189. */
  12190. keysLeft: number[];
  12191. /**
  12192. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12193. */
  12194. keysRight: number[];
  12195. /**
  12196. * Event raised when the camera collide with a mesh in the scene.
  12197. */
  12198. onCollide: (collidedMesh: AbstractMesh) => void;
  12199. private _collider;
  12200. private _needMoveForGravity;
  12201. private _oldPosition;
  12202. private _diffPosition;
  12203. private _newPosition;
  12204. /** @hidden */
  12205. _localDirection: Vector3;
  12206. /** @hidden */
  12207. _transformedDirection: Vector3;
  12208. /**
  12209. * Instantiates a Free Camera.
  12210. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12211. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12212. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12213. * @param name Define the name of the camera in the scene
  12214. * @param position Define the start position of the camera in the scene
  12215. * @param scene Define the scene the camera belongs to
  12216. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12217. */
  12218. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12219. /**
  12220. * Attached controls to the current camera.
  12221. * @param element Defines the element the controls should be listened from
  12222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12223. */
  12224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12225. /**
  12226. * Detach the current controls from the camera.
  12227. * The camera will stop reacting to inputs.
  12228. * @param element Defines the element to stop listening the inputs from
  12229. */
  12230. detachControl(element: HTMLElement): void;
  12231. private _collisionMask;
  12232. /**
  12233. * Define a collision mask to limit the list of object the camera can collide with
  12234. */
  12235. collisionMask: number;
  12236. /** @hidden */
  12237. _collideWithWorld(displacement: Vector3): void;
  12238. private _onCollisionPositionChange;
  12239. /** @hidden */
  12240. _checkInputs(): void;
  12241. /** @hidden */
  12242. _decideIfNeedsToMove(): boolean;
  12243. /** @hidden */
  12244. _updatePosition(): void;
  12245. /**
  12246. * Destroy the camera and release the current resources hold by it.
  12247. */
  12248. dispose(): void;
  12249. /**
  12250. * Gets the current object class name.
  12251. * @return the class name
  12252. */
  12253. getClassName(): string;
  12254. }
  12255. }
  12256. declare module BABYLON {
  12257. /**
  12258. * Represents a gamepad control stick position
  12259. */
  12260. export class StickValues {
  12261. /**
  12262. * The x component of the control stick
  12263. */
  12264. x: number;
  12265. /**
  12266. * The y component of the control stick
  12267. */
  12268. y: number;
  12269. /**
  12270. * Initializes the gamepad x and y control stick values
  12271. * @param x The x component of the gamepad control stick value
  12272. * @param y The y component of the gamepad control stick value
  12273. */
  12274. constructor(
  12275. /**
  12276. * The x component of the control stick
  12277. */
  12278. x: number,
  12279. /**
  12280. * The y component of the control stick
  12281. */
  12282. y: number);
  12283. }
  12284. /**
  12285. * An interface which manages callbacks for gamepad button changes
  12286. */
  12287. export interface GamepadButtonChanges {
  12288. /**
  12289. * Called when a gamepad has been changed
  12290. */
  12291. changed: boolean;
  12292. /**
  12293. * Called when a gamepad press event has been triggered
  12294. */
  12295. pressChanged: boolean;
  12296. /**
  12297. * Called when a touch event has been triggered
  12298. */
  12299. touchChanged: boolean;
  12300. /**
  12301. * Called when a value has changed
  12302. */
  12303. valueChanged: boolean;
  12304. }
  12305. /**
  12306. * Represents a gamepad
  12307. */
  12308. export class Gamepad {
  12309. /**
  12310. * The id of the gamepad
  12311. */
  12312. id: string;
  12313. /**
  12314. * The index of the gamepad
  12315. */
  12316. index: number;
  12317. /**
  12318. * The browser gamepad
  12319. */
  12320. browserGamepad: any;
  12321. /**
  12322. * Specifies what type of gamepad this represents
  12323. */
  12324. type: number;
  12325. private _leftStick;
  12326. private _rightStick;
  12327. /** @hidden */
  12328. _isConnected: boolean;
  12329. private _leftStickAxisX;
  12330. private _leftStickAxisY;
  12331. private _rightStickAxisX;
  12332. private _rightStickAxisY;
  12333. /**
  12334. * Triggered when the left control stick has been changed
  12335. */
  12336. private _onleftstickchanged;
  12337. /**
  12338. * Triggered when the right control stick has been changed
  12339. */
  12340. private _onrightstickchanged;
  12341. /**
  12342. * Represents a gamepad controller
  12343. */
  12344. static GAMEPAD: number;
  12345. /**
  12346. * Represents a generic controller
  12347. */
  12348. static GENERIC: number;
  12349. /**
  12350. * Represents an XBox controller
  12351. */
  12352. static XBOX: number;
  12353. /**
  12354. * Represents a pose-enabled controller
  12355. */
  12356. static POSE_ENABLED: number;
  12357. /**
  12358. * Represents an Dual Shock controller
  12359. */
  12360. static DUALSHOCK: number;
  12361. /**
  12362. * Specifies whether the left control stick should be Y-inverted
  12363. */
  12364. protected _invertLeftStickY: boolean;
  12365. /**
  12366. * Specifies if the gamepad has been connected
  12367. */
  12368. readonly isConnected: boolean;
  12369. /**
  12370. * Initializes the gamepad
  12371. * @param id The id of the gamepad
  12372. * @param index The index of the gamepad
  12373. * @param browserGamepad The browser gamepad
  12374. * @param leftStickX The x component of the left joystick
  12375. * @param leftStickY The y component of the left joystick
  12376. * @param rightStickX The x component of the right joystick
  12377. * @param rightStickY The y component of the right joystick
  12378. */
  12379. constructor(
  12380. /**
  12381. * The id of the gamepad
  12382. */
  12383. id: string,
  12384. /**
  12385. * The index of the gamepad
  12386. */
  12387. index: number,
  12388. /**
  12389. * The browser gamepad
  12390. */
  12391. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12392. /**
  12393. * Callback triggered when the left joystick has changed
  12394. * @param callback
  12395. */
  12396. onleftstickchanged(callback: (values: StickValues) => void): void;
  12397. /**
  12398. * Callback triggered when the right joystick has changed
  12399. * @param callback
  12400. */
  12401. onrightstickchanged(callback: (values: StickValues) => void): void;
  12402. /**
  12403. * Gets the left joystick
  12404. */
  12405. /**
  12406. * Sets the left joystick values
  12407. */
  12408. leftStick: StickValues;
  12409. /**
  12410. * Gets the right joystick
  12411. */
  12412. /**
  12413. * Sets the right joystick value
  12414. */
  12415. rightStick: StickValues;
  12416. /**
  12417. * Updates the gamepad joystick positions
  12418. */
  12419. update(): void;
  12420. /**
  12421. * Disposes the gamepad
  12422. */
  12423. dispose(): void;
  12424. }
  12425. /**
  12426. * Represents a generic gamepad
  12427. */
  12428. export class GenericPad extends Gamepad {
  12429. private _buttons;
  12430. private _onbuttondown;
  12431. private _onbuttonup;
  12432. /**
  12433. * Observable triggered when a button has been pressed
  12434. */
  12435. onButtonDownObservable: Observable<number>;
  12436. /**
  12437. * Observable triggered when a button has been released
  12438. */
  12439. onButtonUpObservable: Observable<number>;
  12440. /**
  12441. * Callback triggered when a button has been pressed
  12442. * @param callback Called when a button has been pressed
  12443. */
  12444. onbuttondown(callback: (buttonPressed: number) => void): void;
  12445. /**
  12446. * Callback triggered when a button has been released
  12447. * @param callback Called when a button has been released
  12448. */
  12449. onbuttonup(callback: (buttonReleased: number) => void): void;
  12450. /**
  12451. * Initializes the generic gamepad
  12452. * @param id The id of the generic gamepad
  12453. * @param index The index of the generic gamepad
  12454. * @param browserGamepad The browser gamepad
  12455. */
  12456. constructor(id: string, index: number, browserGamepad: any);
  12457. private _setButtonValue;
  12458. /**
  12459. * Updates the generic gamepad
  12460. */
  12461. update(): void;
  12462. /**
  12463. * Disposes the generic gamepad
  12464. */
  12465. dispose(): void;
  12466. }
  12467. }
  12468. declare module BABYLON {
  12469. interface Engine {
  12470. /**
  12471. * Creates a raw texture
  12472. * @param data defines the data to store in the texture
  12473. * @param width defines the width of the texture
  12474. * @param height defines the height of the texture
  12475. * @param format defines the format of the data
  12476. * @param generateMipMaps defines if the engine should generate the mip levels
  12477. * @param invertY defines if data must be stored with Y axis inverted
  12478. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12479. * @param compression defines the compression used (null by default)
  12480. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12481. * @returns the raw texture inside an InternalTexture
  12482. */
  12483. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12484. /**
  12485. * Update a raw texture
  12486. * @param texture defines the texture to update
  12487. * @param data defines the data to store in the texture
  12488. * @param format defines the format of the data
  12489. * @param invertY defines if data must be stored with Y axis inverted
  12490. */
  12491. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12492. /**
  12493. * Update a raw texture
  12494. * @param texture defines the texture to update
  12495. * @param data defines the data to store in the texture
  12496. * @param format defines the format of the data
  12497. * @param invertY defines if data must be stored with Y axis inverted
  12498. * @param compression defines the compression used (null by default)
  12499. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12500. */
  12501. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12502. /**
  12503. * Creates a new raw cube texture
  12504. * @param data defines the array of data to use to create each face
  12505. * @param size defines the size of the textures
  12506. * @param format defines the format of the data
  12507. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12508. * @param generateMipMaps defines if the engine should generate the mip levels
  12509. * @param invertY defines if data must be stored with Y axis inverted
  12510. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12511. * @param compression defines the compression used (null by default)
  12512. * @returns the cube texture as an InternalTexture
  12513. */
  12514. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12515. /**
  12516. * Update a raw cube texture
  12517. * @param texture defines the texture to udpdate
  12518. * @param data defines the data to store
  12519. * @param format defines the data format
  12520. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12521. * @param invertY defines if data must be stored with Y axis inverted
  12522. */
  12523. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12524. /**
  12525. * Update a raw cube texture
  12526. * @param texture defines the texture to udpdate
  12527. * @param data defines the data to store
  12528. * @param format defines the data format
  12529. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. * @param compression defines the compression used (null by default)
  12532. */
  12533. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12534. /**
  12535. * Update a raw cube texture
  12536. * @param texture defines the texture to udpdate
  12537. * @param data defines the data to store
  12538. * @param format defines the data format
  12539. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12540. * @param invertY defines if data must be stored with Y axis inverted
  12541. * @param compression defines the compression used (null by default)
  12542. * @param level defines which level of the texture to update
  12543. */
  12544. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12545. /**
  12546. * Creates a new raw cube texture from a specified url
  12547. * @param url defines the url where the data is located
  12548. * @param scene defines the current scene
  12549. * @param size defines the size of the textures
  12550. * @param format defines the format of the data
  12551. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12552. * @param noMipmap defines if the engine should avoid generating the mip levels
  12553. * @param callback defines a callback used to extract texture data from loaded data
  12554. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12555. * @param onLoad defines a callback called when texture is loaded
  12556. * @param onError defines a callback called if there is an error
  12557. * @returns the cube texture as an InternalTexture
  12558. */
  12559. 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;
  12560. /**
  12561. * Creates a new raw cube texture from a specified url
  12562. * @param url defines the url where the data is located
  12563. * @param scene defines the current scene
  12564. * @param size defines the size of the textures
  12565. * @param format defines the format of the data
  12566. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12567. * @param noMipmap defines if the engine should avoid generating the mip levels
  12568. * @param callback defines a callback used to extract texture data from loaded data
  12569. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12570. * @param onLoad defines a callback called when texture is loaded
  12571. * @param onError defines a callback called if there is an error
  12572. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12573. * @param invertY defines if data must be stored with Y axis inverted
  12574. * @returns the cube texture as an InternalTexture
  12575. */
  12576. 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;
  12577. /**
  12578. * Creates a new raw 3D texture
  12579. * @param data defines the data used to create the texture
  12580. * @param width defines the width of the texture
  12581. * @param height defines the height of the texture
  12582. * @param depth defines the depth of the texture
  12583. * @param format defines the format of the texture
  12584. * @param generateMipMaps defines if the engine must generate mip levels
  12585. * @param invertY defines if data must be stored with Y axis inverted
  12586. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12587. * @param compression defines the compressed used (can be null)
  12588. * @param textureType defines the compressed used (can be null)
  12589. * @returns a new raw 3D texture (stored in an InternalTexture)
  12590. */
  12591. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12592. /**
  12593. * Update a raw 3D texture
  12594. * @param texture defines the texture to update
  12595. * @param data defines the data to store
  12596. * @param format defines the data format
  12597. * @param invertY defines if data must be stored with Y axis inverted
  12598. */
  12599. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12600. /**
  12601. * Update a raw 3D texture
  12602. * @param texture defines the texture to update
  12603. * @param data defines the data to store
  12604. * @param format defines the data format
  12605. * @param invertY defines if data must be stored with Y axis inverted
  12606. * @param compression defines the used compression (can be null)
  12607. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12608. */
  12609. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12610. /**
  12611. * Creates a new raw 2D array texture
  12612. * @param data defines the data used to create the texture
  12613. * @param width defines the width of the texture
  12614. * @param height defines the height of the texture
  12615. * @param depth defines the number of layers of the texture
  12616. * @param format defines the format of the texture
  12617. * @param generateMipMaps defines if the engine must generate mip levels
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12620. * @param compression defines the compressed used (can be null)
  12621. * @param textureType defines the compressed used (can be null)
  12622. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12623. */
  12624. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12625. /**
  12626. * Update a raw 2D array texture
  12627. * @param texture defines the texture to update
  12628. * @param data defines the data to store
  12629. * @param format defines the data format
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. */
  12632. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12633. /**
  12634. * Update a raw 2D array texture
  12635. * @param texture defines the texture to update
  12636. * @param data defines the data to store
  12637. * @param format defines the data format
  12638. * @param invertY defines if data must be stored with Y axis inverted
  12639. * @param compression defines the used compression (can be null)
  12640. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12641. */
  12642. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12643. }
  12644. }
  12645. declare module BABYLON {
  12646. /**
  12647. * Raw texture can help creating a texture directly from an array of data.
  12648. * This can be super useful if you either get the data from an uncompressed source or
  12649. * if you wish to create your texture pixel by pixel.
  12650. */
  12651. export class RawTexture extends Texture {
  12652. /**
  12653. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12654. */
  12655. format: number;
  12656. private _engine;
  12657. /**
  12658. * Instantiates a new RawTexture.
  12659. * Raw texture can help creating a texture directly from an array of data.
  12660. * This can be super useful if you either get the data from an uncompressed source or
  12661. * if you wish to create your texture pixel by pixel.
  12662. * @param data define the array of data to use to create the texture
  12663. * @param width define the width of the texture
  12664. * @param height define the height of the texture
  12665. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12666. * @param scene define the scene the texture belongs to
  12667. * @param generateMipMaps define whether mip maps should be generated or not
  12668. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12669. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12670. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12671. */
  12672. constructor(data: ArrayBufferView, width: number, height: number,
  12673. /**
  12674. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12675. */
  12676. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12677. /**
  12678. * Updates the texture underlying data.
  12679. * @param data Define the new data of the texture
  12680. */
  12681. update(data: ArrayBufferView): void;
  12682. /**
  12683. * Creates a luminance texture from some data.
  12684. * @param data Define the texture data
  12685. * @param width Define the width of the texture
  12686. * @param height Define the height of the texture
  12687. * @param scene Define the scene the texture belongs to
  12688. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12689. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12690. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12691. * @returns the luminance texture
  12692. */
  12693. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12694. /**
  12695. * Creates a luminance alpha texture from some data.
  12696. * @param data Define the texture data
  12697. * @param width Define the width of the texture
  12698. * @param height Define the height of the texture
  12699. * @param scene Define the scene the texture belongs to
  12700. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12701. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12702. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12703. * @returns the luminance alpha texture
  12704. */
  12705. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12706. /**
  12707. * Creates an alpha texture from some data.
  12708. * @param data Define the texture data
  12709. * @param width Define the width of the texture
  12710. * @param height Define the height of the texture
  12711. * @param scene Define the scene the texture belongs to
  12712. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12713. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12714. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12715. * @returns the alpha texture
  12716. */
  12717. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12718. /**
  12719. * Creates a RGB texture from some data.
  12720. * @param data Define the texture data
  12721. * @param width Define the width of the texture
  12722. * @param height Define the height of the texture
  12723. * @param scene Define the scene the texture belongs to
  12724. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12725. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12726. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12727. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12728. * @returns the RGB alpha texture
  12729. */
  12730. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12731. /**
  12732. * Creates a RGBA texture from some data.
  12733. * @param data Define the texture data
  12734. * @param width Define the width of the texture
  12735. * @param height Define the height of the texture
  12736. * @param scene Define the scene the texture belongs to
  12737. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12738. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12739. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12740. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12741. * @returns the RGBA texture
  12742. */
  12743. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12744. /**
  12745. * Creates a R texture from some data.
  12746. * @param data Define the texture data
  12747. * @param width Define the width of the texture
  12748. * @param height Define the height of the texture
  12749. * @param scene Define the scene the texture belongs to
  12750. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12751. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12752. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12753. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12754. * @returns the R texture
  12755. */
  12756. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12757. }
  12758. }
  12759. declare module BABYLON {
  12760. /**
  12761. * Interface for the size containing width and height
  12762. */
  12763. export interface ISize {
  12764. /**
  12765. * Width
  12766. */
  12767. width: number;
  12768. /**
  12769. * Heighht
  12770. */
  12771. height: number;
  12772. }
  12773. /**
  12774. * Size containing widht and height
  12775. */
  12776. export class Size implements ISize {
  12777. /**
  12778. * Width
  12779. */
  12780. width: number;
  12781. /**
  12782. * Height
  12783. */
  12784. height: number;
  12785. /**
  12786. * Creates a Size object from the given width and height (floats).
  12787. * @param width width of the new size
  12788. * @param height height of the new size
  12789. */
  12790. constructor(width: number, height: number);
  12791. /**
  12792. * Returns a string with the Size width and height
  12793. * @returns a string with the Size width and height
  12794. */
  12795. toString(): string;
  12796. /**
  12797. * "Size"
  12798. * @returns the string "Size"
  12799. */
  12800. getClassName(): string;
  12801. /**
  12802. * Returns the Size hash code.
  12803. * @returns a hash code for a unique width and height
  12804. */
  12805. getHashCode(): number;
  12806. /**
  12807. * Updates the current size from the given one.
  12808. * @param src the given size
  12809. */
  12810. copyFrom(src: Size): void;
  12811. /**
  12812. * Updates in place the current Size from the given floats.
  12813. * @param width width of the new size
  12814. * @param height height of the new size
  12815. * @returns the updated Size.
  12816. */
  12817. copyFromFloats(width: number, height: number): Size;
  12818. /**
  12819. * Updates in place the current Size from the given floats.
  12820. * @param width width to set
  12821. * @param height height to set
  12822. * @returns the updated Size.
  12823. */
  12824. set(width: number, height: number): Size;
  12825. /**
  12826. * Multiplies the width and height by numbers
  12827. * @param w factor to multiple the width by
  12828. * @param h factor to multiple the height by
  12829. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12830. */
  12831. multiplyByFloats(w: number, h: number): Size;
  12832. /**
  12833. * Clones the size
  12834. * @returns a new Size copied from the given one.
  12835. */
  12836. clone(): Size;
  12837. /**
  12838. * True if the current Size and the given one width and height are strictly equal.
  12839. * @param other the other size to compare against
  12840. * @returns True if the current Size and the given one width and height are strictly equal.
  12841. */
  12842. equals(other: Size): boolean;
  12843. /**
  12844. * The surface of the Size : width * height (float).
  12845. */
  12846. readonly surface: number;
  12847. /**
  12848. * Create a new size of zero
  12849. * @returns a new Size set to (0.0, 0.0)
  12850. */
  12851. static Zero(): Size;
  12852. /**
  12853. * Sums the width and height of two sizes
  12854. * @param otherSize size to add to this size
  12855. * @returns a new Size set as the addition result of the current Size and the given one.
  12856. */
  12857. add(otherSize: Size): Size;
  12858. /**
  12859. * Subtracts the width and height of two
  12860. * @param otherSize size to subtract to this size
  12861. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12862. */
  12863. subtract(otherSize: Size): Size;
  12864. /**
  12865. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12866. * @param start starting size to lerp between
  12867. * @param end end size to lerp between
  12868. * @param amount amount to lerp between the start and end values
  12869. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12870. */
  12871. static Lerp(start: Size, end: Size, amount: number): Size;
  12872. }
  12873. }
  12874. declare module BABYLON {
  12875. /**
  12876. * Defines a runtime animation
  12877. */
  12878. export class RuntimeAnimation {
  12879. private _events;
  12880. /**
  12881. * The current frame of the runtime animation
  12882. */
  12883. private _currentFrame;
  12884. /**
  12885. * The animation used by the runtime animation
  12886. */
  12887. private _animation;
  12888. /**
  12889. * The target of the runtime animation
  12890. */
  12891. private _target;
  12892. /**
  12893. * The initiating animatable
  12894. */
  12895. private _host;
  12896. /**
  12897. * The original value of the runtime animation
  12898. */
  12899. private _originalValue;
  12900. /**
  12901. * The original blend value of the runtime animation
  12902. */
  12903. private _originalBlendValue;
  12904. /**
  12905. * The offsets cache of the runtime animation
  12906. */
  12907. private _offsetsCache;
  12908. /**
  12909. * The high limits cache of the runtime animation
  12910. */
  12911. private _highLimitsCache;
  12912. /**
  12913. * Specifies if the runtime animation has been stopped
  12914. */
  12915. private _stopped;
  12916. /**
  12917. * The blending factor of the runtime animation
  12918. */
  12919. private _blendingFactor;
  12920. /**
  12921. * The BabylonJS scene
  12922. */
  12923. private _scene;
  12924. /**
  12925. * The current value of the runtime animation
  12926. */
  12927. private _currentValue;
  12928. /** @hidden */
  12929. _animationState: _IAnimationState;
  12930. /**
  12931. * The active target of the runtime animation
  12932. */
  12933. private _activeTargets;
  12934. private _currentActiveTarget;
  12935. private _directTarget;
  12936. /**
  12937. * The target path of the runtime animation
  12938. */
  12939. private _targetPath;
  12940. /**
  12941. * The weight of the runtime animation
  12942. */
  12943. private _weight;
  12944. /**
  12945. * The ratio offset of the runtime animation
  12946. */
  12947. private _ratioOffset;
  12948. /**
  12949. * The previous delay of the runtime animation
  12950. */
  12951. private _previousDelay;
  12952. /**
  12953. * The previous ratio of the runtime animation
  12954. */
  12955. private _previousRatio;
  12956. private _enableBlending;
  12957. private _keys;
  12958. private _minFrame;
  12959. private _maxFrame;
  12960. private _minValue;
  12961. private _maxValue;
  12962. private _targetIsArray;
  12963. /**
  12964. * Gets the current frame of the runtime animation
  12965. */
  12966. readonly currentFrame: number;
  12967. /**
  12968. * Gets the weight of the runtime animation
  12969. */
  12970. readonly weight: number;
  12971. /**
  12972. * Gets the current value of the runtime animation
  12973. */
  12974. readonly currentValue: any;
  12975. /**
  12976. * Gets the target path of the runtime animation
  12977. */
  12978. readonly targetPath: string;
  12979. /**
  12980. * Gets the actual target of the runtime animation
  12981. */
  12982. readonly target: any;
  12983. /** @hidden */
  12984. _onLoop: () => void;
  12985. /**
  12986. * Create a new RuntimeAnimation object
  12987. * @param target defines the target of the animation
  12988. * @param animation defines the source animation object
  12989. * @param scene defines the hosting scene
  12990. * @param host defines the initiating Animatable
  12991. */
  12992. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12993. private _preparePath;
  12994. /**
  12995. * Gets the animation from the runtime animation
  12996. */
  12997. readonly animation: Animation;
  12998. /**
  12999. * Resets the runtime animation to the beginning
  13000. * @param restoreOriginal defines whether to restore the target property to the original value
  13001. */
  13002. reset(restoreOriginal?: boolean): void;
  13003. /**
  13004. * Specifies if the runtime animation is stopped
  13005. * @returns Boolean specifying if the runtime animation is stopped
  13006. */
  13007. isStopped(): boolean;
  13008. /**
  13009. * Disposes of the runtime animation
  13010. */
  13011. dispose(): void;
  13012. /**
  13013. * Apply the interpolated value to the target
  13014. * @param currentValue defines the value computed by the animation
  13015. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13016. */
  13017. setValue(currentValue: any, weight: number): void;
  13018. private _getOriginalValues;
  13019. private _setValue;
  13020. /**
  13021. * Gets the loop pmode of the runtime animation
  13022. * @returns Loop Mode
  13023. */
  13024. private _getCorrectLoopMode;
  13025. /**
  13026. * Move the current animation to a given frame
  13027. * @param frame defines the frame to move to
  13028. */
  13029. goToFrame(frame: number): void;
  13030. /**
  13031. * @hidden Internal use only
  13032. */
  13033. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13034. /**
  13035. * Execute the current animation
  13036. * @param delay defines the delay to add to the current frame
  13037. * @param from defines the lower bound of the animation range
  13038. * @param to defines the upper bound of the animation range
  13039. * @param loop defines if the current animation must loop
  13040. * @param speedRatio defines the current speed ratio
  13041. * @param weight defines the weight of the animation (default is -1 so no weight)
  13042. * @param onLoop optional callback called when animation loops
  13043. * @returns a boolean indicating if the animation is running
  13044. */
  13045. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13046. }
  13047. }
  13048. declare module BABYLON {
  13049. /**
  13050. * Class used to store an actual running animation
  13051. */
  13052. export class Animatable {
  13053. /** defines the target object */
  13054. target: any;
  13055. /** defines the starting frame number (default is 0) */
  13056. fromFrame: number;
  13057. /** defines the ending frame number (default is 100) */
  13058. toFrame: number;
  13059. /** defines if the animation must loop (default is false) */
  13060. loopAnimation: boolean;
  13061. /** defines a callback to call when animation ends if it is not looping */
  13062. onAnimationEnd?: (() => void) | null | undefined;
  13063. /** defines a callback to call when animation loops */
  13064. onAnimationLoop?: (() => void) | null | undefined;
  13065. private _localDelayOffset;
  13066. private _pausedDelay;
  13067. private _runtimeAnimations;
  13068. private _paused;
  13069. private _scene;
  13070. private _speedRatio;
  13071. private _weight;
  13072. private _syncRoot;
  13073. /**
  13074. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13075. * This will only apply for non looping animation (default is true)
  13076. */
  13077. disposeOnEnd: boolean;
  13078. /**
  13079. * Gets a boolean indicating if the animation has started
  13080. */
  13081. animationStarted: boolean;
  13082. /**
  13083. * Observer raised when the animation ends
  13084. */
  13085. onAnimationEndObservable: Observable<Animatable>;
  13086. /**
  13087. * Observer raised when the animation loops
  13088. */
  13089. onAnimationLoopObservable: Observable<Animatable>;
  13090. /**
  13091. * Gets the root Animatable used to synchronize and normalize animations
  13092. */
  13093. readonly syncRoot: Nullable<Animatable>;
  13094. /**
  13095. * Gets the current frame of the first RuntimeAnimation
  13096. * Used to synchronize Animatables
  13097. */
  13098. readonly masterFrame: number;
  13099. /**
  13100. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13101. */
  13102. weight: number;
  13103. /**
  13104. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13105. */
  13106. speedRatio: number;
  13107. /**
  13108. * Creates a new Animatable
  13109. * @param scene defines the hosting scene
  13110. * @param target defines the target object
  13111. * @param fromFrame defines the starting frame number (default is 0)
  13112. * @param toFrame defines the ending frame number (default is 100)
  13113. * @param loopAnimation defines if the animation must loop (default is false)
  13114. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13115. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13116. * @param animations defines a group of animation to add to the new Animatable
  13117. * @param onAnimationLoop defines a callback to call when animation loops
  13118. */
  13119. constructor(scene: Scene,
  13120. /** defines the target object */
  13121. target: any,
  13122. /** defines the starting frame number (default is 0) */
  13123. fromFrame?: number,
  13124. /** defines the ending frame number (default is 100) */
  13125. toFrame?: number,
  13126. /** defines if the animation must loop (default is false) */
  13127. loopAnimation?: boolean, speedRatio?: number,
  13128. /** defines a callback to call when animation ends if it is not looping */
  13129. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13130. /** defines a callback to call when animation loops */
  13131. onAnimationLoop?: (() => void) | null | undefined);
  13132. /**
  13133. * Synchronize and normalize current Animatable with a source Animatable
  13134. * This is useful when using animation weights and when animations are not of the same length
  13135. * @param root defines the root Animatable to synchronize with
  13136. * @returns the current Animatable
  13137. */
  13138. syncWith(root: Animatable): Animatable;
  13139. /**
  13140. * Gets the list of runtime animations
  13141. * @returns an array of RuntimeAnimation
  13142. */
  13143. getAnimations(): RuntimeAnimation[];
  13144. /**
  13145. * Adds more animations to the current animatable
  13146. * @param target defines the target of the animations
  13147. * @param animations defines the new animations to add
  13148. */
  13149. appendAnimations(target: any, animations: Animation[]): void;
  13150. /**
  13151. * Gets the source animation for a specific property
  13152. * @param property defines the propertyu to look for
  13153. * @returns null or the source animation for the given property
  13154. */
  13155. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13156. /**
  13157. * Gets the runtime animation for a specific property
  13158. * @param property defines the propertyu to look for
  13159. * @returns null or the runtime animation for the given property
  13160. */
  13161. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13162. /**
  13163. * Resets the animatable to its original state
  13164. */
  13165. reset(): void;
  13166. /**
  13167. * Allows the animatable to blend with current running animations
  13168. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13169. * @param blendingSpeed defines the blending speed to use
  13170. */
  13171. enableBlending(blendingSpeed: number): void;
  13172. /**
  13173. * Disable animation blending
  13174. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13175. */
  13176. disableBlending(): void;
  13177. /**
  13178. * Jump directly to a given frame
  13179. * @param frame defines the frame to jump to
  13180. */
  13181. goToFrame(frame: number): void;
  13182. /**
  13183. * Pause the animation
  13184. */
  13185. pause(): void;
  13186. /**
  13187. * Restart the animation
  13188. */
  13189. restart(): void;
  13190. private _raiseOnAnimationEnd;
  13191. /**
  13192. * Stop and delete the current animation
  13193. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13194. * @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)
  13195. */
  13196. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13197. /**
  13198. * Wait asynchronously for the animation to end
  13199. * @returns a promise which will be fullfilled when the animation ends
  13200. */
  13201. waitAsync(): Promise<Animatable>;
  13202. /** @hidden */
  13203. _animate(delay: number): boolean;
  13204. }
  13205. interface Scene {
  13206. /** @hidden */
  13207. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13208. /** @hidden */
  13209. _processLateAnimationBindingsForMatrices(holder: {
  13210. totalWeight: number;
  13211. animations: RuntimeAnimation[];
  13212. originalValue: Matrix;
  13213. }): any;
  13214. /** @hidden */
  13215. _processLateAnimationBindingsForQuaternions(holder: {
  13216. totalWeight: number;
  13217. animations: RuntimeAnimation[];
  13218. originalValue: Quaternion;
  13219. }, refQuaternion: Quaternion): Quaternion;
  13220. /** @hidden */
  13221. _processLateAnimationBindings(): void;
  13222. /**
  13223. * Will start the animation sequence of a given target
  13224. * @param target defines the target
  13225. * @param from defines from which frame should animation start
  13226. * @param to defines until which frame should animation run.
  13227. * @param weight defines the weight to apply to the animation (1.0 by default)
  13228. * @param loop defines if the animation loops
  13229. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13230. * @param onAnimationEnd defines the function to be executed when the animation ends
  13231. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13232. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13233. * @param onAnimationLoop defines the callback to call when an animation loops
  13234. * @returns the animatable object created for this animation
  13235. */
  13236. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13237. /**
  13238. * Will start the animation sequence of a given target
  13239. * @param target defines the target
  13240. * @param from defines from which frame should animation start
  13241. * @param to defines until which frame should animation run.
  13242. * @param loop defines if the animation loops
  13243. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13244. * @param onAnimationEnd defines the function to be executed when the animation ends
  13245. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13246. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13247. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13248. * @param onAnimationLoop defines the callback to call when an animation loops
  13249. * @returns the animatable object created for this animation
  13250. */
  13251. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13252. /**
  13253. * Will start the animation sequence of a given target and its hierarchy
  13254. * @param target defines the target
  13255. * @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.
  13256. * @param from defines from which frame should animation start
  13257. * @param to defines until which frame should animation run.
  13258. * @param loop defines if the animation loops
  13259. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13260. * @param onAnimationEnd defines the function to be executed when the animation ends
  13261. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13262. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13263. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13264. * @param onAnimationLoop defines the callback to call when an animation loops
  13265. * @returns the list of created animatables
  13266. */
  13267. 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[];
  13268. /**
  13269. * Begin a new animation on a given node
  13270. * @param target defines the target where the animation will take place
  13271. * @param animations defines the list of animations to start
  13272. * @param from defines the initial value
  13273. * @param to defines the final value
  13274. * @param loop defines if you want animation to loop (off by default)
  13275. * @param speedRatio defines the speed ratio to apply to all animations
  13276. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13277. * @param onAnimationLoop defines the callback to call when an animation loops
  13278. * @returns the list of created animatables
  13279. */
  13280. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13281. /**
  13282. * Begin a new animation on a given node and its hierarchy
  13283. * @param target defines the root node where the animation will take place
  13284. * @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.
  13285. * @param animations defines the list of animations to start
  13286. * @param from defines the initial value
  13287. * @param to defines the final value
  13288. * @param loop defines if you want animation to loop (off by default)
  13289. * @param speedRatio defines the speed ratio to apply to all animations
  13290. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13291. * @param onAnimationLoop defines the callback to call when an animation loops
  13292. * @returns the list of animatables created for all nodes
  13293. */
  13294. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13295. /**
  13296. * Gets the animatable associated with a specific target
  13297. * @param target defines the target of the animatable
  13298. * @returns the required animatable if found
  13299. */
  13300. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13301. /**
  13302. * Gets all animatables associated with a given target
  13303. * @param target defines the target to look animatables for
  13304. * @returns an array of Animatables
  13305. */
  13306. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13307. /**
  13308. * Stops and removes all animations that have been applied to the scene
  13309. */
  13310. stopAllAnimations(): void;
  13311. /**
  13312. * Gets the current delta time used by animation engine
  13313. */
  13314. deltaTime: number;
  13315. }
  13316. interface Bone {
  13317. /**
  13318. * Copy an animation range from another bone
  13319. * @param source defines the source bone
  13320. * @param rangeName defines the range name to copy
  13321. * @param frameOffset defines the frame offset
  13322. * @param rescaleAsRequired defines if rescaling must be applied if required
  13323. * @param skelDimensionsRatio defines the scaling ratio
  13324. * @returns true if operation was successful
  13325. */
  13326. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13327. }
  13328. }
  13329. declare module BABYLON {
  13330. /**
  13331. * Class used to override all child animations of a given target
  13332. */
  13333. export class AnimationPropertiesOverride {
  13334. /**
  13335. * Gets or sets a value indicating if animation blending must be used
  13336. */
  13337. enableBlending: boolean;
  13338. /**
  13339. * Gets or sets the blending speed to use when enableBlending is true
  13340. */
  13341. blendingSpeed: number;
  13342. /**
  13343. * Gets or sets the default loop mode to use
  13344. */
  13345. loopMode: number;
  13346. }
  13347. }
  13348. declare module BABYLON {
  13349. /**
  13350. * Class used to handle skinning animations
  13351. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13352. */
  13353. export class Skeleton implements IAnimatable {
  13354. /** defines the skeleton name */
  13355. name: string;
  13356. /** defines the skeleton Id */
  13357. id: string;
  13358. /**
  13359. * Defines the list of child bones
  13360. */
  13361. bones: Bone[];
  13362. /**
  13363. * Defines an estimate of the dimension of the skeleton at rest
  13364. */
  13365. dimensionsAtRest: Vector3;
  13366. /**
  13367. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13368. */
  13369. needInitialSkinMatrix: boolean;
  13370. /**
  13371. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13372. */
  13373. overrideMesh: Nullable<AbstractMesh>;
  13374. /**
  13375. * Gets the list of animations attached to this skeleton
  13376. */
  13377. animations: Array<Animation>;
  13378. private _scene;
  13379. private _isDirty;
  13380. private _transformMatrices;
  13381. private _transformMatrixTexture;
  13382. private _meshesWithPoseMatrix;
  13383. private _animatables;
  13384. private _identity;
  13385. private _synchronizedWithMesh;
  13386. private _ranges;
  13387. private _lastAbsoluteTransformsUpdateId;
  13388. private _canUseTextureForBones;
  13389. private _uniqueId;
  13390. /** @hidden */
  13391. _numBonesWithLinkedTransformNode: number;
  13392. /** @hidden */
  13393. _hasWaitingData: Nullable<boolean>;
  13394. /**
  13395. * Specifies if the skeleton should be serialized
  13396. */
  13397. doNotSerialize: boolean;
  13398. private _useTextureToStoreBoneMatrices;
  13399. /**
  13400. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13401. * Please note that this option is not available if the hardware does not support it
  13402. */
  13403. useTextureToStoreBoneMatrices: boolean;
  13404. private _animationPropertiesOverride;
  13405. /**
  13406. * Gets or sets the animation properties override
  13407. */
  13408. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13409. /**
  13410. * List of inspectable custom properties (used by the Inspector)
  13411. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13412. */
  13413. inspectableCustomProperties: IInspectable[];
  13414. /**
  13415. * An observable triggered before computing the skeleton's matrices
  13416. */
  13417. onBeforeComputeObservable: Observable<Skeleton>;
  13418. /**
  13419. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13420. */
  13421. readonly isUsingTextureForMatrices: boolean;
  13422. /**
  13423. * Gets the unique ID of this skeleton
  13424. */
  13425. readonly uniqueId: number;
  13426. /**
  13427. * Creates a new skeleton
  13428. * @param name defines the skeleton name
  13429. * @param id defines the skeleton Id
  13430. * @param scene defines the hosting scene
  13431. */
  13432. constructor(
  13433. /** defines the skeleton name */
  13434. name: string,
  13435. /** defines the skeleton Id */
  13436. id: string, scene: Scene);
  13437. /**
  13438. * Gets the current object class name.
  13439. * @return the class name
  13440. */
  13441. getClassName(): string;
  13442. /**
  13443. * Returns an array containing the root bones
  13444. * @returns an array containing the root bones
  13445. */
  13446. getChildren(): Array<Bone>;
  13447. /**
  13448. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13449. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13450. * @returns a Float32Array containing matrices data
  13451. */
  13452. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13453. /**
  13454. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13455. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13456. * @returns a raw texture containing the data
  13457. */
  13458. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13459. /**
  13460. * Gets the current hosting scene
  13461. * @returns a scene object
  13462. */
  13463. getScene(): Scene;
  13464. /**
  13465. * Gets a string representing the current skeleton data
  13466. * @param fullDetails defines a boolean indicating if we want a verbose version
  13467. * @returns a string representing the current skeleton data
  13468. */
  13469. toString(fullDetails?: boolean): string;
  13470. /**
  13471. * Get bone's index searching by name
  13472. * @param name defines bone's name to search for
  13473. * @return the indice of the bone. Returns -1 if not found
  13474. */
  13475. getBoneIndexByName(name: string): number;
  13476. /**
  13477. * Creater a new animation range
  13478. * @param name defines the name of the range
  13479. * @param from defines the start key
  13480. * @param to defines the end key
  13481. */
  13482. createAnimationRange(name: string, from: number, to: number): void;
  13483. /**
  13484. * Delete a specific animation range
  13485. * @param name defines the name of the range
  13486. * @param deleteFrames defines if frames must be removed as well
  13487. */
  13488. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13489. /**
  13490. * Gets a specific animation range
  13491. * @param name defines the name of the range to look for
  13492. * @returns the requested animation range or null if not found
  13493. */
  13494. getAnimationRange(name: string): Nullable<AnimationRange>;
  13495. /**
  13496. * Gets the list of all animation ranges defined on this skeleton
  13497. * @returns an array
  13498. */
  13499. getAnimationRanges(): Nullable<AnimationRange>[];
  13500. /**
  13501. * Copy animation range from a source skeleton.
  13502. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13503. * @param source defines the source skeleton
  13504. * @param name defines the name of the range to copy
  13505. * @param rescaleAsRequired defines if rescaling must be applied if required
  13506. * @returns true if operation was successful
  13507. */
  13508. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13509. /**
  13510. * Forces the skeleton to go to rest pose
  13511. */
  13512. returnToRest(): void;
  13513. private _getHighestAnimationFrame;
  13514. /**
  13515. * Begin a specific animation range
  13516. * @param name defines the name of the range to start
  13517. * @param loop defines if looping must be turned on (false by default)
  13518. * @param speedRatio defines the speed ratio to apply (1 by default)
  13519. * @param onAnimationEnd defines a callback which will be called when animation will end
  13520. * @returns a new animatable
  13521. */
  13522. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13523. /** @hidden */
  13524. _markAsDirty(): void;
  13525. /** @hidden */
  13526. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13527. /** @hidden */
  13528. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13529. private _computeTransformMatrices;
  13530. /**
  13531. * Build all resources required to render a skeleton
  13532. */
  13533. prepare(): void;
  13534. /**
  13535. * Gets the list of animatables currently running for this skeleton
  13536. * @returns an array of animatables
  13537. */
  13538. getAnimatables(): IAnimatable[];
  13539. /**
  13540. * Clone the current skeleton
  13541. * @param name defines the name of the new skeleton
  13542. * @param id defines the id of the new skeleton
  13543. * @returns the new skeleton
  13544. */
  13545. clone(name: string, id?: string): Skeleton;
  13546. /**
  13547. * Enable animation blending for this skeleton
  13548. * @param blendingSpeed defines the blending speed to apply
  13549. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13550. */
  13551. enableBlending(blendingSpeed?: number): void;
  13552. /**
  13553. * Releases all resources associated with the current skeleton
  13554. */
  13555. dispose(): void;
  13556. /**
  13557. * Serialize the skeleton in a JSON object
  13558. * @returns a JSON object
  13559. */
  13560. serialize(): any;
  13561. /**
  13562. * Creates a new skeleton from serialized data
  13563. * @param parsedSkeleton defines the serialized data
  13564. * @param scene defines the hosting scene
  13565. * @returns a new skeleton
  13566. */
  13567. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13568. /**
  13569. * Compute all node absolute transforms
  13570. * @param forceUpdate defines if computation must be done even if cache is up to date
  13571. */
  13572. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13573. /**
  13574. * Gets the root pose matrix
  13575. * @returns a matrix
  13576. */
  13577. getPoseMatrix(): Nullable<Matrix>;
  13578. /**
  13579. * Sorts bones per internal index
  13580. */
  13581. sortBones(): void;
  13582. private _sortBones;
  13583. }
  13584. }
  13585. declare module BABYLON {
  13586. /**
  13587. * Class used to store bone information
  13588. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13589. */
  13590. export class Bone extends Node {
  13591. /**
  13592. * defines the bone name
  13593. */
  13594. name: string;
  13595. private static _tmpVecs;
  13596. private static _tmpQuat;
  13597. private static _tmpMats;
  13598. /**
  13599. * Gets the list of child bones
  13600. */
  13601. children: Bone[];
  13602. /** Gets the animations associated with this bone */
  13603. animations: Animation[];
  13604. /**
  13605. * Gets or sets bone length
  13606. */
  13607. length: number;
  13608. /**
  13609. * @hidden Internal only
  13610. * Set this value to map this bone to a different index in the transform matrices
  13611. * Set this value to -1 to exclude the bone from the transform matrices
  13612. */
  13613. _index: Nullable<number>;
  13614. private _skeleton;
  13615. private _localMatrix;
  13616. private _restPose;
  13617. private _baseMatrix;
  13618. private _absoluteTransform;
  13619. private _invertedAbsoluteTransform;
  13620. private _parent;
  13621. private _scalingDeterminant;
  13622. private _worldTransform;
  13623. private _localScaling;
  13624. private _localRotation;
  13625. private _localPosition;
  13626. private _needToDecompose;
  13627. private _needToCompose;
  13628. /** @hidden */
  13629. _linkedTransformNode: Nullable<TransformNode>;
  13630. /** @hidden */
  13631. _waitingTransformNodeId: Nullable<string>;
  13632. /** @hidden */
  13633. /** @hidden */
  13634. _matrix: Matrix;
  13635. /**
  13636. * Create a new bone
  13637. * @param name defines the bone name
  13638. * @param skeleton defines the parent skeleton
  13639. * @param parentBone defines the parent (can be null if the bone is the root)
  13640. * @param localMatrix defines the local matrix
  13641. * @param restPose defines the rest pose matrix
  13642. * @param baseMatrix defines the base matrix
  13643. * @param index defines index of the bone in the hiearchy
  13644. */
  13645. constructor(
  13646. /**
  13647. * defines the bone name
  13648. */
  13649. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13650. /**
  13651. * Gets the current object class name.
  13652. * @return the class name
  13653. */
  13654. getClassName(): string;
  13655. /**
  13656. * Gets the parent skeleton
  13657. * @returns a skeleton
  13658. */
  13659. getSkeleton(): Skeleton;
  13660. /**
  13661. * Gets parent bone
  13662. * @returns a bone or null if the bone is the root of the bone hierarchy
  13663. */
  13664. getParent(): Nullable<Bone>;
  13665. /**
  13666. * Returns an array containing the root bones
  13667. * @returns an array containing the root bones
  13668. */
  13669. getChildren(): Array<Bone>;
  13670. /**
  13671. * Gets the node index in matrix array generated for rendering
  13672. * @returns the node index
  13673. */
  13674. getIndex(): number;
  13675. /**
  13676. * Sets the parent bone
  13677. * @param parent defines the parent (can be null if the bone is the root)
  13678. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13679. */
  13680. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13681. /**
  13682. * Gets the local matrix
  13683. * @returns a matrix
  13684. */
  13685. getLocalMatrix(): Matrix;
  13686. /**
  13687. * Gets the base matrix (initial matrix which remains unchanged)
  13688. * @returns a matrix
  13689. */
  13690. getBaseMatrix(): Matrix;
  13691. /**
  13692. * Gets the rest pose matrix
  13693. * @returns a matrix
  13694. */
  13695. getRestPose(): Matrix;
  13696. /**
  13697. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13698. */
  13699. getWorldMatrix(): Matrix;
  13700. /**
  13701. * Sets the local matrix to rest pose matrix
  13702. */
  13703. returnToRest(): void;
  13704. /**
  13705. * Gets the inverse of the absolute transform matrix.
  13706. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13707. * @returns a matrix
  13708. */
  13709. getInvertedAbsoluteTransform(): Matrix;
  13710. /**
  13711. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13712. * @returns a matrix
  13713. */
  13714. getAbsoluteTransform(): Matrix;
  13715. /**
  13716. * Links with the given transform node.
  13717. * The local matrix of this bone is copied from the transform node every frame.
  13718. * @param transformNode defines the transform node to link to
  13719. */
  13720. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13721. /**
  13722. * Gets the node used to drive the bone's transformation
  13723. * @returns a transform node or null
  13724. */
  13725. getTransformNode(): Nullable<TransformNode>;
  13726. /** Gets or sets current position (in local space) */
  13727. position: Vector3;
  13728. /** Gets or sets current rotation (in local space) */
  13729. rotation: Vector3;
  13730. /** Gets or sets current rotation quaternion (in local space) */
  13731. rotationQuaternion: Quaternion;
  13732. /** Gets or sets current scaling (in local space) */
  13733. scaling: Vector3;
  13734. /**
  13735. * Gets the animation properties override
  13736. */
  13737. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13738. private _decompose;
  13739. private _compose;
  13740. /**
  13741. * Update the base and local matrices
  13742. * @param matrix defines the new base or local matrix
  13743. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13744. * @param updateLocalMatrix defines if the local matrix should be updated
  13745. */
  13746. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13747. /** @hidden */
  13748. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13749. /**
  13750. * Flag the bone as dirty (Forcing it to update everything)
  13751. */
  13752. markAsDirty(): void;
  13753. /** @hidden */
  13754. _markAsDirtyAndCompose(): void;
  13755. private _markAsDirtyAndDecompose;
  13756. /**
  13757. * Translate the bone in local or world space
  13758. * @param vec The amount to translate the bone
  13759. * @param space The space that the translation is in
  13760. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13761. */
  13762. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13763. /**
  13764. * Set the postion of the bone in local or world space
  13765. * @param position The position to set the bone
  13766. * @param space The space that the position is in
  13767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13768. */
  13769. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13770. /**
  13771. * Set the absolute position of the bone (world space)
  13772. * @param position The position to set the bone
  13773. * @param mesh The mesh that this bone is attached to
  13774. */
  13775. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13776. /**
  13777. * Scale the bone on the x, y and z axes (in local space)
  13778. * @param x The amount to scale the bone on the x axis
  13779. * @param y The amount to scale the bone on the y axis
  13780. * @param z The amount to scale the bone on the z axis
  13781. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13782. */
  13783. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13784. /**
  13785. * Set the bone scaling in local space
  13786. * @param scale defines the scaling vector
  13787. */
  13788. setScale(scale: Vector3): void;
  13789. /**
  13790. * Gets the current scaling in local space
  13791. * @returns the current scaling vector
  13792. */
  13793. getScale(): Vector3;
  13794. /**
  13795. * Gets the current scaling in local space and stores it in a target vector
  13796. * @param result defines the target vector
  13797. */
  13798. getScaleToRef(result: Vector3): void;
  13799. /**
  13800. * Set the yaw, pitch, and roll of the bone in local or world space
  13801. * @param yaw The rotation of the bone on the y axis
  13802. * @param pitch The rotation of the bone on the x axis
  13803. * @param roll The rotation of the bone on the z axis
  13804. * @param space The space that the axes of rotation are in
  13805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13806. */
  13807. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13808. /**
  13809. * Add a rotation to the bone on an axis in local or world space
  13810. * @param axis The axis to rotate the bone on
  13811. * @param amount The amount to rotate the bone
  13812. * @param space The space that the axis is in
  13813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13814. */
  13815. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13816. /**
  13817. * Set the rotation of the bone to a particular axis angle in local or world space
  13818. * @param axis The axis to rotate the bone on
  13819. * @param angle The angle that the bone should be rotated to
  13820. * @param space The space that the axis is in
  13821. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13822. */
  13823. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13824. /**
  13825. * Set the euler rotation of the bone in local of world space
  13826. * @param rotation The euler rotation that the bone should be set to
  13827. * @param space The space that the rotation is in
  13828. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13829. */
  13830. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13831. /**
  13832. * Set the quaternion rotation of the bone in local of world space
  13833. * @param quat The quaternion rotation that the bone should be set to
  13834. * @param space The space that the rotation is in
  13835. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13836. */
  13837. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13838. /**
  13839. * Set the rotation matrix of the bone in local of world space
  13840. * @param rotMat The rotation matrix that the bone should be set to
  13841. * @param space The space that the rotation is in
  13842. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13843. */
  13844. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13845. private _rotateWithMatrix;
  13846. private _getNegativeRotationToRef;
  13847. /**
  13848. * Get the position of the bone in local or world space
  13849. * @param space The space that the returned position is in
  13850. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13851. * @returns The position of the bone
  13852. */
  13853. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13854. /**
  13855. * Copy the position of the bone to a vector3 in local or world space
  13856. * @param space The space that the returned position is in
  13857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13858. * @param result The vector3 to copy the position to
  13859. */
  13860. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13861. /**
  13862. * Get the absolute position of the bone (world space)
  13863. * @param mesh The mesh that this bone is attached to
  13864. * @returns The absolute position of the bone
  13865. */
  13866. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13867. /**
  13868. * Copy the absolute position of the bone (world space) to the result param
  13869. * @param mesh The mesh that this bone is attached to
  13870. * @param result The vector3 to copy the absolute position to
  13871. */
  13872. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13873. /**
  13874. * Compute the absolute transforms of this bone and its children
  13875. */
  13876. computeAbsoluteTransforms(): void;
  13877. /**
  13878. * Get the world direction from an axis that is in the local space of the bone
  13879. * @param localAxis The local direction that is used to compute the world direction
  13880. * @param mesh The mesh that this bone is attached to
  13881. * @returns The world direction
  13882. */
  13883. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13884. /**
  13885. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13886. * @param localAxis The local direction that is used to compute the world direction
  13887. * @param mesh The mesh that this bone is attached to
  13888. * @param result The vector3 that the world direction will be copied to
  13889. */
  13890. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13891. /**
  13892. * Get the euler rotation of the bone in local or world space
  13893. * @param space The space that the rotation should be in
  13894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13895. * @returns The euler rotation
  13896. */
  13897. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13898. /**
  13899. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13900. * @param space The space that the rotation should be in
  13901. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13902. * @param result The vector3 that the rotation should be copied to
  13903. */
  13904. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13905. /**
  13906. * Get the quaternion rotation of the bone in either local or world space
  13907. * @param space The space that the rotation should be in
  13908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13909. * @returns The quaternion rotation
  13910. */
  13911. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13912. /**
  13913. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13914. * @param space The space that the rotation should be in
  13915. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13916. * @param result The quaternion that the rotation should be copied to
  13917. */
  13918. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13919. /**
  13920. * Get the rotation matrix of the bone in local or world space
  13921. * @param space The space that the rotation should be in
  13922. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13923. * @returns The rotation matrix
  13924. */
  13925. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13926. /**
  13927. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13928. * @param space The space that the rotation should be in
  13929. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13930. * @param result The quaternion that the rotation should be copied to
  13931. */
  13932. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13933. /**
  13934. * Get the world position of a point that is in the local space of the bone
  13935. * @param position The local position
  13936. * @param mesh The mesh that this bone is attached to
  13937. * @returns The world position
  13938. */
  13939. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13940. /**
  13941. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13942. * @param position The local position
  13943. * @param mesh The mesh that this bone is attached to
  13944. * @param result The vector3 that the world position should be copied to
  13945. */
  13946. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13947. /**
  13948. * Get the local position of a point that is in world space
  13949. * @param position The world position
  13950. * @param mesh The mesh that this bone is attached to
  13951. * @returns The local position
  13952. */
  13953. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13954. /**
  13955. * Get the local position of a point that is in world space and copy it to the result param
  13956. * @param position The world position
  13957. * @param mesh The mesh that this bone is attached to
  13958. * @param result The vector3 that the local position should be copied to
  13959. */
  13960. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13961. }
  13962. }
  13963. declare module BABYLON {
  13964. /**
  13965. * 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.
  13966. * @see https://doc.babylonjs.com/how_to/transformnode
  13967. */
  13968. export class TransformNode extends Node {
  13969. /**
  13970. * Object will not rotate to face the camera
  13971. */
  13972. static BILLBOARDMODE_NONE: number;
  13973. /**
  13974. * Object will rotate to face the camera but only on the x axis
  13975. */
  13976. static BILLBOARDMODE_X: number;
  13977. /**
  13978. * Object will rotate to face the camera but only on the y axis
  13979. */
  13980. static BILLBOARDMODE_Y: number;
  13981. /**
  13982. * Object will rotate to face the camera but only on the z axis
  13983. */
  13984. static BILLBOARDMODE_Z: number;
  13985. /**
  13986. * Object will rotate to face the camera
  13987. */
  13988. static BILLBOARDMODE_ALL: number;
  13989. /**
  13990. * Object will rotate to face the camera's position instead of orientation
  13991. */
  13992. static BILLBOARDMODE_USE_POSITION: number;
  13993. private _forward;
  13994. private _forwardInverted;
  13995. private _up;
  13996. private _right;
  13997. private _rightInverted;
  13998. private _position;
  13999. private _rotation;
  14000. private _rotationQuaternion;
  14001. protected _scaling: Vector3;
  14002. protected _isDirty: boolean;
  14003. private _transformToBoneReferal;
  14004. private _isAbsoluteSynced;
  14005. private _billboardMode;
  14006. /**
  14007. * Gets or sets the billboard mode. Default is 0.
  14008. *
  14009. * | Value | Type | Description |
  14010. * | --- | --- | --- |
  14011. * | 0 | BILLBOARDMODE_NONE | |
  14012. * | 1 | BILLBOARDMODE_X | |
  14013. * | 2 | BILLBOARDMODE_Y | |
  14014. * | 4 | BILLBOARDMODE_Z | |
  14015. * | 7 | BILLBOARDMODE_ALL | |
  14016. *
  14017. */
  14018. billboardMode: number;
  14019. private _preserveParentRotationForBillboard;
  14020. /**
  14021. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14022. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14023. */
  14024. preserveParentRotationForBillboard: boolean;
  14025. /**
  14026. * 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
  14027. */
  14028. scalingDeterminant: number;
  14029. private _infiniteDistance;
  14030. /**
  14031. * Gets or sets the distance of the object to max, often used by skybox
  14032. */
  14033. infiniteDistance: boolean;
  14034. /**
  14035. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14036. * By default the system will update normals to compensate
  14037. */
  14038. ignoreNonUniformScaling: boolean;
  14039. /**
  14040. * 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
  14041. */
  14042. reIntegrateRotationIntoRotationQuaternion: boolean;
  14043. /** @hidden */
  14044. _poseMatrix: Nullable<Matrix>;
  14045. /** @hidden */
  14046. _localMatrix: Matrix;
  14047. private _usePivotMatrix;
  14048. private _absolutePosition;
  14049. private _absoluteScaling;
  14050. private _absoluteRotationQuaternion;
  14051. private _pivotMatrix;
  14052. private _pivotMatrixInverse;
  14053. protected _postMultiplyPivotMatrix: boolean;
  14054. protected _isWorldMatrixFrozen: boolean;
  14055. /** @hidden */
  14056. _indexInSceneTransformNodesArray: number;
  14057. /**
  14058. * An event triggered after the world matrix is updated
  14059. */
  14060. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14061. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14062. /**
  14063. * Gets a string identifying the name of the class
  14064. * @returns "TransformNode" string
  14065. */
  14066. getClassName(): string;
  14067. /**
  14068. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14069. */
  14070. position: Vector3;
  14071. /**
  14072. * 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)).
  14073. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14074. */
  14075. rotation: Vector3;
  14076. /**
  14077. * 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)).
  14078. */
  14079. scaling: Vector3;
  14080. /**
  14081. * 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).
  14082. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14083. */
  14084. rotationQuaternion: Nullable<Quaternion>;
  14085. /**
  14086. * The forward direction of that transform in world space.
  14087. */
  14088. readonly forward: Vector3;
  14089. /**
  14090. * The up direction of that transform in world space.
  14091. */
  14092. readonly up: Vector3;
  14093. /**
  14094. * The right direction of that transform in world space.
  14095. */
  14096. readonly right: Vector3;
  14097. /**
  14098. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14099. * @param matrix the matrix to copy the pose from
  14100. * @returns this TransformNode.
  14101. */
  14102. updatePoseMatrix(matrix: Matrix): TransformNode;
  14103. /**
  14104. * Returns the mesh Pose matrix.
  14105. * @returns the pose matrix
  14106. */
  14107. getPoseMatrix(): Matrix;
  14108. /** @hidden */
  14109. _isSynchronized(): boolean;
  14110. /** @hidden */
  14111. _initCache(): void;
  14112. /**
  14113. * Flag the transform node as dirty (Forcing it to update everything)
  14114. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14115. * @returns this transform node
  14116. */
  14117. markAsDirty(property: string): TransformNode;
  14118. /**
  14119. * Returns the current mesh absolute position.
  14120. * Returns a Vector3.
  14121. */
  14122. readonly absolutePosition: Vector3;
  14123. /**
  14124. * Returns the current mesh absolute scaling.
  14125. * Returns a Vector3.
  14126. */
  14127. readonly absoluteScaling: Vector3;
  14128. /**
  14129. * Returns the current mesh absolute rotation.
  14130. * Returns a Quaternion.
  14131. */
  14132. readonly absoluteRotationQuaternion: Quaternion;
  14133. /**
  14134. * Sets a new matrix to apply before all other transformation
  14135. * @param matrix defines the transform matrix
  14136. * @returns the current TransformNode
  14137. */
  14138. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14139. /**
  14140. * Sets a new pivot matrix to the current node
  14141. * @param matrix defines the new pivot matrix to use
  14142. * @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
  14143. * @returns the current TransformNode
  14144. */
  14145. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14146. /**
  14147. * Returns the mesh pivot matrix.
  14148. * Default : Identity.
  14149. * @returns the matrix
  14150. */
  14151. getPivotMatrix(): Matrix;
  14152. /**
  14153. * Instantiate (when possible) or clone that node with its hierarchy
  14154. * @param newParent defines the new parent to use for the instance (or clone)
  14155. * @param options defines options to configure how copy is done
  14156. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14157. * @returns an instance (or a clone) of the current node with its hiearchy
  14158. */
  14159. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14160. doNotInstantiate: boolean;
  14161. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14162. /**
  14163. * Prevents the World matrix to be computed any longer
  14164. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14165. * @returns the TransformNode.
  14166. */
  14167. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14168. /**
  14169. * Allows back the World matrix computation.
  14170. * @returns the TransformNode.
  14171. */
  14172. unfreezeWorldMatrix(): this;
  14173. /**
  14174. * True if the World matrix has been frozen.
  14175. */
  14176. readonly isWorldMatrixFrozen: boolean;
  14177. /**
  14178. * Retuns the mesh absolute position in the World.
  14179. * @returns a Vector3.
  14180. */
  14181. getAbsolutePosition(): Vector3;
  14182. /**
  14183. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14184. * @param absolutePosition the absolute position to set
  14185. * @returns the TransformNode.
  14186. */
  14187. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14188. /**
  14189. * Sets the mesh position in its local space.
  14190. * @param vector3 the position to set in localspace
  14191. * @returns the TransformNode.
  14192. */
  14193. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14194. /**
  14195. * Returns the mesh position in the local space from the current World matrix values.
  14196. * @returns a new Vector3.
  14197. */
  14198. getPositionExpressedInLocalSpace(): Vector3;
  14199. /**
  14200. * Translates the mesh along the passed Vector3 in its local space.
  14201. * @param vector3 the distance to translate in localspace
  14202. * @returns the TransformNode.
  14203. */
  14204. locallyTranslate(vector3: Vector3): TransformNode;
  14205. private static _lookAtVectorCache;
  14206. /**
  14207. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14208. * @param targetPoint the position (must be in same space as current mesh) to look at
  14209. * @param yawCor optional yaw (y-axis) correction in radians
  14210. * @param pitchCor optional pitch (x-axis) correction in radians
  14211. * @param rollCor optional roll (z-axis) correction in radians
  14212. * @param space the choosen space of the target
  14213. * @returns the TransformNode.
  14214. */
  14215. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14216. /**
  14217. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14218. * This Vector3 is expressed in the World space.
  14219. * @param localAxis axis to rotate
  14220. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14221. */
  14222. getDirection(localAxis: Vector3): Vector3;
  14223. /**
  14224. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14225. * localAxis is expressed in the mesh local space.
  14226. * result is computed in the Wordl space from the mesh World matrix.
  14227. * @param localAxis axis to rotate
  14228. * @param result the resulting transformnode
  14229. * @returns this TransformNode.
  14230. */
  14231. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14232. /**
  14233. * Sets this transform node rotation to the given local axis.
  14234. * @param localAxis the axis in local space
  14235. * @param yawCor optional yaw (y-axis) correction in radians
  14236. * @param pitchCor optional pitch (x-axis) correction in radians
  14237. * @param rollCor optional roll (z-axis) correction in radians
  14238. * @returns this TransformNode
  14239. */
  14240. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14241. /**
  14242. * Sets a new pivot point to the current node
  14243. * @param point defines the new pivot point to use
  14244. * @param space defines if the point is in world or local space (local by default)
  14245. * @returns the current TransformNode
  14246. */
  14247. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14248. /**
  14249. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14250. * @returns the pivot point
  14251. */
  14252. getPivotPoint(): Vector3;
  14253. /**
  14254. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14255. * @param result the vector3 to store the result
  14256. * @returns this TransformNode.
  14257. */
  14258. getPivotPointToRef(result: Vector3): TransformNode;
  14259. /**
  14260. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14261. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14262. */
  14263. getAbsolutePivotPoint(): Vector3;
  14264. /**
  14265. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14266. * @param result vector3 to store the result
  14267. * @returns this TransformNode.
  14268. */
  14269. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14270. /**
  14271. * Defines the passed node as the parent of the current node.
  14272. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14273. * @see https://doc.babylonjs.com/how_to/parenting
  14274. * @param node the node ot set as the parent
  14275. * @returns this TransformNode.
  14276. */
  14277. setParent(node: Nullable<Node>): TransformNode;
  14278. private _nonUniformScaling;
  14279. /**
  14280. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14281. */
  14282. readonly nonUniformScaling: boolean;
  14283. /** @hidden */
  14284. _updateNonUniformScalingState(value: boolean): boolean;
  14285. /**
  14286. * Attach the current TransformNode to another TransformNode associated with a bone
  14287. * @param bone Bone affecting the TransformNode
  14288. * @param affectedTransformNode TransformNode associated with the bone
  14289. * @returns this object
  14290. */
  14291. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14292. /**
  14293. * Detach the transform node if its associated with a bone
  14294. * @returns this object
  14295. */
  14296. detachFromBone(): TransformNode;
  14297. private static _rotationAxisCache;
  14298. /**
  14299. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14300. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14301. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14302. * The passed axis is also normalized.
  14303. * @param axis the axis to rotate around
  14304. * @param amount the amount to rotate in radians
  14305. * @param space Space to rotate in (Default: local)
  14306. * @returns the TransformNode.
  14307. */
  14308. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14309. /**
  14310. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14311. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14312. * The passed axis is also normalized. .
  14313. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14314. * @param point the point to rotate around
  14315. * @param axis the axis to rotate around
  14316. * @param amount the amount to rotate in radians
  14317. * @returns the TransformNode
  14318. */
  14319. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14320. /**
  14321. * Translates the mesh along the axis vector for the passed distance in the given space.
  14322. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14323. * @param axis the axis to translate in
  14324. * @param distance the distance to translate
  14325. * @param space Space to rotate in (Default: local)
  14326. * @returns the TransformNode.
  14327. */
  14328. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14329. /**
  14330. * Adds a rotation step to the mesh current rotation.
  14331. * x, y, z are Euler angles expressed in radians.
  14332. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14333. * This means this rotation is made in the mesh local space only.
  14334. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14335. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14336. * ```javascript
  14337. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14338. * ```
  14339. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14340. * 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.
  14341. * @param x Rotation to add
  14342. * @param y Rotation to add
  14343. * @param z Rotation to add
  14344. * @returns the TransformNode.
  14345. */
  14346. addRotation(x: number, y: number, z: number): TransformNode;
  14347. /**
  14348. * @hidden
  14349. */
  14350. protected _getEffectiveParent(): Nullable<Node>;
  14351. /**
  14352. * Computes the world matrix of the node
  14353. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14354. * @returns the world matrix
  14355. */
  14356. computeWorldMatrix(force?: boolean): Matrix;
  14357. protected _afterComputeWorldMatrix(): void;
  14358. /**
  14359. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14360. * @param func callback function to add
  14361. *
  14362. * @returns the TransformNode.
  14363. */
  14364. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14365. /**
  14366. * Removes a registered callback function.
  14367. * @param func callback function to remove
  14368. * @returns the TransformNode.
  14369. */
  14370. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14371. /**
  14372. * Gets the position of the current mesh in camera space
  14373. * @param camera defines the camera to use
  14374. * @returns a position
  14375. */
  14376. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14377. /**
  14378. * Returns the distance from the mesh to the active camera
  14379. * @param camera defines the camera to use
  14380. * @returns the distance
  14381. */
  14382. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14383. /**
  14384. * Clone the current transform node
  14385. * @param name Name of the new clone
  14386. * @param newParent New parent for the clone
  14387. * @param doNotCloneChildren Do not clone children hierarchy
  14388. * @returns the new transform node
  14389. */
  14390. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14391. /**
  14392. * Serializes the objects information.
  14393. * @param currentSerializationObject defines the object to serialize in
  14394. * @returns the serialized object
  14395. */
  14396. serialize(currentSerializationObject?: any): any;
  14397. /**
  14398. * Returns a new TransformNode object parsed from the source provided.
  14399. * @param parsedTransformNode is the source.
  14400. * @param scene the scne the object belongs to
  14401. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14402. * @returns a new TransformNode object parsed from the source provided.
  14403. */
  14404. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14405. /**
  14406. * Get all child-transformNodes of this node
  14407. * @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
  14408. * @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
  14409. * @returns an array of TransformNode
  14410. */
  14411. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14412. /**
  14413. * Releases resources associated with this transform node.
  14414. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14415. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14416. */
  14417. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14418. /**
  14419. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14420. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14421. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14422. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14423. * @returns the current mesh
  14424. */
  14425. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14426. private _syncAbsoluteScalingAndRotation;
  14427. }
  14428. }
  14429. declare module BABYLON {
  14430. /**
  14431. * Defines the types of pose enabled controllers that are supported
  14432. */
  14433. export enum PoseEnabledControllerType {
  14434. /**
  14435. * HTC Vive
  14436. */
  14437. VIVE = 0,
  14438. /**
  14439. * Oculus Rift
  14440. */
  14441. OCULUS = 1,
  14442. /**
  14443. * Windows mixed reality
  14444. */
  14445. WINDOWS = 2,
  14446. /**
  14447. * Samsung gear VR
  14448. */
  14449. GEAR_VR = 3,
  14450. /**
  14451. * Google Daydream
  14452. */
  14453. DAYDREAM = 4,
  14454. /**
  14455. * Generic
  14456. */
  14457. GENERIC = 5
  14458. }
  14459. /**
  14460. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14461. */
  14462. export interface MutableGamepadButton {
  14463. /**
  14464. * Value of the button/trigger
  14465. */
  14466. value: number;
  14467. /**
  14468. * If the button/trigger is currently touched
  14469. */
  14470. touched: boolean;
  14471. /**
  14472. * If the button/trigger is currently pressed
  14473. */
  14474. pressed: boolean;
  14475. }
  14476. /**
  14477. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14478. * @hidden
  14479. */
  14480. export interface ExtendedGamepadButton extends GamepadButton {
  14481. /**
  14482. * If the button/trigger is currently pressed
  14483. */
  14484. readonly pressed: boolean;
  14485. /**
  14486. * If the button/trigger is currently touched
  14487. */
  14488. readonly touched: boolean;
  14489. /**
  14490. * Value of the button/trigger
  14491. */
  14492. readonly value: number;
  14493. }
  14494. /** @hidden */
  14495. export interface _GamePadFactory {
  14496. /**
  14497. * Returns wether or not the current gamepad can be created for this type of controller.
  14498. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14499. * @returns true if it can be created, otherwise false
  14500. */
  14501. canCreate(gamepadInfo: any): boolean;
  14502. /**
  14503. * Creates a new instance of the Gamepad.
  14504. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14505. * @returns the new gamepad instance
  14506. */
  14507. create(gamepadInfo: any): Gamepad;
  14508. }
  14509. /**
  14510. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14511. */
  14512. export class PoseEnabledControllerHelper {
  14513. /** @hidden */
  14514. static _ControllerFactories: _GamePadFactory[];
  14515. /** @hidden */
  14516. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14517. /**
  14518. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14519. * @param vrGamepad the gamepad to initialized
  14520. * @returns a vr controller of the type the gamepad identified as
  14521. */
  14522. static InitiateController(vrGamepad: any): Gamepad;
  14523. }
  14524. /**
  14525. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14526. */
  14527. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14528. /**
  14529. * If the controller is used in a webXR session
  14530. */
  14531. isXR: boolean;
  14532. private _deviceRoomPosition;
  14533. private _deviceRoomRotationQuaternion;
  14534. /**
  14535. * The device position in babylon space
  14536. */
  14537. devicePosition: Vector3;
  14538. /**
  14539. * The device rotation in babylon space
  14540. */
  14541. deviceRotationQuaternion: Quaternion;
  14542. /**
  14543. * The scale factor of the device in babylon space
  14544. */
  14545. deviceScaleFactor: number;
  14546. /**
  14547. * (Likely devicePosition should be used instead) The device position in its room space
  14548. */
  14549. position: Vector3;
  14550. /**
  14551. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14552. */
  14553. rotationQuaternion: Quaternion;
  14554. /**
  14555. * The type of controller (Eg. Windows mixed reality)
  14556. */
  14557. controllerType: PoseEnabledControllerType;
  14558. protected _calculatedPosition: Vector3;
  14559. private _calculatedRotation;
  14560. /**
  14561. * The raw pose from the device
  14562. */
  14563. rawPose: DevicePose;
  14564. private _trackPosition;
  14565. private _maxRotationDistFromHeadset;
  14566. private _draggedRoomRotation;
  14567. /**
  14568. * @hidden
  14569. */
  14570. _disableTrackPosition(fixedPosition: Vector3): void;
  14571. /**
  14572. * Internal, the mesh attached to the controller
  14573. * @hidden
  14574. */
  14575. _mesh: Nullable<AbstractMesh>;
  14576. private _poseControlledCamera;
  14577. private _leftHandSystemQuaternion;
  14578. /**
  14579. * Internal, matrix used to convert room space to babylon space
  14580. * @hidden
  14581. */
  14582. _deviceToWorld: Matrix;
  14583. /**
  14584. * Node to be used when casting a ray from the controller
  14585. * @hidden
  14586. */
  14587. _pointingPoseNode: Nullable<TransformNode>;
  14588. /**
  14589. * Name of the child mesh that can be used to cast a ray from the controller
  14590. */
  14591. static readonly POINTING_POSE: string;
  14592. /**
  14593. * Creates a new PoseEnabledController from a gamepad
  14594. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14595. */
  14596. constructor(browserGamepad: any);
  14597. private _workingMatrix;
  14598. /**
  14599. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14600. */
  14601. update(): void;
  14602. /**
  14603. * Updates only the pose device and mesh without doing any button event checking
  14604. */
  14605. protected _updatePoseAndMesh(): void;
  14606. /**
  14607. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14608. * @param poseData raw pose fromthe device
  14609. */
  14610. updateFromDevice(poseData: DevicePose): void;
  14611. /**
  14612. * @hidden
  14613. */
  14614. _meshAttachedObservable: Observable<AbstractMesh>;
  14615. /**
  14616. * Attaches a mesh to the controller
  14617. * @param mesh the mesh to be attached
  14618. */
  14619. attachToMesh(mesh: AbstractMesh): void;
  14620. /**
  14621. * Attaches the controllers mesh to a camera
  14622. * @param camera the camera the mesh should be attached to
  14623. */
  14624. attachToPoseControlledCamera(camera: TargetCamera): void;
  14625. /**
  14626. * Disposes of the controller
  14627. */
  14628. dispose(): void;
  14629. /**
  14630. * The mesh that is attached to the controller
  14631. */
  14632. readonly mesh: Nullable<AbstractMesh>;
  14633. /**
  14634. * Gets the ray of the controller in the direction the controller is pointing
  14635. * @param length the length the resulting ray should be
  14636. * @returns a ray in the direction the controller is pointing
  14637. */
  14638. getForwardRay(length?: number): Ray;
  14639. }
  14640. }
  14641. declare module BABYLON {
  14642. /**
  14643. * Defines the WebVRController object that represents controllers tracked in 3D space
  14644. */
  14645. export abstract class WebVRController extends PoseEnabledController {
  14646. /**
  14647. * Internal, the default controller model for the controller
  14648. */
  14649. protected _defaultModel: Nullable<AbstractMesh>;
  14650. /**
  14651. * Fired when the trigger state has changed
  14652. */
  14653. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14654. /**
  14655. * Fired when the main button state has changed
  14656. */
  14657. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14658. /**
  14659. * Fired when the secondary button state has changed
  14660. */
  14661. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14662. /**
  14663. * Fired when the pad state has changed
  14664. */
  14665. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14666. /**
  14667. * Fired when controllers stick values have changed
  14668. */
  14669. onPadValuesChangedObservable: Observable<StickValues>;
  14670. /**
  14671. * Array of button availible on the controller
  14672. */
  14673. protected _buttons: Array<MutableGamepadButton>;
  14674. private _onButtonStateChange;
  14675. /**
  14676. * Fired when a controller button's state has changed
  14677. * @param callback the callback containing the button that was modified
  14678. */
  14679. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14680. /**
  14681. * X and Y axis corresponding to the controllers joystick
  14682. */
  14683. pad: StickValues;
  14684. /**
  14685. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14686. */
  14687. hand: string;
  14688. /**
  14689. * The default controller model for the controller
  14690. */
  14691. readonly defaultModel: Nullable<AbstractMesh>;
  14692. /**
  14693. * Creates a new WebVRController from a gamepad
  14694. * @param vrGamepad the gamepad that the WebVRController should be created from
  14695. */
  14696. constructor(vrGamepad: any);
  14697. /**
  14698. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14699. */
  14700. update(): void;
  14701. /**
  14702. * Function to be called when a button is modified
  14703. */
  14704. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14705. /**
  14706. * Loads a mesh and attaches it to the controller
  14707. * @param scene the scene the mesh should be added to
  14708. * @param meshLoaded callback for when the mesh has been loaded
  14709. */
  14710. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14711. private _setButtonValue;
  14712. private _changes;
  14713. private _checkChanges;
  14714. /**
  14715. * Disposes of th webVRCOntroller
  14716. */
  14717. dispose(): void;
  14718. }
  14719. }
  14720. declare module BABYLON {
  14721. /**
  14722. * The HemisphericLight simulates the ambient environment light,
  14723. * so the passed direction is the light reflection direction, not the incoming direction.
  14724. */
  14725. export class HemisphericLight extends Light {
  14726. /**
  14727. * The groundColor is the light in the opposite direction to the one specified during creation.
  14728. * 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.
  14729. */
  14730. groundColor: Color3;
  14731. /**
  14732. * The light reflection direction, not the incoming direction.
  14733. */
  14734. direction: Vector3;
  14735. /**
  14736. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14737. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14738. * The HemisphericLight can't cast shadows.
  14739. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14740. * @param name The friendly name of the light
  14741. * @param direction The direction of the light reflection
  14742. * @param scene The scene the light belongs to
  14743. */
  14744. constructor(name: string, direction: Vector3, scene: Scene);
  14745. protected _buildUniformLayout(): void;
  14746. /**
  14747. * Returns the string "HemisphericLight".
  14748. * @return The class name
  14749. */
  14750. getClassName(): string;
  14751. /**
  14752. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14753. * Returns the updated direction.
  14754. * @param target The target the direction should point to
  14755. * @return The computed direction
  14756. */
  14757. setDirectionToTarget(target: Vector3): Vector3;
  14758. /**
  14759. * Returns the shadow generator associated to the light.
  14760. * @returns Always null for hemispheric lights because it does not support shadows.
  14761. */
  14762. getShadowGenerator(): Nullable<IShadowGenerator>;
  14763. /**
  14764. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14765. * @param effect The effect to update
  14766. * @param lightIndex The index of the light in the effect to update
  14767. * @returns The hemispheric light
  14768. */
  14769. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14770. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14771. /**
  14772. * Computes the world matrix of the node
  14773. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14774. * @param useWasUpdatedFlag defines a reserved property
  14775. * @returns the world matrix
  14776. */
  14777. computeWorldMatrix(): Matrix;
  14778. /**
  14779. * Returns the integer 3.
  14780. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14781. */
  14782. getTypeID(): number;
  14783. /**
  14784. * Prepares the list of defines specific to the light type.
  14785. * @param defines the list of defines
  14786. * @param lightIndex defines the index of the light for the effect
  14787. */
  14788. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14789. }
  14790. }
  14791. declare module BABYLON {
  14792. /** @hidden */
  14793. export var vrMultiviewToSingleviewPixelShader: {
  14794. name: string;
  14795. shader: string;
  14796. };
  14797. }
  14798. declare module BABYLON {
  14799. /**
  14800. * Renders to multiple views with a single draw call
  14801. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14802. */
  14803. export class MultiviewRenderTarget extends RenderTargetTexture {
  14804. /**
  14805. * Creates a multiview render target
  14806. * @param scene scene used with the render target
  14807. * @param size the size of the render target (used for each view)
  14808. */
  14809. constructor(scene: Scene, size?: number | {
  14810. width: number;
  14811. height: number;
  14812. } | {
  14813. ratio: number;
  14814. });
  14815. /**
  14816. * @hidden
  14817. * @param faceIndex the face index, if its a cube texture
  14818. */
  14819. _bindFrameBuffer(faceIndex?: number): void;
  14820. /**
  14821. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14822. * @returns the view count
  14823. */
  14824. getViewCount(): number;
  14825. }
  14826. }
  14827. declare module BABYLON {
  14828. /**
  14829. * Represents a camera frustum
  14830. */
  14831. export class Frustum {
  14832. /**
  14833. * Gets the planes representing the frustum
  14834. * @param transform matrix to be applied to the returned planes
  14835. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14836. */
  14837. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14838. /**
  14839. * Gets the near frustum plane transformed by the transform matrix
  14840. * @param transform transformation matrix to be applied to the resulting frustum plane
  14841. * @param frustumPlane the resuling frustum plane
  14842. */
  14843. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14844. /**
  14845. * Gets the far frustum plane transformed by the transform matrix
  14846. * @param transform transformation matrix to be applied to the resulting frustum plane
  14847. * @param frustumPlane the resuling frustum plane
  14848. */
  14849. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14850. /**
  14851. * Gets the left frustum plane transformed by the transform matrix
  14852. * @param transform transformation matrix to be applied to the resulting frustum plane
  14853. * @param frustumPlane the resuling frustum plane
  14854. */
  14855. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14856. /**
  14857. * Gets the right frustum plane transformed by the transform matrix
  14858. * @param transform transformation matrix to be applied to the resulting frustum plane
  14859. * @param frustumPlane the resuling frustum plane
  14860. */
  14861. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14862. /**
  14863. * Gets the top frustum plane transformed by the transform matrix
  14864. * @param transform transformation matrix to be applied to the resulting frustum plane
  14865. * @param frustumPlane the resuling frustum plane
  14866. */
  14867. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14868. /**
  14869. * Gets the bottom frustum plane transformed by the transform matrix
  14870. * @param transform transformation matrix to be applied to the resulting frustum plane
  14871. * @param frustumPlane the resuling frustum plane
  14872. */
  14873. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14874. /**
  14875. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14876. * @param transform transformation matrix to be applied to the resulting frustum planes
  14877. * @param frustumPlanes the resuling frustum planes
  14878. */
  14879. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14880. }
  14881. }
  14882. declare module BABYLON {
  14883. interface Engine {
  14884. /**
  14885. * Creates a new multiview render target
  14886. * @param width defines the width of the texture
  14887. * @param height defines the height of the texture
  14888. * @returns the created multiview texture
  14889. */
  14890. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14891. /**
  14892. * Binds a multiview framebuffer to be drawn to
  14893. * @param multiviewTexture texture to bind
  14894. */
  14895. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14896. }
  14897. interface Camera {
  14898. /**
  14899. * @hidden
  14900. * 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)
  14901. */
  14902. _useMultiviewToSingleView: boolean;
  14903. /**
  14904. * @hidden
  14905. * 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)
  14906. */
  14907. _multiviewTexture: Nullable<RenderTargetTexture>;
  14908. /**
  14909. * @hidden
  14910. * ensures the multiview texture of the camera exists and has the specified width/height
  14911. * @param width height to set on the multiview texture
  14912. * @param height width to set on the multiview texture
  14913. */
  14914. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14915. }
  14916. interface Scene {
  14917. /** @hidden */
  14918. _transformMatrixR: Matrix;
  14919. /** @hidden */
  14920. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14921. /** @hidden */
  14922. _createMultiviewUbo(): void;
  14923. /** @hidden */
  14924. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14925. /** @hidden */
  14926. _renderMultiviewToSingleView(camera: Camera): void;
  14927. }
  14928. }
  14929. declare module BABYLON {
  14930. /**
  14931. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14932. * This will not be used for webXR as it supports displaying texture arrays directly
  14933. */
  14934. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14935. /**
  14936. * Initializes a VRMultiviewToSingleview
  14937. * @param name name of the post process
  14938. * @param camera camera to be applied to
  14939. * @param scaleFactor scaling factor to the size of the output texture
  14940. */
  14941. constructor(name: string, camera: Camera, scaleFactor: number);
  14942. }
  14943. }
  14944. declare module BABYLON {
  14945. /**
  14946. * Interface used to define additional presentation attributes
  14947. */
  14948. export interface IVRPresentationAttributes {
  14949. /**
  14950. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  14951. */
  14952. highRefreshRate: boolean;
  14953. /**
  14954. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  14955. */
  14956. foveationLevel: number;
  14957. }
  14958. interface Engine {
  14959. /** @hidden */
  14960. _vrDisplay: any;
  14961. /** @hidden */
  14962. _vrSupported: boolean;
  14963. /** @hidden */
  14964. _oldSize: Size;
  14965. /** @hidden */
  14966. _oldHardwareScaleFactor: number;
  14967. /** @hidden */
  14968. _vrExclusivePointerMode: boolean;
  14969. /** @hidden */
  14970. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14971. /** @hidden */
  14972. _onVRDisplayPointerRestricted: () => void;
  14973. /** @hidden */
  14974. _onVRDisplayPointerUnrestricted: () => void;
  14975. /** @hidden */
  14976. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14977. /** @hidden */
  14978. _onVrDisplayDisconnect: Nullable<() => void>;
  14979. /** @hidden */
  14980. _onVrDisplayPresentChange: Nullable<() => void>;
  14981. /**
  14982. * Observable signaled when VR display mode changes
  14983. */
  14984. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14985. /**
  14986. * Observable signaled when VR request present is complete
  14987. */
  14988. onVRRequestPresentComplete: Observable<boolean>;
  14989. /**
  14990. * Observable signaled when VR request present starts
  14991. */
  14992. onVRRequestPresentStart: Observable<Engine>;
  14993. /**
  14994. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14995. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14996. */
  14997. isInVRExclusivePointerMode: boolean;
  14998. /**
  14999. * Gets a boolean indicating if a webVR device was detected
  15000. * @returns true if a webVR device was detected
  15001. */
  15002. isVRDevicePresent(): boolean;
  15003. /**
  15004. * Gets the current webVR device
  15005. * @returns the current webVR device (or null)
  15006. */
  15007. getVRDevice(): any;
  15008. /**
  15009. * Initializes a webVR display and starts listening to display change events
  15010. * The onVRDisplayChangedObservable will be notified upon these changes
  15011. * @returns A promise containing a VRDisplay and if vr is supported
  15012. */
  15013. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15014. /** @hidden */
  15015. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15016. /**
  15017. * Gets or sets the presentation attributes used to configure VR rendering
  15018. */
  15019. vrPresentationAttributes?: IVRPresentationAttributes;
  15020. /**
  15021. * Call this function to switch to webVR mode
  15022. * Will do nothing if webVR is not supported or if there is no webVR device
  15023. * @param options the webvr options provided to the camera. mainly used for multiview
  15024. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15025. */
  15026. enableVR(options: WebVROptions): void;
  15027. /** @hidden */
  15028. _onVRFullScreenTriggered(): void;
  15029. }
  15030. }
  15031. declare module BABYLON {
  15032. /**
  15033. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15034. * IMPORTANT!! The data is right-hand data.
  15035. * @export
  15036. * @interface DevicePose
  15037. */
  15038. export interface DevicePose {
  15039. /**
  15040. * The position of the device, values in array are [x,y,z].
  15041. */
  15042. readonly position: Nullable<Float32Array>;
  15043. /**
  15044. * The linearVelocity of the device, values in array are [x,y,z].
  15045. */
  15046. readonly linearVelocity: Nullable<Float32Array>;
  15047. /**
  15048. * The linearAcceleration of the device, values in array are [x,y,z].
  15049. */
  15050. readonly linearAcceleration: Nullable<Float32Array>;
  15051. /**
  15052. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15053. */
  15054. readonly orientation: Nullable<Float32Array>;
  15055. /**
  15056. * The angularVelocity of the device, values in array are [x,y,z].
  15057. */
  15058. readonly angularVelocity: Nullable<Float32Array>;
  15059. /**
  15060. * The angularAcceleration of the device, values in array are [x,y,z].
  15061. */
  15062. readonly angularAcceleration: Nullable<Float32Array>;
  15063. }
  15064. /**
  15065. * Interface representing a pose controlled object in Babylon.
  15066. * A pose controlled object has both regular pose values as well as pose values
  15067. * from an external device such as a VR head mounted display
  15068. */
  15069. export interface PoseControlled {
  15070. /**
  15071. * The position of the object in babylon space.
  15072. */
  15073. position: Vector3;
  15074. /**
  15075. * The rotation quaternion of the object in babylon space.
  15076. */
  15077. rotationQuaternion: Quaternion;
  15078. /**
  15079. * The position of the device in babylon space.
  15080. */
  15081. devicePosition?: Vector3;
  15082. /**
  15083. * The rotation quaternion of the device in babylon space.
  15084. */
  15085. deviceRotationQuaternion: Quaternion;
  15086. /**
  15087. * The raw pose coming from the device.
  15088. */
  15089. rawPose: Nullable<DevicePose>;
  15090. /**
  15091. * The scale of the device to be used when translating from device space to babylon space.
  15092. */
  15093. deviceScaleFactor: number;
  15094. /**
  15095. * Updates the poseControlled values based on the input device pose.
  15096. * @param poseData the pose data to update the object with
  15097. */
  15098. updateFromDevice(poseData: DevicePose): void;
  15099. }
  15100. /**
  15101. * Set of options to customize the webVRCamera
  15102. */
  15103. export interface WebVROptions {
  15104. /**
  15105. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15106. */
  15107. trackPosition?: boolean;
  15108. /**
  15109. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15110. */
  15111. positionScale?: number;
  15112. /**
  15113. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15114. */
  15115. displayName?: string;
  15116. /**
  15117. * Should the native controller meshes be initialized. (default: true)
  15118. */
  15119. controllerMeshes?: boolean;
  15120. /**
  15121. * Creating a default HemiLight only on controllers. (default: true)
  15122. */
  15123. defaultLightingOnControllers?: boolean;
  15124. /**
  15125. * If you don't want to use the default VR button of the helper. (default: false)
  15126. */
  15127. useCustomVRButton?: boolean;
  15128. /**
  15129. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15130. */
  15131. customVRButton?: HTMLButtonElement;
  15132. /**
  15133. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15134. */
  15135. rayLength?: number;
  15136. /**
  15137. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15138. */
  15139. defaultHeight?: number;
  15140. /**
  15141. * If multiview should be used if availible (default: false)
  15142. */
  15143. useMultiview?: boolean;
  15144. }
  15145. /**
  15146. * This represents a WebVR camera.
  15147. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15148. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15149. */
  15150. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15151. private webVROptions;
  15152. /**
  15153. * @hidden
  15154. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15155. */
  15156. _vrDevice: any;
  15157. /**
  15158. * The rawPose of the vrDevice.
  15159. */
  15160. rawPose: Nullable<DevicePose>;
  15161. private _onVREnabled;
  15162. private _specsVersion;
  15163. private _attached;
  15164. private _frameData;
  15165. protected _descendants: Array<Node>;
  15166. private _deviceRoomPosition;
  15167. /** @hidden */
  15168. _deviceRoomRotationQuaternion: Quaternion;
  15169. private _standingMatrix;
  15170. /**
  15171. * Represents device position in babylon space.
  15172. */
  15173. devicePosition: Vector3;
  15174. /**
  15175. * Represents device rotation in babylon space.
  15176. */
  15177. deviceRotationQuaternion: Quaternion;
  15178. /**
  15179. * The scale of the device to be used when translating from device space to babylon space.
  15180. */
  15181. deviceScaleFactor: number;
  15182. private _deviceToWorld;
  15183. private _worldToDevice;
  15184. /**
  15185. * References to the webVR controllers for the vrDevice.
  15186. */
  15187. controllers: Array<WebVRController>;
  15188. /**
  15189. * Emits an event when a controller is attached.
  15190. */
  15191. onControllersAttachedObservable: Observable<WebVRController[]>;
  15192. /**
  15193. * Emits an event when a controller's mesh has been loaded;
  15194. */
  15195. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15196. /**
  15197. * Emits an event when the HMD's pose has been updated.
  15198. */
  15199. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15200. private _poseSet;
  15201. /**
  15202. * If the rig cameras be used as parent instead of this camera.
  15203. */
  15204. rigParenting: boolean;
  15205. private _lightOnControllers;
  15206. private _defaultHeight?;
  15207. /**
  15208. * Instantiates a WebVRFreeCamera.
  15209. * @param name The name of the WebVRFreeCamera
  15210. * @param position The starting anchor position for the camera
  15211. * @param scene The scene the camera belongs to
  15212. * @param webVROptions a set of customizable options for the webVRCamera
  15213. */
  15214. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15215. /**
  15216. * Gets the device distance from the ground in meters.
  15217. * @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.
  15218. */
  15219. deviceDistanceToRoomGround(): number;
  15220. /**
  15221. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15222. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15223. */
  15224. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15225. /**
  15226. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15227. * @returns A promise with a boolean set to if the standing matrix is supported.
  15228. */
  15229. useStandingMatrixAsync(): Promise<boolean>;
  15230. /**
  15231. * Disposes the camera
  15232. */
  15233. dispose(): void;
  15234. /**
  15235. * Gets a vrController by name.
  15236. * @param name The name of the controller to retreive
  15237. * @returns the controller matching the name specified or null if not found
  15238. */
  15239. getControllerByName(name: string): Nullable<WebVRController>;
  15240. private _leftController;
  15241. /**
  15242. * The controller corresponding to the users left hand.
  15243. */
  15244. readonly leftController: Nullable<WebVRController>;
  15245. private _rightController;
  15246. /**
  15247. * The controller corresponding to the users right hand.
  15248. */
  15249. readonly rightController: Nullable<WebVRController>;
  15250. /**
  15251. * Casts a ray forward from the vrCamera's gaze.
  15252. * @param length Length of the ray (default: 100)
  15253. * @returns the ray corresponding to the gaze
  15254. */
  15255. getForwardRay(length?: number): Ray;
  15256. /**
  15257. * @hidden
  15258. * Updates the camera based on device's frame data
  15259. */
  15260. _checkInputs(): void;
  15261. /**
  15262. * Updates the poseControlled values based on the input device pose.
  15263. * @param poseData Pose coming from the device
  15264. */
  15265. updateFromDevice(poseData: DevicePose): void;
  15266. private _htmlElementAttached;
  15267. private _detachIfAttached;
  15268. /**
  15269. * WebVR's attach control will start broadcasting frames to the device.
  15270. * Note that in certain browsers (chrome for example) this function must be called
  15271. * within a user-interaction callback. Example:
  15272. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15273. *
  15274. * @param element html element to attach the vrDevice to
  15275. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15276. */
  15277. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15278. /**
  15279. * Detaches the camera from the html element and disables VR
  15280. *
  15281. * @param element html element to detach from
  15282. */
  15283. detachControl(element: HTMLElement): void;
  15284. /**
  15285. * @returns the name of this class
  15286. */
  15287. getClassName(): string;
  15288. /**
  15289. * Calls resetPose on the vrDisplay
  15290. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15291. */
  15292. resetToCurrentRotation(): void;
  15293. /**
  15294. * @hidden
  15295. * Updates the rig cameras (left and right eye)
  15296. */
  15297. _updateRigCameras(): void;
  15298. private _workingVector;
  15299. private _oneVector;
  15300. private _workingMatrix;
  15301. private updateCacheCalled;
  15302. private _correctPositionIfNotTrackPosition;
  15303. /**
  15304. * @hidden
  15305. * Updates the cached values of the camera
  15306. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15307. */
  15308. _updateCache(ignoreParentClass?: boolean): void;
  15309. /**
  15310. * @hidden
  15311. * Get current device position in babylon world
  15312. */
  15313. _computeDevicePosition(): void;
  15314. /**
  15315. * Updates the current device position and rotation in the babylon world
  15316. */
  15317. update(): void;
  15318. /**
  15319. * @hidden
  15320. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15321. * @returns an identity matrix
  15322. */
  15323. _getViewMatrix(): Matrix;
  15324. private _tmpMatrix;
  15325. /**
  15326. * This function is called by the two RIG cameras.
  15327. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15328. * @hidden
  15329. */
  15330. _getWebVRViewMatrix(): Matrix;
  15331. /** @hidden */
  15332. _getWebVRProjectionMatrix(): Matrix;
  15333. private _onGamepadConnectedObserver;
  15334. private _onGamepadDisconnectedObserver;
  15335. private _updateCacheWhenTrackingDisabledObserver;
  15336. /**
  15337. * Initializes the controllers and their meshes
  15338. */
  15339. initControllers(): void;
  15340. }
  15341. }
  15342. declare module BABYLON {
  15343. /**
  15344. * Size options for a post process
  15345. */
  15346. export type PostProcessOptions = {
  15347. width: number;
  15348. height: number;
  15349. };
  15350. /**
  15351. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15352. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15353. */
  15354. export class PostProcess {
  15355. /** Name of the PostProcess. */
  15356. name: string;
  15357. /**
  15358. * Gets or sets the unique id of the post process
  15359. */
  15360. uniqueId: number;
  15361. /**
  15362. * Width of the texture to apply the post process on
  15363. */
  15364. width: number;
  15365. /**
  15366. * Height of the texture to apply the post process on
  15367. */
  15368. height: number;
  15369. /**
  15370. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15371. * @hidden
  15372. */
  15373. _outputTexture: Nullable<InternalTexture>;
  15374. /**
  15375. * Sampling mode used by the shader
  15376. * See https://doc.babylonjs.com/classes/3.1/texture
  15377. */
  15378. renderTargetSamplingMode: number;
  15379. /**
  15380. * Clear color to use when screen clearing
  15381. */
  15382. clearColor: Color4;
  15383. /**
  15384. * If the buffer needs to be cleared before applying the post process. (default: true)
  15385. * Should be set to false if shader will overwrite all previous pixels.
  15386. */
  15387. autoClear: boolean;
  15388. /**
  15389. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15390. */
  15391. alphaMode: number;
  15392. /**
  15393. * Sets the setAlphaBlendConstants of the babylon engine
  15394. */
  15395. alphaConstants: Color4;
  15396. /**
  15397. * Animations to be used for the post processing
  15398. */
  15399. animations: Animation[];
  15400. /**
  15401. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15402. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15403. */
  15404. enablePixelPerfectMode: boolean;
  15405. /**
  15406. * Force the postprocess to be applied without taking in account viewport
  15407. */
  15408. forceFullscreenViewport: boolean;
  15409. /**
  15410. * List of inspectable custom properties (used by the Inspector)
  15411. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15412. */
  15413. inspectableCustomProperties: IInspectable[];
  15414. /**
  15415. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15416. *
  15417. * | Value | Type | Description |
  15418. * | ----- | ----------------------------------- | ----------- |
  15419. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15420. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15421. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15422. *
  15423. */
  15424. scaleMode: number;
  15425. /**
  15426. * Force textures to be a power of two (default: false)
  15427. */
  15428. alwaysForcePOT: boolean;
  15429. private _samples;
  15430. /**
  15431. * Number of sample textures (default: 1)
  15432. */
  15433. samples: number;
  15434. /**
  15435. * Modify the scale of the post process to be the same as the viewport (default: false)
  15436. */
  15437. adaptScaleToCurrentViewport: boolean;
  15438. private _camera;
  15439. private _scene;
  15440. private _engine;
  15441. private _options;
  15442. private _reusable;
  15443. private _textureType;
  15444. /**
  15445. * Smart array of input and output textures for the post process.
  15446. * @hidden
  15447. */
  15448. _textures: SmartArray<InternalTexture>;
  15449. /**
  15450. * The index in _textures that corresponds to the output texture.
  15451. * @hidden
  15452. */
  15453. _currentRenderTextureInd: number;
  15454. private _effect;
  15455. private _samplers;
  15456. private _fragmentUrl;
  15457. private _vertexUrl;
  15458. private _parameters;
  15459. private _scaleRatio;
  15460. protected _indexParameters: any;
  15461. private _shareOutputWithPostProcess;
  15462. private _texelSize;
  15463. private _forcedOutputTexture;
  15464. /**
  15465. * Returns the fragment url or shader name used in the post process.
  15466. * @returns the fragment url or name in the shader store.
  15467. */
  15468. getEffectName(): string;
  15469. /**
  15470. * An event triggered when the postprocess is activated.
  15471. */
  15472. onActivateObservable: Observable<Camera>;
  15473. private _onActivateObserver;
  15474. /**
  15475. * A function that is added to the onActivateObservable
  15476. */
  15477. onActivate: Nullable<(camera: Camera) => void>;
  15478. /**
  15479. * An event triggered when the postprocess changes its size.
  15480. */
  15481. onSizeChangedObservable: Observable<PostProcess>;
  15482. private _onSizeChangedObserver;
  15483. /**
  15484. * A function that is added to the onSizeChangedObservable
  15485. */
  15486. onSizeChanged: (postProcess: PostProcess) => void;
  15487. /**
  15488. * An event triggered when the postprocess applies its effect.
  15489. */
  15490. onApplyObservable: Observable<Effect>;
  15491. private _onApplyObserver;
  15492. /**
  15493. * A function that is added to the onApplyObservable
  15494. */
  15495. onApply: (effect: Effect) => void;
  15496. /**
  15497. * An event triggered before rendering the postprocess
  15498. */
  15499. onBeforeRenderObservable: Observable<Effect>;
  15500. private _onBeforeRenderObserver;
  15501. /**
  15502. * A function that is added to the onBeforeRenderObservable
  15503. */
  15504. onBeforeRender: (effect: Effect) => void;
  15505. /**
  15506. * An event triggered after rendering the postprocess
  15507. */
  15508. onAfterRenderObservable: Observable<Effect>;
  15509. private _onAfterRenderObserver;
  15510. /**
  15511. * A function that is added to the onAfterRenderObservable
  15512. */
  15513. onAfterRender: (efect: Effect) => void;
  15514. /**
  15515. * 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
  15516. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15517. */
  15518. inputTexture: InternalTexture;
  15519. /**
  15520. * Gets the camera which post process is applied to.
  15521. * @returns The camera the post process is applied to.
  15522. */
  15523. getCamera(): Camera;
  15524. /**
  15525. * Gets the texel size of the postprocess.
  15526. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15527. */
  15528. readonly texelSize: Vector2;
  15529. /**
  15530. * Creates a new instance PostProcess
  15531. * @param name The name of the PostProcess.
  15532. * @param fragmentUrl The url of the fragment shader to be used.
  15533. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15534. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15535. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15536. * @param camera The camera to apply the render pass to.
  15537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15538. * @param engine The engine which the post process will be applied. (default: current engine)
  15539. * @param reusable If the post process can be reused on the same frame. (default: false)
  15540. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15541. * @param textureType Type of textures used when performing the post process. (default: 0)
  15542. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15543. * @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
  15544. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15545. */
  15546. constructor(
  15547. /** Name of the PostProcess. */
  15548. 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);
  15549. /**
  15550. * Gets a string idenfifying the name of the class
  15551. * @returns "PostProcess" string
  15552. */
  15553. getClassName(): string;
  15554. /**
  15555. * Gets the engine which this post process belongs to.
  15556. * @returns The engine the post process was enabled with.
  15557. */
  15558. getEngine(): Engine;
  15559. /**
  15560. * The effect that is created when initializing the post process.
  15561. * @returns The created effect corresponding the the postprocess.
  15562. */
  15563. getEffect(): Effect;
  15564. /**
  15565. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15566. * @param postProcess The post process to share the output with.
  15567. * @returns This post process.
  15568. */
  15569. shareOutputWith(postProcess: PostProcess): PostProcess;
  15570. /**
  15571. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15572. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15573. */
  15574. useOwnOutput(): void;
  15575. /**
  15576. * Updates the effect with the current post process compile time values and recompiles the shader.
  15577. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15578. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15579. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15580. * @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
  15581. * @param onCompiled Called when the shader has been compiled.
  15582. * @param onError Called if there is an error when compiling a shader.
  15583. */
  15584. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15585. /**
  15586. * The post process is reusable if it can be used multiple times within one frame.
  15587. * @returns If the post process is reusable
  15588. */
  15589. isReusable(): boolean;
  15590. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15591. markTextureDirty(): void;
  15592. /**
  15593. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15594. * 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.
  15595. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15596. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15597. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15598. * @returns The target texture that was bound to be written to.
  15599. */
  15600. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15601. /**
  15602. * If the post process is supported.
  15603. */
  15604. readonly isSupported: boolean;
  15605. /**
  15606. * The aspect ratio of the output texture.
  15607. */
  15608. readonly aspectRatio: number;
  15609. /**
  15610. * Get a value indicating if the post-process is ready to be used
  15611. * @returns true if the post-process is ready (shader is compiled)
  15612. */
  15613. isReady(): boolean;
  15614. /**
  15615. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15616. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15617. */
  15618. apply(): Nullable<Effect>;
  15619. private _disposeTextures;
  15620. /**
  15621. * Disposes the post process.
  15622. * @param camera The camera to dispose the post process on.
  15623. */
  15624. dispose(camera?: Camera): void;
  15625. }
  15626. }
  15627. declare module BABYLON {
  15628. /** @hidden */
  15629. export var kernelBlurVaryingDeclaration: {
  15630. name: string;
  15631. shader: string;
  15632. };
  15633. }
  15634. declare module BABYLON {
  15635. /** @hidden */
  15636. export var kernelBlurFragment: {
  15637. name: string;
  15638. shader: string;
  15639. };
  15640. }
  15641. declare module BABYLON {
  15642. /** @hidden */
  15643. export var kernelBlurFragment2: {
  15644. name: string;
  15645. shader: string;
  15646. };
  15647. }
  15648. declare module BABYLON {
  15649. /** @hidden */
  15650. export var kernelBlurPixelShader: {
  15651. name: string;
  15652. shader: string;
  15653. };
  15654. }
  15655. declare module BABYLON {
  15656. /** @hidden */
  15657. export var kernelBlurVertex: {
  15658. name: string;
  15659. shader: string;
  15660. };
  15661. }
  15662. declare module BABYLON {
  15663. /** @hidden */
  15664. export var kernelBlurVertexShader: {
  15665. name: string;
  15666. shader: string;
  15667. };
  15668. }
  15669. declare module BABYLON {
  15670. /**
  15671. * The Blur Post Process which blurs an image based on a kernel and direction.
  15672. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15673. */
  15674. export class BlurPostProcess extends PostProcess {
  15675. /** The direction in which to blur the image. */
  15676. direction: Vector2;
  15677. private blockCompilation;
  15678. protected _kernel: number;
  15679. protected _idealKernel: number;
  15680. protected _packedFloat: boolean;
  15681. private _staticDefines;
  15682. /**
  15683. * Sets the length in pixels of the blur sample region
  15684. */
  15685. /**
  15686. * Gets the length in pixels of the blur sample region
  15687. */
  15688. kernel: number;
  15689. /**
  15690. * Sets wether or not the blur needs to unpack/repack floats
  15691. */
  15692. /**
  15693. * Gets wether or not the blur is unpacking/repacking floats
  15694. */
  15695. packedFloat: boolean;
  15696. /**
  15697. * Creates a new instance BlurPostProcess
  15698. * @param name The name of the effect.
  15699. * @param direction The direction in which to blur the image.
  15700. * @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.
  15701. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15702. * @param camera The camera to apply the render pass to.
  15703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15704. * @param engine The engine which the post process will be applied. (default: current engine)
  15705. * @param reusable If the post process can be reused on the same frame. (default: false)
  15706. * @param textureType Type of textures used when performing the post process. (default: 0)
  15707. * @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)
  15708. */
  15709. constructor(name: string,
  15710. /** The direction in which to blur the image. */
  15711. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15712. /**
  15713. * Updates the effect with the current post process compile time values and recompiles the shader.
  15714. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15715. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15716. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15717. * @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
  15718. * @param onCompiled Called when the shader has been compiled.
  15719. * @param onError Called if there is an error when compiling a shader.
  15720. */
  15721. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15722. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15723. /**
  15724. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15725. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15726. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15727. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15728. * The gaps between physical kernels are compensated for in the weighting of the samples
  15729. * @param idealKernel Ideal blur kernel.
  15730. * @return Nearest best kernel.
  15731. */
  15732. protected _nearestBestKernel(idealKernel: number): number;
  15733. /**
  15734. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15735. * @param x The point on the Gaussian distribution to sample.
  15736. * @return the value of the Gaussian function at x.
  15737. */
  15738. protected _gaussianWeight(x: number): number;
  15739. /**
  15740. * Generates a string that can be used as a floating point number in GLSL.
  15741. * @param x Value to print.
  15742. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15743. * @return GLSL float string.
  15744. */
  15745. protected _glslFloat(x: number, decimalFigures?: number): string;
  15746. }
  15747. }
  15748. declare module BABYLON {
  15749. /**
  15750. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15751. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15752. * You can then easily use it as a reflectionTexture on a flat surface.
  15753. * In case the surface is not a plane, please consider relying on reflection probes.
  15754. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15755. */
  15756. export class MirrorTexture extends RenderTargetTexture {
  15757. private scene;
  15758. /**
  15759. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15760. * 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.
  15761. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15762. */
  15763. mirrorPlane: Plane;
  15764. /**
  15765. * Define the blur ratio used to blur the reflection if needed.
  15766. */
  15767. blurRatio: number;
  15768. /**
  15769. * Define the adaptive blur kernel used to blur the reflection if needed.
  15770. * This will autocompute the closest best match for the `blurKernel`
  15771. */
  15772. adaptiveBlurKernel: number;
  15773. /**
  15774. * Define the blur kernel used to blur the reflection if needed.
  15775. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15776. */
  15777. blurKernel: number;
  15778. /**
  15779. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15780. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15781. */
  15782. blurKernelX: number;
  15783. /**
  15784. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15785. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15786. */
  15787. blurKernelY: number;
  15788. private _autoComputeBlurKernel;
  15789. protected _onRatioRescale(): void;
  15790. private _updateGammaSpace;
  15791. private _imageProcessingConfigChangeObserver;
  15792. private _transformMatrix;
  15793. private _mirrorMatrix;
  15794. private _savedViewMatrix;
  15795. private _blurX;
  15796. private _blurY;
  15797. private _adaptiveBlurKernel;
  15798. private _blurKernelX;
  15799. private _blurKernelY;
  15800. private _blurRatio;
  15801. /**
  15802. * Instantiates a Mirror Texture.
  15803. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15804. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15805. * You can then easily use it as a reflectionTexture on a flat surface.
  15806. * In case the surface is not a plane, please consider relying on reflection probes.
  15807. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15808. * @param name
  15809. * @param size
  15810. * @param scene
  15811. * @param generateMipMaps
  15812. * @param type
  15813. * @param samplingMode
  15814. * @param generateDepthBuffer
  15815. */
  15816. constructor(name: string, size: number | {
  15817. width: number;
  15818. height: number;
  15819. } | {
  15820. ratio: number;
  15821. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15822. private _preparePostProcesses;
  15823. /**
  15824. * Clone the mirror texture.
  15825. * @returns the cloned texture
  15826. */
  15827. clone(): MirrorTexture;
  15828. /**
  15829. * Serialize the texture to a JSON representation you could use in Parse later on
  15830. * @returns the serialized JSON representation
  15831. */
  15832. serialize(): any;
  15833. /**
  15834. * Dispose the texture and release its associated resources.
  15835. */
  15836. dispose(): void;
  15837. }
  15838. }
  15839. declare module BABYLON {
  15840. /**
  15841. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15842. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15843. */
  15844. export class Texture extends BaseTexture {
  15845. /**
  15846. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15847. */
  15848. static SerializeBuffers: boolean;
  15849. /** @hidden */
  15850. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15851. /** @hidden */
  15852. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15853. /** @hidden */
  15854. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15855. /** nearest is mag = nearest and min = nearest and mip = linear */
  15856. static readonly NEAREST_SAMPLINGMODE: number;
  15857. /** nearest is mag = nearest and min = nearest and mip = linear */
  15858. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15859. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15860. static readonly BILINEAR_SAMPLINGMODE: number;
  15861. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15862. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15863. /** Trilinear is mag = linear and min = linear and mip = linear */
  15864. static readonly TRILINEAR_SAMPLINGMODE: number;
  15865. /** Trilinear is mag = linear and min = linear and mip = linear */
  15866. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15867. /** mag = nearest and min = nearest and mip = nearest */
  15868. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15869. /** mag = nearest and min = linear and mip = nearest */
  15870. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15871. /** mag = nearest and min = linear and mip = linear */
  15872. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15873. /** mag = nearest and min = linear and mip = none */
  15874. static readonly NEAREST_LINEAR: number;
  15875. /** mag = nearest and min = nearest and mip = none */
  15876. static readonly NEAREST_NEAREST: number;
  15877. /** mag = linear and min = nearest and mip = nearest */
  15878. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15879. /** mag = linear and min = nearest and mip = linear */
  15880. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15881. /** mag = linear and min = linear and mip = none */
  15882. static readonly LINEAR_LINEAR: number;
  15883. /** mag = linear and min = nearest and mip = none */
  15884. static readonly LINEAR_NEAREST: number;
  15885. /** Explicit coordinates mode */
  15886. static readonly EXPLICIT_MODE: number;
  15887. /** Spherical coordinates mode */
  15888. static readonly SPHERICAL_MODE: number;
  15889. /** Planar coordinates mode */
  15890. static readonly PLANAR_MODE: number;
  15891. /** Cubic coordinates mode */
  15892. static readonly CUBIC_MODE: number;
  15893. /** Projection coordinates mode */
  15894. static readonly PROJECTION_MODE: number;
  15895. /** Inverse Cubic coordinates mode */
  15896. static readonly SKYBOX_MODE: number;
  15897. /** Inverse Cubic coordinates mode */
  15898. static readonly INVCUBIC_MODE: number;
  15899. /** Equirectangular coordinates mode */
  15900. static readonly EQUIRECTANGULAR_MODE: number;
  15901. /** Equirectangular Fixed coordinates mode */
  15902. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15903. /** Equirectangular Fixed Mirrored coordinates mode */
  15904. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15905. /** Texture is not repeating outside of 0..1 UVs */
  15906. static readonly CLAMP_ADDRESSMODE: number;
  15907. /** Texture is repeating outside of 0..1 UVs */
  15908. static readonly WRAP_ADDRESSMODE: number;
  15909. /** Texture is repeating and mirrored */
  15910. static readonly MIRROR_ADDRESSMODE: number;
  15911. /**
  15912. * 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
  15913. */
  15914. static UseSerializedUrlIfAny: boolean;
  15915. /**
  15916. * Define the url of the texture.
  15917. */
  15918. url: Nullable<string>;
  15919. /**
  15920. * Define an offset on the texture to offset the u coordinates of the UVs
  15921. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15922. */
  15923. uOffset: number;
  15924. /**
  15925. * Define an offset on the texture to offset the v coordinates of the UVs
  15926. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15927. */
  15928. vOffset: number;
  15929. /**
  15930. * Define an offset on the texture to scale the u coordinates of the UVs
  15931. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15932. */
  15933. uScale: number;
  15934. /**
  15935. * Define an offset on the texture to scale the v coordinates of the UVs
  15936. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15937. */
  15938. vScale: number;
  15939. /**
  15940. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15941. * @see http://doc.babylonjs.com/how_to/more_materials
  15942. */
  15943. uAng: number;
  15944. /**
  15945. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15946. * @see http://doc.babylonjs.com/how_to/more_materials
  15947. */
  15948. vAng: number;
  15949. /**
  15950. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15951. * @see http://doc.babylonjs.com/how_to/more_materials
  15952. */
  15953. wAng: number;
  15954. /**
  15955. * Defines the center of rotation (U)
  15956. */
  15957. uRotationCenter: number;
  15958. /**
  15959. * Defines the center of rotation (V)
  15960. */
  15961. vRotationCenter: number;
  15962. /**
  15963. * Defines the center of rotation (W)
  15964. */
  15965. wRotationCenter: number;
  15966. /**
  15967. * Are mip maps generated for this texture or not.
  15968. */
  15969. readonly noMipmap: boolean;
  15970. /**
  15971. * List of inspectable custom properties (used by the Inspector)
  15972. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15973. */
  15974. inspectableCustomProperties: Nullable<IInspectable[]>;
  15975. private _noMipmap;
  15976. /** @hidden */
  15977. _invertY: boolean;
  15978. private _rowGenerationMatrix;
  15979. private _cachedTextureMatrix;
  15980. private _projectionModeMatrix;
  15981. private _t0;
  15982. private _t1;
  15983. private _t2;
  15984. private _cachedUOffset;
  15985. private _cachedVOffset;
  15986. private _cachedUScale;
  15987. private _cachedVScale;
  15988. private _cachedUAng;
  15989. private _cachedVAng;
  15990. private _cachedWAng;
  15991. private _cachedProjectionMatrixId;
  15992. private _cachedCoordinatesMode;
  15993. /** @hidden */
  15994. protected _initialSamplingMode: number;
  15995. /** @hidden */
  15996. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15997. private _deleteBuffer;
  15998. protected _format: Nullable<number>;
  15999. private _delayedOnLoad;
  16000. private _delayedOnError;
  16001. private _mimeType?;
  16002. /**
  16003. * Observable triggered once the texture has been loaded.
  16004. */
  16005. onLoadObservable: Observable<Texture>;
  16006. protected _isBlocking: boolean;
  16007. /**
  16008. * Is the texture preventing material to render while loading.
  16009. * If false, a default texture will be used instead of the loading one during the preparation step.
  16010. */
  16011. isBlocking: boolean;
  16012. /**
  16013. * Get the current sampling mode associated with the texture.
  16014. */
  16015. readonly samplingMode: number;
  16016. /**
  16017. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16018. */
  16019. readonly invertY: boolean;
  16020. /**
  16021. * Instantiates a new texture.
  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. * @param url defines the url of the picture to load as a texture
  16025. * @param scene defines the scene or engine the texture will belong to
  16026. * @param noMipmap defines if the texture will require mip maps or not
  16027. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16028. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16029. * @param onLoad defines a callback triggered when the texture has been loaded
  16030. * @param onError defines a callback triggered when an error occurred during the loading session
  16031. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16032. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16033. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16034. * @param mimeType defines an optional mime type information
  16035. */
  16036. 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);
  16037. /**
  16038. * Update the url (and optional buffer) of this texture if url was null during construction.
  16039. * @param url the url of the texture
  16040. * @param buffer the buffer of the texture (defaults to null)
  16041. * @param onLoad callback called when the texture is loaded (defaults to null)
  16042. */
  16043. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16044. /**
  16045. * Finish the loading sequence of a texture flagged as delayed load.
  16046. * @hidden
  16047. */
  16048. delayLoad(): void;
  16049. private _prepareRowForTextureGeneration;
  16050. /**
  16051. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16052. * @returns the transform matrix of the texture.
  16053. */
  16054. getTextureMatrix(uBase?: number): Matrix;
  16055. /**
  16056. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16057. * @returns The reflection texture transform
  16058. */
  16059. getReflectionTextureMatrix(): Matrix;
  16060. /**
  16061. * Clones the texture.
  16062. * @returns the cloned texture
  16063. */
  16064. clone(): Texture;
  16065. /**
  16066. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16067. * @returns The JSON representation of the texture
  16068. */
  16069. serialize(): any;
  16070. /**
  16071. * Get the current class name of the texture useful for serialization or dynamic coding.
  16072. * @returns "Texture"
  16073. */
  16074. getClassName(): string;
  16075. /**
  16076. * Dispose the texture and release its associated resources.
  16077. */
  16078. dispose(): void;
  16079. /**
  16080. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16081. * @param parsedTexture Define the JSON representation of the texture
  16082. * @param scene Define the scene the parsed texture should be instantiated in
  16083. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16084. * @returns The parsed texture if successful
  16085. */
  16086. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16087. /**
  16088. * Creates a texture from its base 64 representation.
  16089. * @param data Define the base64 payload without the data: prefix
  16090. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16091. * @param scene Define the scene the texture should belong to
  16092. * @param noMipmap Forces the texture to not create mip map information if true
  16093. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16094. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16095. * @param onLoad define a callback triggered when the texture has been loaded
  16096. * @param onError define a callback triggered when an error occurred during the loading session
  16097. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16098. * @returns the created texture
  16099. */
  16100. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16101. /**
  16102. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16103. * @param data Define the base64 payload without the data: prefix
  16104. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16105. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16106. * @param scene Define the scene the texture should belong to
  16107. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16108. * @param noMipmap Forces the texture to not create mip map information if true
  16109. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16110. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16111. * @param onLoad define a callback triggered when the texture has been loaded
  16112. * @param onError define a callback triggered when an error occurred during the loading session
  16113. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16114. * @returns the created texture
  16115. */
  16116. 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;
  16117. }
  16118. }
  16119. declare module BABYLON {
  16120. /**
  16121. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16122. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16123. */
  16124. export class PostProcessManager {
  16125. private _scene;
  16126. private _indexBuffer;
  16127. private _vertexBuffers;
  16128. /**
  16129. * Creates a new instance PostProcess
  16130. * @param scene The scene that the post process is associated with.
  16131. */
  16132. constructor(scene: Scene);
  16133. private _prepareBuffers;
  16134. private _buildIndexBuffer;
  16135. /**
  16136. * Rebuilds the vertex buffers of the manager.
  16137. * @hidden
  16138. */
  16139. _rebuild(): void;
  16140. /**
  16141. * Prepares a frame to be run through a post process.
  16142. * @param sourceTexture The input texture to the post procesess. (default: null)
  16143. * @param postProcesses An array of post processes to be run. (default: null)
  16144. * @returns True if the post processes were able to be run.
  16145. * @hidden
  16146. */
  16147. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16148. /**
  16149. * Manually render a set of post processes to a texture.
  16150. * @param postProcesses An array of post processes to be run.
  16151. * @param targetTexture The target texture to render to.
  16152. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16153. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16154. * @param lodLevel defines which lod of the texture to render to
  16155. */
  16156. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16157. /**
  16158. * Finalize the result of the output of the postprocesses.
  16159. * @param doNotPresent If true the result will not be displayed to the screen.
  16160. * @param targetTexture The target texture to render to.
  16161. * @param faceIndex The index of the face to bind the target texture to.
  16162. * @param postProcesses The array of post processes to render.
  16163. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16164. * @hidden
  16165. */
  16166. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16167. /**
  16168. * Disposes of the post process manager.
  16169. */
  16170. dispose(): void;
  16171. }
  16172. }
  16173. declare module BABYLON {
  16174. /** Interface used by value gradients (color, factor, ...) */
  16175. export interface IValueGradient {
  16176. /**
  16177. * Gets or sets the gradient value (between 0 and 1)
  16178. */
  16179. gradient: number;
  16180. }
  16181. /** Class used to store color4 gradient */
  16182. export class ColorGradient implements IValueGradient {
  16183. /**
  16184. * Gets or sets the gradient value (between 0 and 1)
  16185. */
  16186. gradient: number;
  16187. /**
  16188. * Gets or sets first associated color
  16189. */
  16190. color1: Color4;
  16191. /**
  16192. * Gets or sets second associated color
  16193. */
  16194. color2?: Color4;
  16195. /**
  16196. * Will get a color picked randomly between color1 and color2.
  16197. * If color2 is undefined then color1 will be used
  16198. * @param result defines the target Color4 to store the result in
  16199. */
  16200. getColorToRef(result: Color4): void;
  16201. }
  16202. /** Class used to store color 3 gradient */
  16203. export class Color3Gradient implements IValueGradient {
  16204. /**
  16205. * Gets or sets the gradient value (between 0 and 1)
  16206. */
  16207. gradient: number;
  16208. /**
  16209. * Gets or sets the associated color
  16210. */
  16211. color: Color3;
  16212. }
  16213. /** Class used to store factor gradient */
  16214. export class FactorGradient implements IValueGradient {
  16215. /**
  16216. * Gets or sets the gradient value (between 0 and 1)
  16217. */
  16218. gradient: number;
  16219. /**
  16220. * Gets or sets first associated factor
  16221. */
  16222. factor1: number;
  16223. /**
  16224. * Gets or sets second associated factor
  16225. */
  16226. factor2?: number;
  16227. /**
  16228. * Will get a number picked randomly between factor1 and factor2.
  16229. * If factor2 is undefined then factor1 will be used
  16230. * @returns the picked number
  16231. */
  16232. getFactor(): number;
  16233. }
  16234. /**
  16235. * Helper used to simplify some generic gradient tasks
  16236. */
  16237. export class GradientHelper {
  16238. /**
  16239. * Gets the current gradient from an array of IValueGradient
  16240. * @param ratio defines the current ratio to get
  16241. * @param gradients defines the array of IValueGradient
  16242. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16243. */
  16244. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16245. }
  16246. }
  16247. declare module BABYLON {
  16248. interface ThinEngine {
  16249. /**
  16250. * Creates a dynamic texture
  16251. * @param width defines the width of the texture
  16252. * @param height defines the height of the texture
  16253. * @param generateMipMaps defines if the engine should generate the mip levels
  16254. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16255. * @returns the dynamic texture inside an InternalTexture
  16256. */
  16257. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16258. /**
  16259. * Update the content of a dynamic texture
  16260. * @param texture defines the texture to update
  16261. * @param canvas defines the canvas containing the source
  16262. * @param invertY defines if data must be stored with Y axis inverted
  16263. * @param premulAlpha defines if alpha is stored as premultiplied
  16264. * @param format defines the format of the data
  16265. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16266. */
  16267. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16268. }
  16269. }
  16270. declare module BABYLON {
  16271. /**
  16272. * Helper class used to generate a canvas to manipulate images
  16273. */
  16274. export class CanvasGenerator {
  16275. /**
  16276. * Create a new canvas (or offscreen canvas depending on the context)
  16277. * @param width defines the expected width
  16278. * @param height defines the expected height
  16279. * @return a new canvas or offscreen canvas
  16280. */
  16281. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16282. }
  16283. }
  16284. declare module BABYLON {
  16285. /**
  16286. * A class extending Texture allowing drawing on a texture
  16287. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16288. */
  16289. export class DynamicTexture extends Texture {
  16290. private _generateMipMaps;
  16291. private _canvas;
  16292. private _context;
  16293. private _engine;
  16294. /**
  16295. * Creates a DynamicTexture
  16296. * @param name defines the name of the texture
  16297. * @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
  16298. * @param scene defines the scene where you want the texture
  16299. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16300. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16301. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16302. */
  16303. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16304. /**
  16305. * Get the current class name of the texture useful for serialization or dynamic coding.
  16306. * @returns "DynamicTexture"
  16307. */
  16308. getClassName(): string;
  16309. /**
  16310. * Gets the current state of canRescale
  16311. */
  16312. readonly canRescale: boolean;
  16313. private _recreate;
  16314. /**
  16315. * Scales the texture
  16316. * @param ratio the scale factor to apply to both width and height
  16317. */
  16318. scale(ratio: number): void;
  16319. /**
  16320. * Resizes the texture
  16321. * @param width the new width
  16322. * @param height the new height
  16323. */
  16324. scaleTo(width: number, height: number): void;
  16325. /**
  16326. * Gets the context of the canvas used by the texture
  16327. * @returns the canvas context of the dynamic texture
  16328. */
  16329. getContext(): CanvasRenderingContext2D;
  16330. /**
  16331. * Clears the texture
  16332. */
  16333. clear(): void;
  16334. /**
  16335. * Updates the texture
  16336. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16337. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16338. */
  16339. update(invertY?: boolean, premulAlpha?: boolean): void;
  16340. /**
  16341. * Draws text onto the texture
  16342. * @param text defines the text to be drawn
  16343. * @param x defines the placement of the text from the left
  16344. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16345. * @param font defines the font to be used with font-style, font-size, font-name
  16346. * @param color defines the color used for the text
  16347. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16348. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16349. * @param update defines whether texture is immediately update (default is true)
  16350. */
  16351. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16352. /**
  16353. * Clones the texture
  16354. * @returns the clone of the texture.
  16355. */
  16356. clone(): DynamicTexture;
  16357. /**
  16358. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16359. * @returns a serialized dynamic texture object
  16360. */
  16361. serialize(): any;
  16362. /** @hidden */
  16363. _rebuild(): void;
  16364. }
  16365. }
  16366. declare module BABYLON {
  16367. interface AbstractScene {
  16368. /**
  16369. * The list of procedural textures added to the scene
  16370. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16371. */
  16372. proceduralTextures: Array<ProceduralTexture>;
  16373. }
  16374. /**
  16375. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16376. * in a given scene.
  16377. */
  16378. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16379. /**
  16380. * The component name helpfull to identify the component in the list of scene components.
  16381. */
  16382. readonly name: string;
  16383. /**
  16384. * The scene the component belongs to.
  16385. */
  16386. scene: Scene;
  16387. /**
  16388. * Creates a new instance of the component for the given scene
  16389. * @param scene Defines the scene to register the component in
  16390. */
  16391. constructor(scene: Scene);
  16392. /**
  16393. * Registers the component in a given scene
  16394. */
  16395. register(): void;
  16396. /**
  16397. * Rebuilds the elements related to this component in case of
  16398. * context lost for instance.
  16399. */
  16400. rebuild(): void;
  16401. /**
  16402. * Disposes the component and the associated ressources.
  16403. */
  16404. dispose(): void;
  16405. private _beforeClear;
  16406. }
  16407. }
  16408. declare module BABYLON {
  16409. interface ThinEngine {
  16410. /**
  16411. * Creates a new render target cube texture
  16412. * @param size defines the size of the texture
  16413. * @param options defines the options used to create the texture
  16414. * @returns a new render target cube texture stored in an InternalTexture
  16415. */
  16416. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16417. }
  16418. }
  16419. declare module BABYLON {
  16420. /** @hidden */
  16421. export var proceduralVertexShader: {
  16422. name: string;
  16423. shader: string;
  16424. };
  16425. }
  16426. declare module BABYLON {
  16427. /**
  16428. * 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.
  16429. * This is the base class of any Procedural texture and contains most of the shareable code.
  16430. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16431. */
  16432. export class ProceduralTexture extends Texture {
  16433. isCube: boolean;
  16434. /**
  16435. * Define if the texture is enabled or not (disabled texture will not render)
  16436. */
  16437. isEnabled: boolean;
  16438. /**
  16439. * Define if the texture must be cleared before rendering (default is true)
  16440. */
  16441. autoClear: boolean;
  16442. /**
  16443. * Callback called when the texture is generated
  16444. */
  16445. onGenerated: () => void;
  16446. /**
  16447. * Event raised when the texture is generated
  16448. */
  16449. onGeneratedObservable: Observable<ProceduralTexture>;
  16450. /** @hidden */
  16451. _generateMipMaps: boolean;
  16452. /** @hidden **/
  16453. _effect: Effect;
  16454. /** @hidden */
  16455. _textures: {
  16456. [key: string]: Texture;
  16457. };
  16458. private _size;
  16459. private _currentRefreshId;
  16460. private _refreshRate;
  16461. private _vertexBuffers;
  16462. private _indexBuffer;
  16463. private _uniforms;
  16464. private _samplers;
  16465. private _fragment;
  16466. private _floats;
  16467. private _ints;
  16468. private _floatsArrays;
  16469. private _colors3;
  16470. private _colors4;
  16471. private _vectors2;
  16472. private _vectors3;
  16473. private _matrices;
  16474. private _fallbackTexture;
  16475. private _fallbackTextureUsed;
  16476. private _engine;
  16477. private _cachedDefines;
  16478. private _contentUpdateId;
  16479. private _contentData;
  16480. /**
  16481. * Instantiates a new procedural texture.
  16482. * 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.
  16483. * This is the base class of any Procedural texture and contains most of the shareable code.
  16484. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16485. * @param name Define the name of the texture
  16486. * @param size Define the size of the texture to create
  16487. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16488. * @param scene Define the scene the texture belongs to
  16489. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16490. * @param generateMipMaps Define if the texture should creates mip maps or not
  16491. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16492. */
  16493. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16494. /**
  16495. * The effect that is created when initializing the post process.
  16496. * @returns The created effect corresponding the the postprocess.
  16497. */
  16498. getEffect(): Effect;
  16499. /**
  16500. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16501. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16502. */
  16503. getContent(): Nullable<ArrayBufferView>;
  16504. private _createIndexBuffer;
  16505. /** @hidden */
  16506. _rebuild(): void;
  16507. /**
  16508. * Resets the texture in order to recreate its associated resources.
  16509. * This can be called in case of context loss
  16510. */
  16511. reset(): void;
  16512. protected _getDefines(): string;
  16513. /**
  16514. * Is the texture ready to be used ? (rendered at least once)
  16515. * @returns true if ready, otherwise, false.
  16516. */
  16517. isReady(): boolean;
  16518. /**
  16519. * Resets the refresh counter of the texture and start bak from scratch.
  16520. * Could be useful to regenerate the texture if it is setup to render only once.
  16521. */
  16522. resetRefreshCounter(): void;
  16523. /**
  16524. * Set the fragment shader to use in order to render the texture.
  16525. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16526. */
  16527. setFragment(fragment: any): void;
  16528. /**
  16529. * Define the refresh rate of the texture or the rendering frequency.
  16530. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16531. */
  16532. refreshRate: number;
  16533. /** @hidden */
  16534. _shouldRender(): boolean;
  16535. /**
  16536. * Get the size the texture is rendering at.
  16537. * @returns the size (texture is always squared)
  16538. */
  16539. getRenderSize(): number;
  16540. /**
  16541. * Resize the texture to new value.
  16542. * @param size Define the new size the texture should have
  16543. * @param generateMipMaps Define whether the new texture should create mip maps
  16544. */
  16545. resize(size: number, generateMipMaps: boolean): void;
  16546. private _checkUniform;
  16547. /**
  16548. * Set a texture in the shader program used to render.
  16549. * @param name Define the name of the uniform samplers as defined in the shader
  16550. * @param texture Define the texture to bind to this sampler
  16551. * @return the texture itself allowing "fluent" like uniform updates
  16552. */
  16553. setTexture(name: string, texture: Texture): ProceduralTexture;
  16554. /**
  16555. * Set a float in the shader.
  16556. * @param name Define the name of the uniform as defined in the shader
  16557. * @param value Define the value to give to the uniform
  16558. * @return the texture itself allowing "fluent" like uniform updates
  16559. */
  16560. setFloat(name: string, value: number): ProceduralTexture;
  16561. /**
  16562. * Set a int in the shader.
  16563. * @param name Define the name of the uniform as defined in the shader
  16564. * @param value Define the value to give to the uniform
  16565. * @return the texture itself allowing "fluent" like uniform updates
  16566. */
  16567. setInt(name: string, value: number): ProceduralTexture;
  16568. /**
  16569. * Set an array of floats in the shader.
  16570. * @param name Define the name of the uniform as defined in the shader
  16571. * @param value Define the value to give to the uniform
  16572. * @return the texture itself allowing "fluent" like uniform updates
  16573. */
  16574. setFloats(name: string, value: number[]): ProceduralTexture;
  16575. /**
  16576. * Set a vec3 in the shader from a Color3.
  16577. * @param name Define the name of the uniform as defined in the shader
  16578. * @param value Define the value to give to the uniform
  16579. * @return the texture itself allowing "fluent" like uniform updates
  16580. */
  16581. setColor3(name: string, value: Color3): ProceduralTexture;
  16582. /**
  16583. * Set a vec4 in the shader from a Color4.
  16584. * @param name Define the name of the uniform as defined in the shader
  16585. * @param value Define the value to give to the uniform
  16586. * @return the texture itself allowing "fluent" like uniform updates
  16587. */
  16588. setColor4(name: string, value: Color4): ProceduralTexture;
  16589. /**
  16590. * Set a vec2 in the shader from a Vector2.
  16591. * @param name Define the name of the uniform as defined in the shader
  16592. * @param value Define the value to give to the uniform
  16593. * @return the texture itself allowing "fluent" like uniform updates
  16594. */
  16595. setVector2(name: string, value: Vector2): ProceduralTexture;
  16596. /**
  16597. * Set a vec3 in the shader from a Vector3.
  16598. * @param name Define the name of the uniform as defined in the shader
  16599. * @param value Define the value to give to the uniform
  16600. * @return the texture itself allowing "fluent" like uniform updates
  16601. */
  16602. setVector3(name: string, value: Vector3): ProceduralTexture;
  16603. /**
  16604. * Set a mat4 in the shader from a MAtrix.
  16605. * @param name Define the name of the uniform as defined in the shader
  16606. * @param value Define the value to give to the uniform
  16607. * @return the texture itself allowing "fluent" like uniform updates
  16608. */
  16609. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16610. /**
  16611. * Render the texture to its associated render target.
  16612. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16613. */
  16614. render(useCameraPostProcess?: boolean): void;
  16615. /**
  16616. * Clone the texture.
  16617. * @returns the cloned texture
  16618. */
  16619. clone(): ProceduralTexture;
  16620. /**
  16621. * Dispose the texture and release its asoociated resources.
  16622. */
  16623. dispose(): void;
  16624. }
  16625. }
  16626. declare module BABYLON {
  16627. /**
  16628. * This represents the base class for particle system in Babylon.
  16629. * 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.
  16630. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16631. * @example https://doc.babylonjs.com/babylon101/particles
  16632. */
  16633. export class BaseParticleSystem {
  16634. /**
  16635. * Source color is added to the destination color without alpha affecting the result
  16636. */
  16637. static BLENDMODE_ONEONE: number;
  16638. /**
  16639. * Blend current color and particle color using particle’s alpha
  16640. */
  16641. static BLENDMODE_STANDARD: number;
  16642. /**
  16643. * Add current color and particle color multiplied by particle’s alpha
  16644. */
  16645. static BLENDMODE_ADD: number;
  16646. /**
  16647. * Multiply current color with particle color
  16648. */
  16649. static BLENDMODE_MULTIPLY: number;
  16650. /**
  16651. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16652. */
  16653. static BLENDMODE_MULTIPLYADD: number;
  16654. /**
  16655. * List of animations used by the particle system.
  16656. */
  16657. animations: Animation[];
  16658. /**
  16659. * The id of the Particle system.
  16660. */
  16661. id: string;
  16662. /**
  16663. * The friendly name of the Particle system.
  16664. */
  16665. name: string;
  16666. /**
  16667. * The rendering group used by the Particle system to chose when to render.
  16668. */
  16669. renderingGroupId: number;
  16670. /**
  16671. * The emitter represents the Mesh or position we are attaching the particle system to.
  16672. */
  16673. emitter: Nullable<AbstractMesh | Vector3>;
  16674. /**
  16675. * The maximum number of particles to emit per frame
  16676. */
  16677. emitRate: number;
  16678. /**
  16679. * If you want to launch only a few particles at once, that can be done, as well.
  16680. */
  16681. manualEmitCount: number;
  16682. /**
  16683. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16684. */
  16685. updateSpeed: number;
  16686. /**
  16687. * The amount of time the particle system is running (depends of the overall update speed).
  16688. */
  16689. targetStopDuration: number;
  16690. /**
  16691. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16692. */
  16693. disposeOnStop: boolean;
  16694. /**
  16695. * Minimum power of emitting particles.
  16696. */
  16697. minEmitPower: number;
  16698. /**
  16699. * Maximum power of emitting particles.
  16700. */
  16701. maxEmitPower: number;
  16702. /**
  16703. * Minimum life time of emitting particles.
  16704. */
  16705. minLifeTime: number;
  16706. /**
  16707. * Maximum life time of emitting particles.
  16708. */
  16709. maxLifeTime: number;
  16710. /**
  16711. * Minimum Size of emitting particles.
  16712. */
  16713. minSize: number;
  16714. /**
  16715. * Maximum Size of emitting particles.
  16716. */
  16717. maxSize: number;
  16718. /**
  16719. * Minimum scale of emitting particles on X axis.
  16720. */
  16721. minScaleX: number;
  16722. /**
  16723. * Maximum scale of emitting particles on X axis.
  16724. */
  16725. maxScaleX: number;
  16726. /**
  16727. * Minimum scale of emitting particles on Y axis.
  16728. */
  16729. minScaleY: number;
  16730. /**
  16731. * Maximum scale of emitting particles on Y axis.
  16732. */
  16733. maxScaleY: number;
  16734. /**
  16735. * Gets or sets the minimal initial rotation in radians.
  16736. */
  16737. minInitialRotation: number;
  16738. /**
  16739. * Gets or sets the maximal initial rotation in radians.
  16740. */
  16741. maxInitialRotation: number;
  16742. /**
  16743. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16744. */
  16745. minAngularSpeed: number;
  16746. /**
  16747. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16748. */
  16749. maxAngularSpeed: number;
  16750. /**
  16751. * The texture used to render each particle. (this can be a spritesheet)
  16752. */
  16753. particleTexture: Nullable<Texture>;
  16754. /**
  16755. * The layer mask we are rendering the particles through.
  16756. */
  16757. layerMask: number;
  16758. /**
  16759. * This can help using your own shader to render the particle system.
  16760. * The according effect will be created
  16761. */
  16762. customShader: any;
  16763. /**
  16764. * By default particle system starts as soon as they are created. This prevents the
  16765. * automatic start to happen and let you decide when to start emitting particles.
  16766. */
  16767. preventAutoStart: boolean;
  16768. private _noiseTexture;
  16769. /**
  16770. * Gets or sets a texture used to add random noise to particle positions
  16771. */
  16772. noiseTexture: Nullable<ProceduralTexture>;
  16773. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16774. noiseStrength: Vector3;
  16775. /**
  16776. * Callback triggered when the particle animation is ending.
  16777. */
  16778. onAnimationEnd: Nullable<() => void>;
  16779. /**
  16780. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16781. */
  16782. blendMode: number;
  16783. /**
  16784. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16785. * to override the particles.
  16786. */
  16787. forceDepthWrite: boolean;
  16788. /** 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 */
  16789. preWarmCycles: number;
  16790. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16791. preWarmStepOffset: number;
  16792. /**
  16793. * 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)
  16794. */
  16795. spriteCellChangeSpeed: number;
  16796. /**
  16797. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16798. */
  16799. startSpriteCellID: number;
  16800. /**
  16801. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16802. */
  16803. endSpriteCellID: number;
  16804. /**
  16805. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16806. */
  16807. spriteCellWidth: number;
  16808. /**
  16809. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16810. */
  16811. spriteCellHeight: number;
  16812. /**
  16813. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16814. */
  16815. spriteRandomStartCell: boolean;
  16816. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16817. translationPivot: Vector2;
  16818. /** @hidden */
  16819. protected _isAnimationSheetEnabled: boolean;
  16820. /**
  16821. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16822. */
  16823. beginAnimationOnStart: boolean;
  16824. /**
  16825. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16826. */
  16827. beginAnimationFrom: number;
  16828. /**
  16829. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16830. */
  16831. beginAnimationTo: number;
  16832. /**
  16833. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16834. */
  16835. beginAnimationLoop: boolean;
  16836. /**
  16837. * Gets or sets a world offset applied to all particles
  16838. */
  16839. worldOffset: Vector3;
  16840. /**
  16841. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16842. */
  16843. isAnimationSheetEnabled: boolean;
  16844. /**
  16845. * Get hosting scene
  16846. * @returns the scene
  16847. */
  16848. getScene(): Scene;
  16849. /**
  16850. * You can use gravity if you want to give an orientation to your particles.
  16851. */
  16852. gravity: Vector3;
  16853. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16854. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16855. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16856. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16857. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16858. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16859. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16860. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16861. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16862. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16863. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16864. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16865. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16866. /**
  16867. * Defines the delay in milliseconds before starting the system (0 by default)
  16868. */
  16869. startDelay: number;
  16870. /**
  16871. * Gets the current list of drag gradients.
  16872. * You must use addDragGradient and removeDragGradient to udpate this list
  16873. * @returns the list of drag gradients
  16874. */
  16875. getDragGradients(): Nullable<Array<FactorGradient>>;
  16876. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16877. limitVelocityDamping: number;
  16878. /**
  16879. * Gets the current list of limit velocity gradients.
  16880. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16881. * @returns the list of limit velocity gradients
  16882. */
  16883. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16884. /**
  16885. * Gets the current list of color gradients.
  16886. * You must use addColorGradient and removeColorGradient to udpate this list
  16887. * @returns the list of color gradients
  16888. */
  16889. getColorGradients(): Nullable<Array<ColorGradient>>;
  16890. /**
  16891. * Gets the current list of size gradients.
  16892. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16893. * @returns the list of size gradients
  16894. */
  16895. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16896. /**
  16897. * Gets the current list of color remap gradients.
  16898. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16899. * @returns the list of color remap gradients
  16900. */
  16901. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16902. /**
  16903. * Gets the current list of alpha remap gradients.
  16904. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16905. * @returns the list of alpha remap gradients
  16906. */
  16907. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16908. /**
  16909. * Gets the current list of life time gradients.
  16910. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16911. * @returns the list of life time gradients
  16912. */
  16913. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16914. /**
  16915. * Gets the current list of angular speed gradients.
  16916. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16917. * @returns the list of angular speed gradients
  16918. */
  16919. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16920. /**
  16921. * Gets the current list of velocity gradients.
  16922. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16923. * @returns the list of velocity gradients
  16924. */
  16925. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16926. /**
  16927. * Gets the current list of start size gradients.
  16928. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16929. * @returns the list of start size gradients
  16930. */
  16931. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16932. /**
  16933. * Gets the current list of emit rate gradients.
  16934. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16935. * @returns the list of emit rate gradients
  16936. */
  16937. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16938. /**
  16939. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16940. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16941. */
  16942. direction1: Vector3;
  16943. /**
  16944. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16945. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16946. */
  16947. direction2: Vector3;
  16948. /**
  16949. * 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.
  16950. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16951. */
  16952. minEmitBox: Vector3;
  16953. /**
  16954. * 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.
  16955. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16956. */
  16957. maxEmitBox: Vector3;
  16958. /**
  16959. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16960. */
  16961. color1: Color4;
  16962. /**
  16963. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16964. */
  16965. color2: Color4;
  16966. /**
  16967. * Color the particle will have at the end of its lifetime
  16968. */
  16969. colorDead: Color4;
  16970. /**
  16971. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16972. */
  16973. textureMask: Color4;
  16974. /**
  16975. * The particle emitter type defines the emitter used by the particle system.
  16976. * It can be for example box, sphere, or cone...
  16977. */
  16978. particleEmitterType: IParticleEmitterType;
  16979. /** @hidden */
  16980. _isSubEmitter: boolean;
  16981. /**
  16982. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16983. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16984. */
  16985. billboardMode: number;
  16986. protected _isBillboardBased: boolean;
  16987. /**
  16988. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16989. */
  16990. isBillboardBased: boolean;
  16991. /**
  16992. * The scene the particle system belongs to.
  16993. */
  16994. protected _scene: Scene;
  16995. /**
  16996. * Local cache of defines for image processing.
  16997. */
  16998. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16999. /**
  17000. * Default configuration related to image processing available in the standard Material.
  17001. */
  17002. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17003. /**
  17004. * Gets the image processing configuration used either in this material.
  17005. */
  17006. /**
  17007. * Sets the Default image processing configuration used either in the this material.
  17008. *
  17009. * If sets to null, the scene one is in use.
  17010. */
  17011. imageProcessingConfiguration: ImageProcessingConfiguration;
  17012. /**
  17013. * Attaches a new image processing configuration to the Standard Material.
  17014. * @param configuration
  17015. */
  17016. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17017. /** @hidden */
  17018. protected _reset(): void;
  17019. /** @hidden */
  17020. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17021. /**
  17022. * Instantiates a particle system.
  17023. * 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.
  17024. * @param name The name of the particle system
  17025. */
  17026. constructor(name: string);
  17027. /**
  17028. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17029. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17030. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17031. * @returns the emitter
  17032. */
  17033. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17034. /**
  17035. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17036. * @param radius The radius of the hemisphere to emit from
  17037. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17038. * @returns the emitter
  17039. */
  17040. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17041. /**
  17042. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17043. * @param radius The radius of the sphere to emit from
  17044. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17045. * @returns the emitter
  17046. */
  17047. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17048. /**
  17049. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17050. * @param radius The radius of the sphere to emit from
  17051. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17052. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17053. * @returns the emitter
  17054. */
  17055. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17056. /**
  17057. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17058. * @param radius The radius of the emission cylinder
  17059. * @param height The height of the emission cylinder
  17060. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17061. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17062. * @returns the emitter
  17063. */
  17064. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17065. /**
  17066. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17067. * @param radius The radius of the cylinder to emit from
  17068. * @param height The height of the emission cylinder
  17069. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17070. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17071. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17072. * @returns the emitter
  17073. */
  17074. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17075. /**
  17076. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17077. * @param radius The radius of the cone to emit from
  17078. * @param angle The base angle of the cone
  17079. * @returns the emitter
  17080. */
  17081. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17082. /**
  17083. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17084. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17085. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17086. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17087. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17088. * @returns the emitter
  17089. */
  17090. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17091. }
  17092. }
  17093. declare module BABYLON {
  17094. /**
  17095. * Type of sub emitter
  17096. */
  17097. export enum SubEmitterType {
  17098. /**
  17099. * Attached to the particle over it's lifetime
  17100. */
  17101. ATTACHED = 0,
  17102. /**
  17103. * Created when the particle dies
  17104. */
  17105. END = 1
  17106. }
  17107. /**
  17108. * Sub emitter class used to emit particles from an existing particle
  17109. */
  17110. export class SubEmitter {
  17111. /**
  17112. * the particle system to be used by the sub emitter
  17113. */
  17114. particleSystem: ParticleSystem;
  17115. /**
  17116. * Type of the submitter (Default: END)
  17117. */
  17118. type: SubEmitterType;
  17119. /**
  17120. * 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)
  17121. * Note: This only is supported when using an emitter of type Mesh
  17122. */
  17123. inheritDirection: boolean;
  17124. /**
  17125. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17126. */
  17127. inheritedVelocityAmount: number;
  17128. /**
  17129. * Creates a sub emitter
  17130. * @param particleSystem the particle system to be used by the sub emitter
  17131. */
  17132. constructor(
  17133. /**
  17134. * the particle system to be used by the sub emitter
  17135. */
  17136. particleSystem: ParticleSystem);
  17137. /**
  17138. * Clones the sub emitter
  17139. * @returns the cloned sub emitter
  17140. */
  17141. clone(): SubEmitter;
  17142. /**
  17143. * Serialize current object to a JSON object
  17144. * @returns the serialized object
  17145. */
  17146. serialize(): any;
  17147. /** @hidden */
  17148. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17149. /**
  17150. * Creates a new SubEmitter from a serialized JSON version
  17151. * @param serializationObject defines the JSON object to read from
  17152. * @param scene defines the hosting scene
  17153. * @param rootUrl defines the rootUrl for data loading
  17154. * @returns a new SubEmitter
  17155. */
  17156. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17157. /** Release associated resources */
  17158. dispose(): void;
  17159. }
  17160. }
  17161. declare module BABYLON {
  17162. /** @hidden */
  17163. export var clipPlaneFragmentDeclaration: {
  17164. name: string;
  17165. shader: string;
  17166. };
  17167. }
  17168. declare module BABYLON {
  17169. /** @hidden */
  17170. export var imageProcessingDeclaration: {
  17171. name: string;
  17172. shader: string;
  17173. };
  17174. }
  17175. declare module BABYLON {
  17176. /** @hidden */
  17177. export var imageProcessingFunctions: {
  17178. name: string;
  17179. shader: string;
  17180. };
  17181. }
  17182. declare module BABYLON {
  17183. /** @hidden */
  17184. export var clipPlaneFragment: {
  17185. name: string;
  17186. shader: string;
  17187. };
  17188. }
  17189. declare module BABYLON {
  17190. /** @hidden */
  17191. export var particlesPixelShader: {
  17192. name: string;
  17193. shader: string;
  17194. };
  17195. }
  17196. declare module BABYLON {
  17197. /** @hidden */
  17198. export var clipPlaneVertexDeclaration: {
  17199. name: string;
  17200. shader: string;
  17201. };
  17202. }
  17203. declare module BABYLON {
  17204. /** @hidden */
  17205. export var clipPlaneVertex: {
  17206. name: string;
  17207. shader: string;
  17208. };
  17209. }
  17210. declare module BABYLON {
  17211. /** @hidden */
  17212. export var particlesVertexShader: {
  17213. name: string;
  17214. shader: string;
  17215. };
  17216. }
  17217. declare module BABYLON {
  17218. /**
  17219. * This represents a particle system in Babylon.
  17220. * 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.
  17221. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17222. * @example https://doc.babylonjs.com/babylon101/particles
  17223. */
  17224. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17225. /**
  17226. * Billboard mode will only apply to Y axis
  17227. */
  17228. static readonly BILLBOARDMODE_Y: number;
  17229. /**
  17230. * Billboard mode will apply to all axes
  17231. */
  17232. static readonly BILLBOARDMODE_ALL: number;
  17233. /**
  17234. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17235. */
  17236. static readonly BILLBOARDMODE_STRETCHED: number;
  17237. /**
  17238. * This function can be defined to provide custom update for active particles.
  17239. * This function will be called instead of regular update (age, position, color, etc.).
  17240. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17241. */
  17242. updateFunction: (particles: Particle[]) => void;
  17243. private _emitterWorldMatrix;
  17244. /**
  17245. * This function can be defined to specify initial direction for every new particle.
  17246. * It by default use the emitterType defined function
  17247. */
  17248. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17249. /**
  17250. * This function can be defined to specify initial position for every new particle.
  17251. * It by default use the emitterType defined function
  17252. */
  17253. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17254. /**
  17255. * @hidden
  17256. */
  17257. _inheritedVelocityOffset: Vector3;
  17258. /**
  17259. * An event triggered when the system is disposed
  17260. */
  17261. onDisposeObservable: Observable<ParticleSystem>;
  17262. private _onDisposeObserver;
  17263. /**
  17264. * Sets a callback that will be triggered when the system is disposed
  17265. */
  17266. onDispose: () => void;
  17267. private _particles;
  17268. private _epsilon;
  17269. private _capacity;
  17270. private _stockParticles;
  17271. private _newPartsExcess;
  17272. private _vertexData;
  17273. private _vertexBuffer;
  17274. private _vertexBuffers;
  17275. private _spriteBuffer;
  17276. private _indexBuffer;
  17277. private _effect;
  17278. private _customEffect;
  17279. private _cachedDefines;
  17280. private _scaledColorStep;
  17281. private _colorDiff;
  17282. private _scaledDirection;
  17283. private _scaledGravity;
  17284. private _currentRenderId;
  17285. private _alive;
  17286. private _useInstancing;
  17287. private _started;
  17288. private _stopped;
  17289. private _actualFrame;
  17290. private _scaledUpdateSpeed;
  17291. private _vertexBufferSize;
  17292. /** @hidden */
  17293. _currentEmitRateGradient: Nullable<FactorGradient>;
  17294. /** @hidden */
  17295. _currentEmitRate1: number;
  17296. /** @hidden */
  17297. _currentEmitRate2: number;
  17298. /** @hidden */
  17299. _currentStartSizeGradient: Nullable<FactorGradient>;
  17300. /** @hidden */
  17301. _currentStartSize1: number;
  17302. /** @hidden */
  17303. _currentStartSize2: number;
  17304. private readonly _rawTextureWidth;
  17305. private _rampGradientsTexture;
  17306. private _useRampGradients;
  17307. /** Gets or sets a boolean indicating that ramp gradients must be used
  17308. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17309. */
  17310. useRampGradients: boolean;
  17311. /**
  17312. * 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.
  17313. * 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: [])
  17314. */
  17315. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17316. private _subEmitters;
  17317. /**
  17318. * @hidden
  17319. * If the particle systems emitter should be disposed when the particle system is disposed
  17320. */
  17321. _disposeEmitterOnDispose: boolean;
  17322. /**
  17323. * The current active Sub-systems, this property is used by the root particle system only.
  17324. */
  17325. activeSubSystems: Array<ParticleSystem>;
  17326. private _rootParticleSystem;
  17327. /**
  17328. * Gets the current list of active particles
  17329. */
  17330. readonly particles: Particle[];
  17331. /**
  17332. * Returns the string "ParticleSystem"
  17333. * @returns a string containing the class name
  17334. */
  17335. getClassName(): string;
  17336. /**
  17337. * Instantiates a particle system.
  17338. * 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.
  17339. * @param name The name of the particle system
  17340. * @param capacity The max number of particles alive at the same time
  17341. * @param scene The scene the particle system belongs to
  17342. * @param customEffect a custom effect used to change the way particles are rendered by default
  17343. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17344. * @param epsilon Offset used to render the particles
  17345. */
  17346. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17347. private _addFactorGradient;
  17348. private _removeFactorGradient;
  17349. /**
  17350. * Adds a new life time gradient
  17351. * @param gradient defines the gradient to use (between 0 and 1)
  17352. * @param factor defines the life time factor to affect to the specified gradient
  17353. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17354. * @returns the current particle system
  17355. */
  17356. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17357. /**
  17358. * Remove a specific life time gradient
  17359. * @param gradient defines the gradient to remove
  17360. * @returns the current particle system
  17361. */
  17362. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17363. /**
  17364. * Adds a new size gradient
  17365. * @param gradient defines the gradient to use (between 0 and 1)
  17366. * @param factor defines the size factor to affect to the specified gradient
  17367. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17368. * @returns the current particle system
  17369. */
  17370. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17371. /**
  17372. * Remove a specific size gradient
  17373. * @param gradient defines the gradient to remove
  17374. * @returns the current particle system
  17375. */
  17376. removeSizeGradient(gradient: number): IParticleSystem;
  17377. /**
  17378. * Adds a new color remap gradient
  17379. * @param gradient defines the gradient to use (between 0 and 1)
  17380. * @param min defines the color remap minimal range
  17381. * @param max defines the color remap maximal range
  17382. * @returns the current particle system
  17383. */
  17384. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17385. /**
  17386. * Remove a specific color remap gradient
  17387. * @param gradient defines the gradient to remove
  17388. * @returns the current particle system
  17389. */
  17390. removeColorRemapGradient(gradient: number): IParticleSystem;
  17391. /**
  17392. * Adds a new alpha remap gradient
  17393. * @param gradient defines the gradient to use (between 0 and 1)
  17394. * @param min defines the alpha remap minimal range
  17395. * @param max defines the alpha remap maximal range
  17396. * @returns the current particle system
  17397. */
  17398. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17399. /**
  17400. * Remove a specific alpha remap gradient
  17401. * @param gradient defines the gradient to remove
  17402. * @returns the current particle system
  17403. */
  17404. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17405. /**
  17406. * Adds a new angular speed gradient
  17407. * @param gradient defines the gradient to use (between 0 and 1)
  17408. * @param factor defines the angular speed to affect to the specified gradient
  17409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17410. * @returns the current particle system
  17411. */
  17412. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17413. /**
  17414. * Remove a specific angular speed gradient
  17415. * @param gradient defines the gradient to remove
  17416. * @returns the current particle system
  17417. */
  17418. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17419. /**
  17420. * Adds a new velocity gradient
  17421. * @param gradient defines the gradient to use (between 0 and 1)
  17422. * @param factor defines the velocity to affect to the specified gradient
  17423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17424. * @returns the current particle system
  17425. */
  17426. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17427. /**
  17428. * Remove a specific velocity gradient
  17429. * @param gradient defines the gradient to remove
  17430. * @returns the current particle system
  17431. */
  17432. removeVelocityGradient(gradient: number): IParticleSystem;
  17433. /**
  17434. * Adds a new limit velocity gradient
  17435. * @param gradient defines the gradient to use (between 0 and 1)
  17436. * @param factor defines the limit velocity value to affect to the specified gradient
  17437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17438. * @returns the current particle system
  17439. */
  17440. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17441. /**
  17442. * Remove a specific limit velocity gradient
  17443. * @param gradient defines the gradient to remove
  17444. * @returns the current particle system
  17445. */
  17446. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17447. /**
  17448. * Adds a new drag gradient
  17449. * @param gradient defines the gradient to use (between 0 and 1)
  17450. * @param factor defines the drag value to affect to the specified gradient
  17451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17452. * @returns the current particle system
  17453. */
  17454. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17455. /**
  17456. * Remove a specific drag gradient
  17457. * @param gradient defines the gradient to remove
  17458. * @returns the current particle system
  17459. */
  17460. removeDragGradient(gradient: number): IParticleSystem;
  17461. /**
  17462. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17463. * @param gradient defines the gradient to use (between 0 and 1)
  17464. * @param factor defines the emit rate value to affect to the specified gradient
  17465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17466. * @returns the current particle system
  17467. */
  17468. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17469. /**
  17470. * Remove a specific emit rate gradient
  17471. * @param gradient defines the gradient to remove
  17472. * @returns the current particle system
  17473. */
  17474. removeEmitRateGradient(gradient: number): IParticleSystem;
  17475. /**
  17476. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17477. * @param gradient defines the gradient to use (between 0 and 1)
  17478. * @param factor defines the start size value to affect to the specified gradient
  17479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17480. * @returns the current particle system
  17481. */
  17482. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17483. /**
  17484. * Remove a specific start size gradient
  17485. * @param gradient defines the gradient to remove
  17486. * @returns the current particle system
  17487. */
  17488. removeStartSizeGradient(gradient: number): IParticleSystem;
  17489. private _createRampGradientTexture;
  17490. /**
  17491. * Gets the current list of ramp gradients.
  17492. * You must use addRampGradient and removeRampGradient to udpate this list
  17493. * @returns the list of ramp gradients
  17494. */
  17495. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17496. /**
  17497. * Adds a new ramp gradient used to remap particle colors
  17498. * @param gradient defines the gradient to use (between 0 and 1)
  17499. * @param color defines the color to affect to the specified gradient
  17500. * @returns the current particle system
  17501. */
  17502. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17503. /**
  17504. * Remove a specific ramp gradient
  17505. * @param gradient defines the gradient to remove
  17506. * @returns the current particle system
  17507. */
  17508. removeRampGradient(gradient: number): ParticleSystem;
  17509. /**
  17510. * Adds a new color gradient
  17511. * @param gradient defines the gradient to use (between 0 and 1)
  17512. * @param color1 defines the color to affect to the specified gradient
  17513. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17514. * @returns this particle system
  17515. */
  17516. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17517. /**
  17518. * Remove a specific color gradient
  17519. * @param gradient defines the gradient to remove
  17520. * @returns this particle system
  17521. */
  17522. removeColorGradient(gradient: number): IParticleSystem;
  17523. private _fetchR;
  17524. protected _reset(): void;
  17525. private _resetEffect;
  17526. private _createVertexBuffers;
  17527. private _createIndexBuffer;
  17528. /**
  17529. * Gets the maximum number of particles active at the same time.
  17530. * @returns The max number of active particles.
  17531. */
  17532. getCapacity(): number;
  17533. /**
  17534. * Gets whether there are still active particles in the system.
  17535. * @returns True if it is alive, otherwise false.
  17536. */
  17537. isAlive(): boolean;
  17538. /**
  17539. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17540. * @returns True if it has been started, otherwise false.
  17541. */
  17542. isStarted(): boolean;
  17543. private _prepareSubEmitterInternalArray;
  17544. /**
  17545. * Starts the particle system and begins to emit
  17546. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17547. */
  17548. start(delay?: number): void;
  17549. /**
  17550. * Stops the particle system.
  17551. * @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.
  17552. */
  17553. stop(stopSubEmitters?: boolean): void;
  17554. /**
  17555. * Remove all active particles
  17556. */
  17557. reset(): void;
  17558. /**
  17559. * @hidden (for internal use only)
  17560. */
  17561. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17562. /**
  17563. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17564. * Its lifetime will start back at 0.
  17565. */
  17566. recycleParticle: (particle: Particle) => void;
  17567. private _stopSubEmitters;
  17568. private _createParticle;
  17569. private _removeFromRoot;
  17570. private _emitFromParticle;
  17571. private _update;
  17572. /** @hidden */
  17573. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17574. /** @hidden */
  17575. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17576. /** @hidden */
  17577. private _getEffect;
  17578. /**
  17579. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17580. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17581. */
  17582. animate(preWarmOnly?: boolean): void;
  17583. private _appendParticleVertices;
  17584. /**
  17585. * Rebuilds the particle system.
  17586. */
  17587. rebuild(): void;
  17588. /**
  17589. * Is this system ready to be used/rendered
  17590. * @return true if the system is ready
  17591. */
  17592. isReady(): boolean;
  17593. private _render;
  17594. /**
  17595. * Renders the particle system in its current state.
  17596. * @returns the current number of particles
  17597. */
  17598. render(): number;
  17599. /**
  17600. * Disposes the particle system and free the associated resources
  17601. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17602. */
  17603. dispose(disposeTexture?: boolean): void;
  17604. /**
  17605. * Clones the particle system.
  17606. * @param name The name of the cloned object
  17607. * @param newEmitter The new emitter to use
  17608. * @returns the cloned particle system
  17609. */
  17610. clone(name: string, newEmitter: any): ParticleSystem;
  17611. /**
  17612. * Serializes the particle system to a JSON object.
  17613. * @returns the JSON object
  17614. */
  17615. serialize(): any;
  17616. /** @hidden */
  17617. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17618. /** @hidden */
  17619. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17620. /**
  17621. * Parses a JSON object to create a particle system.
  17622. * @param parsedParticleSystem The JSON object to parse
  17623. * @param scene The scene to create the particle system in
  17624. * @param rootUrl The root url to use to load external dependencies like texture
  17625. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17626. * @returns the Parsed particle system
  17627. */
  17628. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17629. }
  17630. }
  17631. declare module BABYLON {
  17632. /**
  17633. * A particle represents one of the element emitted by a particle system.
  17634. * This is mainly define by its coordinates, direction, velocity and age.
  17635. */
  17636. export class Particle {
  17637. /**
  17638. * The particle system the particle belongs to.
  17639. */
  17640. particleSystem: ParticleSystem;
  17641. private static _Count;
  17642. /**
  17643. * Unique ID of the particle
  17644. */
  17645. id: number;
  17646. /**
  17647. * The world position of the particle in the scene.
  17648. */
  17649. position: Vector3;
  17650. /**
  17651. * The world direction of the particle in the scene.
  17652. */
  17653. direction: Vector3;
  17654. /**
  17655. * The color of the particle.
  17656. */
  17657. color: Color4;
  17658. /**
  17659. * The color change of the particle per step.
  17660. */
  17661. colorStep: Color4;
  17662. /**
  17663. * Defines how long will the life of the particle be.
  17664. */
  17665. lifeTime: number;
  17666. /**
  17667. * The current age of the particle.
  17668. */
  17669. age: number;
  17670. /**
  17671. * The current size of the particle.
  17672. */
  17673. size: number;
  17674. /**
  17675. * The current scale of the particle.
  17676. */
  17677. scale: Vector2;
  17678. /**
  17679. * The current angle of the particle.
  17680. */
  17681. angle: number;
  17682. /**
  17683. * Defines how fast is the angle changing.
  17684. */
  17685. angularSpeed: number;
  17686. /**
  17687. * Defines the cell index used by the particle to be rendered from a sprite.
  17688. */
  17689. cellIndex: number;
  17690. /**
  17691. * The information required to support color remapping
  17692. */
  17693. remapData: Vector4;
  17694. /** @hidden */
  17695. _randomCellOffset?: number;
  17696. /** @hidden */
  17697. _initialDirection: Nullable<Vector3>;
  17698. /** @hidden */
  17699. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17700. /** @hidden */
  17701. _initialStartSpriteCellID: number;
  17702. /** @hidden */
  17703. _initialEndSpriteCellID: number;
  17704. /** @hidden */
  17705. _currentColorGradient: Nullable<ColorGradient>;
  17706. /** @hidden */
  17707. _currentColor1: Color4;
  17708. /** @hidden */
  17709. _currentColor2: Color4;
  17710. /** @hidden */
  17711. _currentSizeGradient: Nullable<FactorGradient>;
  17712. /** @hidden */
  17713. _currentSize1: number;
  17714. /** @hidden */
  17715. _currentSize2: number;
  17716. /** @hidden */
  17717. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17718. /** @hidden */
  17719. _currentAngularSpeed1: number;
  17720. /** @hidden */
  17721. _currentAngularSpeed2: number;
  17722. /** @hidden */
  17723. _currentVelocityGradient: Nullable<FactorGradient>;
  17724. /** @hidden */
  17725. _currentVelocity1: number;
  17726. /** @hidden */
  17727. _currentVelocity2: number;
  17728. /** @hidden */
  17729. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17730. /** @hidden */
  17731. _currentLimitVelocity1: number;
  17732. /** @hidden */
  17733. _currentLimitVelocity2: number;
  17734. /** @hidden */
  17735. _currentDragGradient: Nullable<FactorGradient>;
  17736. /** @hidden */
  17737. _currentDrag1: number;
  17738. /** @hidden */
  17739. _currentDrag2: number;
  17740. /** @hidden */
  17741. _randomNoiseCoordinates1: Vector3;
  17742. /** @hidden */
  17743. _randomNoiseCoordinates2: Vector3;
  17744. /**
  17745. * Creates a new instance Particle
  17746. * @param particleSystem the particle system the particle belongs to
  17747. */
  17748. constructor(
  17749. /**
  17750. * The particle system the particle belongs to.
  17751. */
  17752. particleSystem: ParticleSystem);
  17753. private updateCellInfoFromSystem;
  17754. /**
  17755. * Defines how the sprite cell index is updated for the particle
  17756. */
  17757. updateCellIndex(): void;
  17758. /** @hidden */
  17759. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17760. /** @hidden */
  17761. _inheritParticleInfoToSubEmitters(): void;
  17762. /** @hidden */
  17763. _reset(): void;
  17764. /**
  17765. * Copy the properties of particle to another one.
  17766. * @param other the particle to copy the information to.
  17767. */
  17768. copyTo(other: Particle): void;
  17769. }
  17770. }
  17771. declare module BABYLON {
  17772. /**
  17773. * Particle emitter represents a volume emitting particles.
  17774. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17775. */
  17776. export interface IParticleEmitterType {
  17777. /**
  17778. * Called by the particle System when the direction is computed for the created particle.
  17779. * @param worldMatrix is the world matrix of the particle system
  17780. * @param directionToUpdate is the direction vector to update with the result
  17781. * @param particle is the particle we are computed the direction for
  17782. */
  17783. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17784. /**
  17785. * Called by the particle System when the position is computed for the created particle.
  17786. * @param worldMatrix is the world matrix of the particle system
  17787. * @param positionToUpdate is the position vector to update with the result
  17788. * @param particle is the particle we are computed the position for
  17789. */
  17790. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17791. /**
  17792. * Clones the current emitter and returns a copy of it
  17793. * @returns the new emitter
  17794. */
  17795. clone(): IParticleEmitterType;
  17796. /**
  17797. * Called by the GPUParticleSystem to setup the update shader
  17798. * @param effect defines the update shader
  17799. */
  17800. applyToShader(effect: Effect): void;
  17801. /**
  17802. * Returns a string to use to update the GPU particles update shader
  17803. * @returns the effect defines string
  17804. */
  17805. getEffectDefines(): string;
  17806. /**
  17807. * Returns a string representing the class name
  17808. * @returns a string containing the class name
  17809. */
  17810. getClassName(): string;
  17811. /**
  17812. * Serializes the particle system to a JSON object.
  17813. * @returns the JSON object
  17814. */
  17815. serialize(): any;
  17816. /**
  17817. * Parse properties from a JSON object
  17818. * @param serializationObject defines the JSON object
  17819. */
  17820. parse(serializationObject: any): void;
  17821. }
  17822. }
  17823. declare module BABYLON {
  17824. /**
  17825. * Particle emitter emitting particles from the inside of a box.
  17826. * It emits the particles randomly between 2 given directions.
  17827. */
  17828. export class BoxParticleEmitter implements IParticleEmitterType {
  17829. /**
  17830. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17831. */
  17832. direction1: Vector3;
  17833. /**
  17834. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17835. */
  17836. direction2: Vector3;
  17837. /**
  17838. * 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.
  17839. */
  17840. minEmitBox: Vector3;
  17841. /**
  17842. * 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.
  17843. */
  17844. maxEmitBox: Vector3;
  17845. /**
  17846. * Creates a new instance BoxParticleEmitter
  17847. */
  17848. constructor();
  17849. /**
  17850. * Called by the particle System when the direction is computed for the created particle.
  17851. * @param worldMatrix is the world matrix of the particle system
  17852. * @param directionToUpdate is the direction vector to update with the result
  17853. * @param particle is the particle we are computed the direction for
  17854. */
  17855. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17856. /**
  17857. * Called by the particle System when the position is computed for the created particle.
  17858. * @param worldMatrix is the world matrix of the particle system
  17859. * @param positionToUpdate is the position vector to update with the result
  17860. * @param particle is the particle we are computed the position for
  17861. */
  17862. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17863. /**
  17864. * Clones the current emitter and returns a copy of it
  17865. * @returns the new emitter
  17866. */
  17867. clone(): BoxParticleEmitter;
  17868. /**
  17869. * Called by the GPUParticleSystem to setup the update shader
  17870. * @param effect defines the update shader
  17871. */
  17872. applyToShader(effect: Effect): void;
  17873. /**
  17874. * Returns a string to use to update the GPU particles update shader
  17875. * @returns a string containng the defines string
  17876. */
  17877. getEffectDefines(): string;
  17878. /**
  17879. * Returns the string "BoxParticleEmitter"
  17880. * @returns a string containing the class name
  17881. */
  17882. getClassName(): string;
  17883. /**
  17884. * Serializes the particle system to a JSON object.
  17885. * @returns the JSON object
  17886. */
  17887. serialize(): any;
  17888. /**
  17889. * Parse properties from a JSON object
  17890. * @param serializationObject defines the JSON object
  17891. */
  17892. parse(serializationObject: any): void;
  17893. }
  17894. }
  17895. declare module BABYLON {
  17896. /**
  17897. * Particle emitter emitting particles from the inside of a cone.
  17898. * It emits the particles alongside the cone volume from the base to the particle.
  17899. * The emission direction might be randomized.
  17900. */
  17901. export class ConeParticleEmitter implements IParticleEmitterType {
  17902. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17903. directionRandomizer: number;
  17904. private _radius;
  17905. private _angle;
  17906. private _height;
  17907. /**
  17908. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17909. */
  17910. radiusRange: number;
  17911. /**
  17912. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17913. */
  17914. heightRange: number;
  17915. /**
  17916. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17917. */
  17918. emitFromSpawnPointOnly: boolean;
  17919. /**
  17920. * Gets or sets the radius of the emission cone
  17921. */
  17922. radius: number;
  17923. /**
  17924. * Gets or sets the angle of the emission cone
  17925. */
  17926. angle: number;
  17927. private _buildHeight;
  17928. /**
  17929. * Creates a new instance ConeParticleEmitter
  17930. * @param radius the radius of the emission cone (1 by default)
  17931. * @param angle the cone base angle (PI by default)
  17932. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17933. */
  17934. constructor(radius?: number, angle?: number,
  17935. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17936. directionRandomizer?: number);
  17937. /**
  17938. * Called by the particle System when the direction is computed for the created particle.
  17939. * @param worldMatrix is the world matrix of the particle system
  17940. * @param directionToUpdate is the direction vector to update with the result
  17941. * @param particle is the particle we are computed the direction for
  17942. */
  17943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17944. /**
  17945. * Called by the particle System when the position is computed for the created particle.
  17946. * @param worldMatrix is the world matrix of the particle system
  17947. * @param positionToUpdate is the position vector to update with the result
  17948. * @param particle is the particle we are computed the position for
  17949. */
  17950. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17951. /**
  17952. * Clones the current emitter and returns a copy of it
  17953. * @returns the new emitter
  17954. */
  17955. clone(): ConeParticleEmitter;
  17956. /**
  17957. * Called by the GPUParticleSystem to setup the update shader
  17958. * @param effect defines the update shader
  17959. */
  17960. applyToShader(effect: Effect): void;
  17961. /**
  17962. * Returns a string to use to update the GPU particles update shader
  17963. * @returns a string containng the defines string
  17964. */
  17965. getEffectDefines(): string;
  17966. /**
  17967. * Returns the string "ConeParticleEmitter"
  17968. * @returns a string containing the class name
  17969. */
  17970. getClassName(): string;
  17971. /**
  17972. * Serializes the particle system to a JSON object.
  17973. * @returns the JSON object
  17974. */
  17975. serialize(): any;
  17976. /**
  17977. * Parse properties from a JSON object
  17978. * @param serializationObject defines the JSON object
  17979. */
  17980. parse(serializationObject: any): void;
  17981. }
  17982. }
  17983. declare module BABYLON {
  17984. /**
  17985. * Particle emitter emitting particles from the inside of a cylinder.
  17986. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17987. */
  17988. export class CylinderParticleEmitter implements IParticleEmitterType {
  17989. /**
  17990. * The radius of the emission cylinder.
  17991. */
  17992. radius: number;
  17993. /**
  17994. * The height of the emission cylinder.
  17995. */
  17996. height: number;
  17997. /**
  17998. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17999. */
  18000. radiusRange: number;
  18001. /**
  18002. * How much to randomize the particle direction [0-1].
  18003. */
  18004. directionRandomizer: number;
  18005. /**
  18006. * Creates a new instance CylinderParticleEmitter
  18007. * @param radius the radius of the emission cylinder (1 by default)
  18008. * @param height the height of the emission cylinder (1 by default)
  18009. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18010. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18011. */
  18012. constructor(
  18013. /**
  18014. * The radius of the emission cylinder.
  18015. */
  18016. radius?: number,
  18017. /**
  18018. * The height of the emission cylinder.
  18019. */
  18020. height?: number,
  18021. /**
  18022. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18023. */
  18024. radiusRange?: number,
  18025. /**
  18026. * How much to randomize the particle direction [0-1].
  18027. */
  18028. directionRandomizer?: number);
  18029. /**
  18030. * Called by the particle System when the direction is computed for the created particle.
  18031. * @param worldMatrix is the world matrix of the particle system
  18032. * @param directionToUpdate is the direction vector to update with the result
  18033. * @param particle is the particle we are computed the direction for
  18034. */
  18035. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18036. /**
  18037. * Called by the particle System when the position is computed for the created particle.
  18038. * @param worldMatrix is the world matrix of the particle system
  18039. * @param positionToUpdate is the position vector to update with the result
  18040. * @param particle is the particle we are computed the position for
  18041. */
  18042. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18043. /**
  18044. * Clones the current emitter and returns a copy of it
  18045. * @returns the new emitter
  18046. */
  18047. clone(): CylinderParticleEmitter;
  18048. /**
  18049. * Called by the GPUParticleSystem to setup the update shader
  18050. * @param effect defines the update shader
  18051. */
  18052. applyToShader(effect: Effect): void;
  18053. /**
  18054. * Returns a string to use to update the GPU particles update shader
  18055. * @returns a string containng the defines string
  18056. */
  18057. getEffectDefines(): string;
  18058. /**
  18059. * Returns the string "CylinderParticleEmitter"
  18060. * @returns a string containing the class name
  18061. */
  18062. getClassName(): string;
  18063. /**
  18064. * Serializes the particle system to a JSON object.
  18065. * @returns the JSON object
  18066. */
  18067. serialize(): any;
  18068. /**
  18069. * Parse properties from a JSON object
  18070. * @param serializationObject defines the JSON object
  18071. */
  18072. parse(serializationObject: any): void;
  18073. }
  18074. /**
  18075. * Particle emitter emitting particles from the inside of a cylinder.
  18076. * It emits the particles randomly between two vectors.
  18077. */
  18078. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18079. /**
  18080. * The min limit of the emission direction.
  18081. */
  18082. direction1: Vector3;
  18083. /**
  18084. * The max limit of the emission direction.
  18085. */
  18086. direction2: Vector3;
  18087. /**
  18088. * Creates a new instance CylinderDirectedParticleEmitter
  18089. * @param radius the radius of the emission cylinder (1 by default)
  18090. * @param height the height of the emission cylinder (1 by default)
  18091. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18092. * @param direction1 the min limit of the emission direction (up vector by default)
  18093. * @param direction2 the max limit of the emission direction (up vector by default)
  18094. */
  18095. constructor(radius?: number, height?: number, radiusRange?: number,
  18096. /**
  18097. * The min limit of the emission direction.
  18098. */
  18099. direction1?: Vector3,
  18100. /**
  18101. * The max limit of the emission direction.
  18102. */
  18103. direction2?: Vector3);
  18104. /**
  18105. * Called by the particle System when the direction is computed for the created particle.
  18106. * @param worldMatrix is the world matrix of the particle system
  18107. * @param directionToUpdate is the direction vector to update with the result
  18108. * @param particle is the particle we are computed the direction for
  18109. */
  18110. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18111. /**
  18112. * Clones the current emitter and returns a copy of it
  18113. * @returns the new emitter
  18114. */
  18115. clone(): CylinderDirectedParticleEmitter;
  18116. /**
  18117. * Called by the GPUParticleSystem to setup the update shader
  18118. * @param effect defines the update shader
  18119. */
  18120. applyToShader(effect: Effect): void;
  18121. /**
  18122. * Returns a string to use to update the GPU particles update shader
  18123. * @returns a string containng the defines string
  18124. */
  18125. getEffectDefines(): string;
  18126. /**
  18127. * Returns the string "CylinderDirectedParticleEmitter"
  18128. * @returns a string containing the class name
  18129. */
  18130. getClassName(): string;
  18131. /**
  18132. * Serializes the particle system to a JSON object.
  18133. * @returns the JSON object
  18134. */
  18135. serialize(): any;
  18136. /**
  18137. * Parse properties from a JSON object
  18138. * @param serializationObject defines the JSON object
  18139. */
  18140. parse(serializationObject: any): void;
  18141. }
  18142. }
  18143. declare module BABYLON {
  18144. /**
  18145. * Particle emitter emitting particles from the inside of a hemisphere.
  18146. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18147. */
  18148. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18149. /**
  18150. * The radius of the emission hemisphere.
  18151. */
  18152. radius: number;
  18153. /**
  18154. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18155. */
  18156. radiusRange: number;
  18157. /**
  18158. * How much to randomize the particle direction [0-1].
  18159. */
  18160. directionRandomizer: number;
  18161. /**
  18162. * Creates a new instance HemisphericParticleEmitter
  18163. * @param radius the radius of the emission hemisphere (1 by default)
  18164. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18165. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18166. */
  18167. constructor(
  18168. /**
  18169. * The radius of the emission hemisphere.
  18170. */
  18171. radius?: number,
  18172. /**
  18173. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18174. */
  18175. radiusRange?: number,
  18176. /**
  18177. * How much to randomize the particle direction [0-1].
  18178. */
  18179. directionRandomizer?: number);
  18180. /**
  18181. * Called by the particle System when the direction is computed for the created particle.
  18182. * @param worldMatrix is the world matrix of the particle system
  18183. * @param directionToUpdate is the direction vector to update with the result
  18184. * @param particle is the particle we are computed the direction for
  18185. */
  18186. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18187. /**
  18188. * Called by the particle System when the position is computed for the created particle.
  18189. * @param worldMatrix is the world matrix of the particle system
  18190. * @param positionToUpdate is the position vector to update with the result
  18191. * @param particle is the particle we are computed the position for
  18192. */
  18193. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18194. /**
  18195. * Clones the current emitter and returns a copy of it
  18196. * @returns the new emitter
  18197. */
  18198. clone(): HemisphericParticleEmitter;
  18199. /**
  18200. * Called by the GPUParticleSystem to setup the update shader
  18201. * @param effect defines the update shader
  18202. */
  18203. applyToShader(effect: Effect): void;
  18204. /**
  18205. * Returns a string to use to update the GPU particles update shader
  18206. * @returns a string containng the defines string
  18207. */
  18208. getEffectDefines(): string;
  18209. /**
  18210. * Returns the string "HemisphericParticleEmitter"
  18211. * @returns a string containing the class name
  18212. */
  18213. getClassName(): string;
  18214. /**
  18215. * Serializes the particle system to a JSON object.
  18216. * @returns the JSON object
  18217. */
  18218. serialize(): any;
  18219. /**
  18220. * Parse properties from a JSON object
  18221. * @param serializationObject defines the JSON object
  18222. */
  18223. parse(serializationObject: any): void;
  18224. }
  18225. }
  18226. declare module BABYLON {
  18227. /**
  18228. * Particle emitter emitting particles from a point.
  18229. * It emits the particles randomly between 2 given directions.
  18230. */
  18231. export class PointParticleEmitter implements IParticleEmitterType {
  18232. /**
  18233. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18234. */
  18235. direction1: Vector3;
  18236. /**
  18237. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18238. */
  18239. direction2: Vector3;
  18240. /**
  18241. * Creates a new instance PointParticleEmitter
  18242. */
  18243. constructor();
  18244. /**
  18245. * Called by the particle System when the direction is computed for the created particle.
  18246. * @param worldMatrix is the world matrix of the particle system
  18247. * @param directionToUpdate is the direction vector to update with the result
  18248. * @param particle is the particle we are computed the direction for
  18249. */
  18250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18251. /**
  18252. * Called by the particle System when the position is computed for the created particle.
  18253. * @param worldMatrix is the world matrix of the particle system
  18254. * @param positionToUpdate is the position vector to update with the result
  18255. * @param particle is the particle we are computed the position for
  18256. */
  18257. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18258. /**
  18259. * Clones the current emitter and returns a copy of it
  18260. * @returns the new emitter
  18261. */
  18262. clone(): PointParticleEmitter;
  18263. /**
  18264. * Called by the GPUParticleSystem to setup the update shader
  18265. * @param effect defines the update shader
  18266. */
  18267. applyToShader(effect: Effect): void;
  18268. /**
  18269. * Returns a string to use to update the GPU particles update shader
  18270. * @returns a string containng the defines string
  18271. */
  18272. getEffectDefines(): string;
  18273. /**
  18274. * Returns the string "PointParticleEmitter"
  18275. * @returns a string containing the class name
  18276. */
  18277. getClassName(): string;
  18278. /**
  18279. * Serializes the particle system to a JSON object.
  18280. * @returns the JSON object
  18281. */
  18282. serialize(): any;
  18283. /**
  18284. * Parse properties from a JSON object
  18285. * @param serializationObject defines the JSON object
  18286. */
  18287. parse(serializationObject: any): void;
  18288. }
  18289. }
  18290. declare module BABYLON {
  18291. /**
  18292. * Particle emitter emitting particles from the inside of a sphere.
  18293. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18294. */
  18295. export class SphereParticleEmitter implements IParticleEmitterType {
  18296. /**
  18297. * The radius of the emission sphere.
  18298. */
  18299. radius: number;
  18300. /**
  18301. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18302. */
  18303. radiusRange: number;
  18304. /**
  18305. * How much to randomize the particle direction [0-1].
  18306. */
  18307. directionRandomizer: number;
  18308. /**
  18309. * Creates a new instance SphereParticleEmitter
  18310. * @param radius the radius of the emission sphere (1 by default)
  18311. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18312. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18313. */
  18314. constructor(
  18315. /**
  18316. * The radius of the emission sphere.
  18317. */
  18318. radius?: number,
  18319. /**
  18320. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18321. */
  18322. radiusRange?: number,
  18323. /**
  18324. * How much to randomize the particle direction [0-1].
  18325. */
  18326. directionRandomizer?: number);
  18327. /**
  18328. * Called by the particle System when the direction is computed for the created particle.
  18329. * @param worldMatrix is the world matrix of the particle system
  18330. * @param directionToUpdate is the direction vector to update with the result
  18331. * @param particle is the particle we are computed the direction for
  18332. */
  18333. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18334. /**
  18335. * Called by the particle System when the position is computed for the created particle.
  18336. * @param worldMatrix is the world matrix of the particle system
  18337. * @param positionToUpdate is the position vector to update with the result
  18338. * @param particle is the particle we are computed the position for
  18339. */
  18340. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18341. /**
  18342. * Clones the current emitter and returns a copy of it
  18343. * @returns the new emitter
  18344. */
  18345. clone(): SphereParticleEmitter;
  18346. /**
  18347. * Called by the GPUParticleSystem to setup the update shader
  18348. * @param effect defines the update shader
  18349. */
  18350. applyToShader(effect: Effect): void;
  18351. /**
  18352. * Returns a string to use to update the GPU particles update shader
  18353. * @returns a string containng the defines string
  18354. */
  18355. getEffectDefines(): string;
  18356. /**
  18357. * Returns the string "SphereParticleEmitter"
  18358. * @returns a string containing the class name
  18359. */
  18360. getClassName(): string;
  18361. /**
  18362. * Serializes the particle system to a JSON object.
  18363. * @returns the JSON object
  18364. */
  18365. serialize(): any;
  18366. /**
  18367. * Parse properties from a JSON object
  18368. * @param serializationObject defines the JSON object
  18369. */
  18370. parse(serializationObject: any): void;
  18371. }
  18372. /**
  18373. * Particle emitter emitting particles from the inside of a sphere.
  18374. * It emits the particles randomly between two vectors.
  18375. */
  18376. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18377. /**
  18378. * The min limit of the emission direction.
  18379. */
  18380. direction1: Vector3;
  18381. /**
  18382. * The max limit of the emission direction.
  18383. */
  18384. direction2: Vector3;
  18385. /**
  18386. * Creates a new instance SphereDirectedParticleEmitter
  18387. * @param radius the radius of the emission sphere (1 by default)
  18388. * @param direction1 the min limit of the emission direction (up vector by default)
  18389. * @param direction2 the max limit of the emission direction (up vector by default)
  18390. */
  18391. constructor(radius?: number,
  18392. /**
  18393. * The min limit of the emission direction.
  18394. */
  18395. direction1?: Vector3,
  18396. /**
  18397. * The max limit of the emission direction.
  18398. */
  18399. direction2?: Vector3);
  18400. /**
  18401. * Called by the particle System when the direction is computed for the created particle.
  18402. * @param worldMatrix is the world matrix of the particle system
  18403. * @param directionToUpdate is the direction vector to update with the result
  18404. * @param particle is the particle we are computed the direction for
  18405. */
  18406. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18407. /**
  18408. * Clones the current emitter and returns a copy of it
  18409. * @returns the new emitter
  18410. */
  18411. clone(): SphereDirectedParticleEmitter;
  18412. /**
  18413. * Called by the GPUParticleSystem to setup the update shader
  18414. * @param effect defines the update shader
  18415. */
  18416. applyToShader(effect: Effect): void;
  18417. /**
  18418. * Returns a string to use to update the GPU particles update shader
  18419. * @returns a string containng the defines string
  18420. */
  18421. getEffectDefines(): string;
  18422. /**
  18423. * Returns the string "SphereDirectedParticleEmitter"
  18424. * @returns a string containing the class name
  18425. */
  18426. getClassName(): string;
  18427. /**
  18428. * Serializes the particle system to a JSON object.
  18429. * @returns the JSON object
  18430. */
  18431. serialize(): any;
  18432. /**
  18433. * Parse properties from a JSON object
  18434. * @param serializationObject defines the JSON object
  18435. */
  18436. parse(serializationObject: any): void;
  18437. }
  18438. }
  18439. declare module BABYLON {
  18440. /**
  18441. * Interface representing a particle system in Babylon.js.
  18442. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18443. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18444. */
  18445. export interface IParticleSystem {
  18446. /**
  18447. * List of animations used by the particle system.
  18448. */
  18449. animations: Animation[];
  18450. /**
  18451. * The id of the Particle system.
  18452. */
  18453. id: string;
  18454. /**
  18455. * The name of the Particle system.
  18456. */
  18457. name: string;
  18458. /**
  18459. * The emitter represents the Mesh or position we are attaching the particle system to.
  18460. */
  18461. emitter: Nullable<AbstractMesh | Vector3>;
  18462. /**
  18463. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18464. */
  18465. isBillboardBased: boolean;
  18466. /**
  18467. * The rendering group used by the Particle system to chose when to render.
  18468. */
  18469. renderingGroupId: number;
  18470. /**
  18471. * The layer mask we are rendering the particles through.
  18472. */
  18473. layerMask: number;
  18474. /**
  18475. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18476. */
  18477. updateSpeed: number;
  18478. /**
  18479. * The amount of time the particle system is running (depends of the overall update speed).
  18480. */
  18481. targetStopDuration: number;
  18482. /**
  18483. * The texture used to render each particle. (this can be a spritesheet)
  18484. */
  18485. particleTexture: Nullable<Texture>;
  18486. /**
  18487. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18488. */
  18489. blendMode: number;
  18490. /**
  18491. * Minimum life time of emitting particles.
  18492. */
  18493. minLifeTime: number;
  18494. /**
  18495. * Maximum life time of emitting particles.
  18496. */
  18497. maxLifeTime: number;
  18498. /**
  18499. * Minimum Size of emitting particles.
  18500. */
  18501. minSize: number;
  18502. /**
  18503. * Maximum Size of emitting particles.
  18504. */
  18505. maxSize: number;
  18506. /**
  18507. * Minimum scale of emitting particles on X axis.
  18508. */
  18509. minScaleX: number;
  18510. /**
  18511. * Maximum scale of emitting particles on X axis.
  18512. */
  18513. maxScaleX: number;
  18514. /**
  18515. * Minimum scale of emitting particles on Y axis.
  18516. */
  18517. minScaleY: number;
  18518. /**
  18519. * Maximum scale of emitting particles on Y axis.
  18520. */
  18521. maxScaleY: number;
  18522. /**
  18523. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18524. */
  18525. color1: Color4;
  18526. /**
  18527. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18528. */
  18529. color2: Color4;
  18530. /**
  18531. * Color the particle will have at the end of its lifetime.
  18532. */
  18533. colorDead: Color4;
  18534. /**
  18535. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18536. */
  18537. emitRate: number;
  18538. /**
  18539. * You can use gravity if you want to give an orientation to your particles.
  18540. */
  18541. gravity: Vector3;
  18542. /**
  18543. * Minimum power of emitting particles.
  18544. */
  18545. minEmitPower: number;
  18546. /**
  18547. * Maximum power of emitting particles.
  18548. */
  18549. maxEmitPower: number;
  18550. /**
  18551. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18552. */
  18553. minAngularSpeed: number;
  18554. /**
  18555. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18556. */
  18557. maxAngularSpeed: number;
  18558. /**
  18559. * Gets or sets the minimal initial rotation in radians.
  18560. */
  18561. minInitialRotation: number;
  18562. /**
  18563. * Gets or sets the maximal initial rotation in radians.
  18564. */
  18565. maxInitialRotation: number;
  18566. /**
  18567. * The particle emitter type defines the emitter used by the particle system.
  18568. * It can be for example box, sphere, or cone...
  18569. */
  18570. particleEmitterType: Nullable<IParticleEmitterType>;
  18571. /**
  18572. * Defines the delay in milliseconds before starting the system (0 by default)
  18573. */
  18574. startDelay: number;
  18575. /**
  18576. * 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
  18577. */
  18578. preWarmCycles: number;
  18579. /**
  18580. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18581. */
  18582. preWarmStepOffset: number;
  18583. /**
  18584. * 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)
  18585. */
  18586. spriteCellChangeSpeed: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18589. */
  18590. startSpriteCellID: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18593. */
  18594. endSpriteCellID: number;
  18595. /**
  18596. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18597. */
  18598. spriteCellWidth: number;
  18599. /**
  18600. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18601. */
  18602. spriteCellHeight: number;
  18603. /**
  18604. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18605. */
  18606. spriteRandomStartCell: boolean;
  18607. /**
  18608. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18609. */
  18610. isAnimationSheetEnabled: boolean;
  18611. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18612. translationPivot: Vector2;
  18613. /**
  18614. * Gets or sets a texture used to add random noise to particle positions
  18615. */
  18616. noiseTexture: Nullable<BaseTexture>;
  18617. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18618. noiseStrength: Vector3;
  18619. /**
  18620. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18621. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18622. */
  18623. billboardMode: number;
  18624. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18625. limitVelocityDamping: number;
  18626. /**
  18627. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18628. */
  18629. beginAnimationOnStart: boolean;
  18630. /**
  18631. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationFrom: number;
  18634. /**
  18635. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18636. */
  18637. beginAnimationTo: number;
  18638. /**
  18639. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18640. */
  18641. beginAnimationLoop: boolean;
  18642. /**
  18643. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18644. */
  18645. disposeOnStop: boolean;
  18646. /**
  18647. * Gets the maximum number of particles active at the same time.
  18648. * @returns The max number of active particles.
  18649. */
  18650. getCapacity(): number;
  18651. /**
  18652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18653. * @returns True if it has been started, otherwise false.
  18654. */
  18655. isStarted(): boolean;
  18656. /**
  18657. * Animates the particle system for this frame.
  18658. */
  18659. animate(): void;
  18660. /**
  18661. * Renders the particle system in its current state.
  18662. * @returns the current number of particles
  18663. */
  18664. render(): number;
  18665. /**
  18666. * Dispose the particle system and frees its associated resources.
  18667. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18668. */
  18669. dispose(disposeTexture?: boolean): void;
  18670. /**
  18671. * Clones the particle system.
  18672. * @param name The name of the cloned object
  18673. * @param newEmitter The new emitter to use
  18674. * @returns the cloned particle system
  18675. */
  18676. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18677. /**
  18678. * Serializes the particle system to a JSON object.
  18679. * @returns the JSON object
  18680. */
  18681. serialize(): any;
  18682. /**
  18683. * Rebuild the particle system
  18684. */
  18685. rebuild(): void;
  18686. /**
  18687. * Starts the particle system and begins to emit
  18688. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18689. */
  18690. start(delay?: number): void;
  18691. /**
  18692. * Stops the particle system.
  18693. */
  18694. stop(): void;
  18695. /**
  18696. * Remove all active particles
  18697. */
  18698. reset(): void;
  18699. /**
  18700. * Is this system ready to be used/rendered
  18701. * @return true if the system is ready
  18702. */
  18703. isReady(): boolean;
  18704. /**
  18705. * Adds a new color gradient
  18706. * @param gradient defines the gradient to use (between 0 and 1)
  18707. * @param color1 defines the color to affect to the specified gradient
  18708. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18709. * @returns the current particle system
  18710. */
  18711. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18712. /**
  18713. * Remove a specific color gradient
  18714. * @param gradient defines the gradient to remove
  18715. * @returns the current particle system
  18716. */
  18717. removeColorGradient(gradient: number): IParticleSystem;
  18718. /**
  18719. * Adds a new size gradient
  18720. * @param gradient defines the gradient to use (between 0 and 1)
  18721. * @param factor defines the size factor to affect to the specified gradient
  18722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18723. * @returns the current particle system
  18724. */
  18725. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18726. /**
  18727. * Remove a specific size gradient
  18728. * @param gradient defines the gradient to remove
  18729. * @returns the current particle system
  18730. */
  18731. removeSizeGradient(gradient: number): IParticleSystem;
  18732. /**
  18733. * Gets the current list of color gradients.
  18734. * You must use addColorGradient and removeColorGradient to udpate this list
  18735. * @returns the list of color gradients
  18736. */
  18737. getColorGradients(): Nullable<Array<ColorGradient>>;
  18738. /**
  18739. * Gets the current list of size gradients.
  18740. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18741. * @returns the list of size gradients
  18742. */
  18743. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18744. /**
  18745. * Gets the current list of angular speed gradients.
  18746. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18747. * @returns the list of angular speed gradients
  18748. */
  18749. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18750. /**
  18751. * Adds a new angular speed gradient
  18752. * @param gradient defines the gradient to use (between 0 and 1)
  18753. * @param factor defines the angular speed to affect to the specified gradient
  18754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18755. * @returns the current particle system
  18756. */
  18757. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18758. /**
  18759. * Remove a specific angular speed gradient
  18760. * @param gradient defines the gradient to remove
  18761. * @returns the current particle system
  18762. */
  18763. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18764. /**
  18765. * Gets the current list of velocity gradients.
  18766. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18767. * @returns the list of velocity gradients
  18768. */
  18769. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18770. /**
  18771. * Adds a new velocity gradient
  18772. * @param gradient defines the gradient to use (between 0 and 1)
  18773. * @param factor defines the velocity to affect to the specified gradient
  18774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18775. * @returns the current particle system
  18776. */
  18777. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18778. /**
  18779. * Remove a specific velocity gradient
  18780. * @param gradient defines the gradient to remove
  18781. * @returns the current particle system
  18782. */
  18783. removeVelocityGradient(gradient: number): IParticleSystem;
  18784. /**
  18785. * Gets the current list of limit velocity gradients.
  18786. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18787. * @returns the list of limit velocity gradients
  18788. */
  18789. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18790. /**
  18791. * Adds a new limit velocity gradient
  18792. * @param gradient defines the gradient to use (between 0 and 1)
  18793. * @param factor defines the limit velocity to affect to the specified gradient
  18794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18795. * @returns the current particle system
  18796. */
  18797. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18798. /**
  18799. * Remove a specific limit velocity gradient
  18800. * @param gradient defines the gradient to remove
  18801. * @returns the current particle system
  18802. */
  18803. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18804. /**
  18805. * Adds a new drag gradient
  18806. * @param gradient defines the gradient to use (between 0 and 1)
  18807. * @param factor defines the drag to affect to the specified gradient
  18808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18809. * @returns the current particle system
  18810. */
  18811. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18812. /**
  18813. * Remove a specific drag gradient
  18814. * @param gradient defines the gradient to remove
  18815. * @returns the current particle system
  18816. */
  18817. removeDragGradient(gradient: number): IParticleSystem;
  18818. /**
  18819. * Gets the current list of drag gradients.
  18820. * You must use addDragGradient and removeDragGradient to udpate this list
  18821. * @returns the list of drag gradients
  18822. */
  18823. getDragGradients(): Nullable<Array<FactorGradient>>;
  18824. /**
  18825. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18826. * @param gradient defines the gradient to use (between 0 and 1)
  18827. * @param factor defines the emit rate to affect to the specified gradient
  18828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18829. * @returns the current particle system
  18830. */
  18831. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18832. /**
  18833. * Remove a specific emit rate gradient
  18834. * @param gradient defines the gradient to remove
  18835. * @returns the current particle system
  18836. */
  18837. removeEmitRateGradient(gradient: number): IParticleSystem;
  18838. /**
  18839. * Gets the current list of emit rate gradients.
  18840. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18841. * @returns the list of emit rate gradients
  18842. */
  18843. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18844. /**
  18845. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18846. * @param gradient defines the gradient to use (between 0 and 1)
  18847. * @param factor defines the start size to affect to the specified gradient
  18848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18849. * @returns the current particle system
  18850. */
  18851. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18852. /**
  18853. * Remove a specific start size gradient
  18854. * @param gradient defines the gradient to remove
  18855. * @returns the current particle system
  18856. */
  18857. removeStartSizeGradient(gradient: number): IParticleSystem;
  18858. /**
  18859. * Gets the current list of start size gradients.
  18860. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18861. * @returns the list of start size gradients
  18862. */
  18863. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18864. /**
  18865. * Adds a new life time gradient
  18866. * @param gradient defines the gradient to use (between 0 and 1)
  18867. * @param factor defines the life time factor to affect to the specified gradient
  18868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18869. * @returns the current particle system
  18870. */
  18871. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18872. /**
  18873. * Remove a specific life time gradient
  18874. * @param gradient defines the gradient to remove
  18875. * @returns the current particle system
  18876. */
  18877. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18878. /**
  18879. * Gets the current list of life time gradients.
  18880. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18881. * @returns the list of life time gradients
  18882. */
  18883. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18884. /**
  18885. * Gets the current list of color gradients.
  18886. * You must use addColorGradient and removeColorGradient to udpate this list
  18887. * @returns the list of color gradients
  18888. */
  18889. getColorGradients(): Nullable<Array<ColorGradient>>;
  18890. /**
  18891. * Adds a new ramp gradient used to remap particle colors
  18892. * @param gradient defines the gradient to use (between 0 and 1)
  18893. * @param color defines the color to affect to the specified gradient
  18894. * @returns the current particle system
  18895. */
  18896. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18897. /**
  18898. * Gets the current list of ramp gradients.
  18899. * You must use addRampGradient and removeRampGradient to udpate this list
  18900. * @returns the list of ramp gradients
  18901. */
  18902. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18903. /** Gets or sets a boolean indicating that ramp gradients must be used
  18904. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18905. */
  18906. useRampGradients: boolean;
  18907. /**
  18908. * Adds a new color remap gradient
  18909. * @param gradient defines the gradient to use (between 0 and 1)
  18910. * @param min defines the color remap minimal range
  18911. * @param max defines the color remap maximal range
  18912. * @returns the current particle system
  18913. */
  18914. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18915. /**
  18916. * Gets the current list of color remap gradients.
  18917. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18918. * @returns the list of color remap gradients
  18919. */
  18920. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18921. /**
  18922. * Adds a new alpha remap gradient
  18923. * @param gradient defines the gradient to use (between 0 and 1)
  18924. * @param min defines the alpha remap minimal range
  18925. * @param max defines the alpha remap maximal range
  18926. * @returns the current particle system
  18927. */
  18928. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18929. /**
  18930. * Gets the current list of alpha remap gradients.
  18931. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18932. * @returns the list of alpha remap gradients
  18933. */
  18934. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18935. /**
  18936. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18937. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18938. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18939. * @returns the emitter
  18940. */
  18941. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18942. /**
  18943. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18944. * @param radius The radius of the hemisphere to emit from
  18945. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18946. * @returns the emitter
  18947. */
  18948. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18949. /**
  18950. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18951. * @param radius The radius of the sphere to emit from
  18952. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18953. * @returns the emitter
  18954. */
  18955. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18956. /**
  18957. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18958. * @param radius The radius of the sphere to emit from
  18959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18961. * @returns the emitter
  18962. */
  18963. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18964. /**
  18965. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18966. * @param radius The radius of the emission cylinder
  18967. * @param height The height of the emission cylinder
  18968. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18969. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18970. * @returns the emitter
  18971. */
  18972. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18973. /**
  18974. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18975. * @param radius The radius of the cylinder to emit from
  18976. * @param height The height of the emission cylinder
  18977. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18978. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18979. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18980. * @returns the emitter
  18981. */
  18982. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18983. /**
  18984. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18985. * @param radius The radius of the cone to emit from
  18986. * @param angle The base angle of the cone
  18987. * @returns the emitter
  18988. */
  18989. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18990. /**
  18991. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18992. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18993. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18994. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18995. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18996. * @returns the emitter
  18997. */
  18998. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18999. /**
  19000. * Get hosting scene
  19001. * @returns the scene
  19002. */
  19003. getScene(): Scene;
  19004. }
  19005. }
  19006. declare module BABYLON {
  19007. /**
  19008. * Creates an instance based on a source mesh.
  19009. */
  19010. export class InstancedMesh extends AbstractMesh {
  19011. private _sourceMesh;
  19012. private _currentLOD;
  19013. /** @hidden */
  19014. _indexInSourceMeshInstanceArray: number;
  19015. constructor(name: string, source: Mesh);
  19016. /**
  19017. * Returns the string "InstancedMesh".
  19018. */
  19019. getClassName(): string;
  19020. /** Gets the list of lights affecting that mesh */
  19021. readonly lightSources: Light[];
  19022. _resyncLightSources(): void;
  19023. _resyncLightSource(light: Light): void;
  19024. _removeLightSource(light: Light, dispose: boolean): void;
  19025. /**
  19026. * If the source mesh receives shadows
  19027. */
  19028. readonly receiveShadows: boolean;
  19029. /**
  19030. * The material of the source mesh
  19031. */
  19032. readonly material: Nullable<Material>;
  19033. /**
  19034. * Visibility of the source mesh
  19035. */
  19036. readonly visibility: number;
  19037. /**
  19038. * Skeleton of the source mesh
  19039. */
  19040. readonly skeleton: Nullable<Skeleton>;
  19041. /**
  19042. * Rendering ground id of the source mesh
  19043. */
  19044. renderingGroupId: number;
  19045. /**
  19046. * Returns the total number of vertices (integer).
  19047. */
  19048. getTotalVertices(): number;
  19049. /**
  19050. * Returns a positive integer : the total number of indices in this mesh geometry.
  19051. * @returns the numner of indices or zero if the mesh has no geometry.
  19052. */
  19053. getTotalIndices(): number;
  19054. /**
  19055. * The source mesh of the instance
  19056. */
  19057. readonly sourceMesh: Mesh;
  19058. /**
  19059. * Is this node ready to be used/rendered
  19060. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19061. * @return {boolean} is it ready
  19062. */
  19063. isReady(completeCheck?: boolean): boolean;
  19064. /**
  19065. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19066. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19067. * @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.
  19068. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19069. */
  19070. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19071. /**
  19072. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19073. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19074. * The `data` are either a numeric array either a Float32Array.
  19075. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19076. * 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).
  19077. * Note that a new underlying VertexBuffer object is created each call.
  19078. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19079. *
  19080. * Possible `kind` values :
  19081. * - VertexBuffer.PositionKind
  19082. * - VertexBuffer.UVKind
  19083. * - VertexBuffer.UV2Kind
  19084. * - VertexBuffer.UV3Kind
  19085. * - VertexBuffer.UV4Kind
  19086. * - VertexBuffer.UV5Kind
  19087. * - VertexBuffer.UV6Kind
  19088. * - VertexBuffer.ColorKind
  19089. * - VertexBuffer.MatricesIndicesKind
  19090. * - VertexBuffer.MatricesIndicesExtraKind
  19091. * - VertexBuffer.MatricesWeightsKind
  19092. * - VertexBuffer.MatricesWeightsExtraKind
  19093. *
  19094. * Returns the Mesh.
  19095. */
  19096. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19097. /**
  19098. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19099. * If the mesh has no geometry, it is simply returned as it is.
  19100. * The `data` are either a numeric array either a Float32Array.
  19101. * No new underlying VertexBuffer object is created.
  19102. * 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.
  19103. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19104. *
  19105. * Possible `kind` values :
  19106. * - VertexBuffer.PositionKind
  19107. * - VertexBuffer.UVKind
  19108. * - VertexBuffer.UV2Kind
  19109. * - VertexBuffer.UV3Kind
  19110. * - VertexBuffer.UV4Kind
  19111. * - VertexBuffer.UV5Kind
  19112. * - VertexBuffer.UV6Kind
  19113. * - VertexBuffer.ColorKind
  19114. * - VertexBuffer.MatricesIndicesKind
  19115. * - VertexBuffer.MatricesIndicesExtraKind
  19116. * - VertexBuffer.MatricesWeightsKind
  19117. * - VertexBuffer.MatricesWeightsExtraKind
  19118. *
  19119. * Returns the Mesh.
  19120. */
  19121. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19122. /**
  19123. * Sets the mesh indices.
  19124. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19125. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19126. * This method creates a new index buffer each call.
  19127. * Returns the Mesh.
  19128. */
  19129. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19130. /**
  19131. * Boolean : True if the mesh owns the requested kind of data.
  19132. */
  19133. isVerticesDataPresent(kind: string): boolean;
  19134. /**
  19135. * Returns an array of indices (IndicesArray).
  19136. */
  19137. getIndices(): Nullable<IndicesArray>;
  19138. readonly _positions: Nullable<Vector3[]>;
  19139. /**
  19140. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19141. * This means the mesh underlying bounding box and sphere are recomputed.
  19142. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19143. * @returns the current mesh
  19144. */
  19145. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19146. /** @hidden */
  19147. _preActivate(): InstancedMesh;
  19148. /** @hidden */
  19149. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19150. /** @hidden */
  19151. _postActivate(): void;
  19152. getWorldMatrix(): Matrix;
  19153. readonly isAnInstance: boolean;
  19154. /**
  19155. * Returns the current associated LOD AbstractMesh.
  19156. */
  19157. getLOD(camera: Camera): AbstractMesh;
  19158. /** @hidden */
  19159. _syncSubMeshes(): InstancedMesh;
  19160. /** @hidden */
  19161. _generatePointsArray(): boolean;
  19162. /**
  19163. * Creates a new InstancedMesh from the current mesh.
  19164. * - name (string) : the cloned mesh name
  19165. * - newParent (optional Node) : the optional Node to parent the clone to.
  19166. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19167. *
  19168. * Returns the clone.
  19169. */
  19170. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19171. /**
  19172. * Disposes the InstancedMesh.
  19173. * Returns nothing.
  19174. */
  19175. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19176. }
  19177. interface Mesh {
  19178. /**
  19179. * Register a custom buffer that will be instanced
  19180. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19181. * @param kind defines the buffer kind
  19182. * @param stride defines the stride in floats
  19183. */
  19184. registerInstancedBuffer(kind: string, stride: number): void;
  19185. /** @hidden */
  19186. _userInstancedBuffersStorage: {
  19187. data: {
  19188. [key: string]: Float32Array;
  19189. };
  19190. sizes: {
  19191. [key: string]: number;
  19192. };
  19193. vertexBuffers: {
  19194. [key: string]: Nullable<VertexBuffer>;
  19195. };
  19196. strides: {
  19197. [key: string]: number;
  19198. };
  19199. };
  19200. }
  19201. interface AbstractMesh {
  19202. /**
  19203. * Object used to store instanced buffers defined by user
  19204. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19205. */
  19206. instancedBuffers: {
  19207. [key: string]: any;
  19208. };
  19209. }
  19210. }
  19211. declare module BABYLON {
  19212. /**
  19213. * Defines the options associated with the creation of a shader material.
  19214. */
  19215. export interface IShaderMaterialOptions {
  19216. /**
  19217. * Does the material work in alpha blend mode
  19218. */
  19219. needAlphaBlending: boolean;
  19220. /**
  19221. * Does the material work in alpha test mode
  19222. */
  19223. needAlphaTesting: boolean;
  19224. /**
  19225. * The list of attribute names used in the shader
  19226. */
  19227. attributes: string[];
  19228. /**
  19229. * The list of unifrom names used in the shader
  19230. */
  19231. uniforms: string[];
  19232. /**
  19233. * The list of UBO names used in the shader
  19234. */
  19235. uniformBuffers: string[];
  19236. /**
  19237. * The list of sampler names used in the shader
  19238. */
  19239. samplers: string[];
  19240. /**
  19241. * The list of defines used in the shader
  19242. */
  19243. defines: string[];
  19244. }
  19245. /**
  19246. * 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.
  19247. *
  19248. * This returned material effects how the mesh will look based on the code in the shaders.
  19249. *
  19250. * @see http://doc.babylonjs.com/how_to/shader_material
  19251. */
  19252. export class ShaderMaterial extends Material {
  19253. private _shaderPath;
  19254. private _options;
  19255. private _textures;
  19256. private _textureArrays;
  19257. private _floats;
  19258. private _ints;
  19259. private _floatsArrays;
  19260. private _colors3;
  19261. private _colors3Arrays;
  19262. private _colors4;
  19263. private _colors4Arrays;
  19264. private _vectors2;
  19265. private _vectors3;
  19266. private _vectors4;
  19267. private _matrices;
  19268. private _matrixArrays;
  19269. private _matrices3x3;
  19270. private _matrices2x2;
  19271. private _vectors2Arrays;
  19272. private _vectors3Arrays;
  19273. private _vectors4Arrays;
  19274. private _cachedWorldViewMatrix;
  19275. private _cachedWorldViewProjectionMatrix;
  19276. private _renderId;
  19277. private _multiview;
  19278. /**
  19279. * Instantiate a new shader material.
  19280. * 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.
  19281. * This returned material effects how the mesh will look based on the code in the shaders.
  19282. * @see http://doc.babylonjs.com/how_to/shader_material
  19283. * @param name Define the name of the material in the scene
  19284. * @param scene Define the scene the material belongs to
  19285. * @param shaderPath Defines the route to the shader code in one of three ways:
  19286. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19287. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19288. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19289. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19290. * @param options Define the options used to create the shader
  19291. */
  19292. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19293. /**
  19294. * Gets the shader path used to define the shader code
  19295. * It can be modified to trigger a new compilation
  19296. */
  19297. /**
  19298. * Sets the shader path used to define the shader code
  19299. * It can be modified to trigger a new compilation
  19300. */
  19301. shaderPath: any;
  19302. /**
  19303. * Gets the options used to compile the shader.
  19304. * They can be modified to trigger a new compilation
  19305. */
  19306. readonly options: IShaderMaterialOptions;
  19307. /**
  19308. * Gets the current class name of the material e.g. "ShaderMaterial"
  19309. * Mainly use in serialization.
  19310. * @returns the class name
  19311. */
  19312. getClassName(): string;
  19313. /**
  19314. * Specifies if the material will require alpha blending
  19315. * @returns a boolean specifying if alpha blending is needed
  19316. */
  19317. needAlphaBlending(): boolean;
  19318. /**
  19319. * Specifies if this material should be rendered in alpha test mode
  19320. * @returns a boolean specifying if an alpha test is needed.
  19321. */
  19322. needAlphaTesting(): boolean;
  19323. private _checkUniform;
  19324. /**
  19325. * Set a texture in the shader.
  19326. * @param name Define the name of the uniform samplers as defined in the shader
  19327. * @param texture Define the texture to bind to this sampler
  19328. * @return the material itself allowing "fluent" like uniform updates
  19329. */
  19330. setTexture(name: string, texture: Texture): ShaderMaterial;
  19331. /**
  19332. * Set a texture array in the shader.
  19333. * @param name Define the name of the uniform sampler array as defined in the shader
  19334. * @param textures Define the list of textures to bind to this sampler
  19335. * @return the material itself allowing "fluent" like uniform updates
  19336. */
  19337. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19338. /**
  19339. * Set a float in the shader.
  19340. * @param name Define the name of the uniform as defined in the shader
  19341. * @param value Define the value to give to the uniform
  19342. * @return the material itself allowing "fluent" like uniform updates
  19343. */
  19344. setFloat(name: string, value: number): ShaderMaterial;
  19345. /**
  19346. * Set a int in the shader.
  19347. * @param name Define the name of the uniform as defined in the shader
  19348. * @param value Define the value to give to the uniform
  19349. * @return the material itself allowing "fluent" like uniform updates
  19350. */
  19351. setInt(name: string, value: number): ShaderMaterial;
  19352. /**
  19353. * Set an array of floats in the shader.
  19354. * @param name Define the name of the uniform as defined in the shader
  19355. * @param value Define the value to give to the uniform
  19356. * @return the material itself allowing "fluent" like uniform updates
  19357. */
  19358. setFloats(name: string, value: number[]): ShaderMaterial;
  19359. /**
  19360. * Set a vec3 in the shader from a Color3.
  19361. * @param name Define the name of the uniform as defined in the shader
  19362. * @param value Define the value to give to the uniform
  19363. * @return the material itself allowing "fluent" like uniform updates
  19364. */
  19365. setColor3(name: string, value: Color3): ShaderMaterial;
  19366. /**
  19367. * Set a vec3 array in the shader from a Color3 array.
  19368. * @param name Define the name of the uniform as defined in the shader
  19369. * @param value Define the value to give to the uniform
  19370. * @return the material itself allowing "fluent" like uniform updates
  19371. */
  19372. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19373. /**
  19374. * Set a vec4 in the shader from a Color4.
  19375. * @param name Define the name of the uniform as defined in the shader
  19376. * @param value Define the value to give to the uniform
  19377. * @return the material itself allowing "fluent" like uniform updates
  19378. */
  19379. setColor4(name: string, value: Color4): ShaderMaterial;
  19380. /**
  19381. * Set a vec4 array in the shader from a Color4 array.
  19382. * @param name Define the name of the uniform as defined in the shader
  19383. * @param value Define the value to give to the uniform
  19384. * @return the material itself allowing "fluent" like uniform updates
  19385. */
  19386. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19387. /**
  19388. * Set a vec2 in the shader from a Vector2.
  19389. * @param name Define the name of the uniform as defined in the shader
  19390. * @param value Define the value to give to the uniform
  19391. * @return the material itself allowing "fluent" like uniform updates
  19392. */
  19393. setVector2(name: string, value: Vector2): ShaderMaterial;
  19394. /**
  19395. * Set a vec3 in the shader from a Vector3.
  19396. * @param name Define the name of the uniform as defined in the shader
  19397. * @param value Define the value to give to the uniform
  19398. * @return the material itself allowing "fluent" like uniform updates
  19399. */
  19400. setVector3(name: string, value: Vector3): ShaderMaterial;
  19401. /**
  19402. * Set a vec4 in the shader from a Vector4.
  19403. * @param name Define the name of the uniform as defined in the shader
  19404. * @param value Define the value to give to the uniform
  19405. * @return the material itself allowing "fluent" like uniform updates
  19406. */
  19407. setVector4(name: string, value: Vector4): ShaderMaterial;
  19408. /**
  19409. * Set a mat4 in the shader from a Matrix.
  19410. * @param name Define the name of the uniform as defined in the shader
  19411. * @param value Define the value to give to the uniform
  19412. * @return the material itself allowing "fluent" like uniform updates
  19413. */
  19414. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19415. /**
  19416. * Set a float32Array in the shader from a matrix array.
  19417. * @param name Define the name of the uniform as defined in the shader
  19418. * @param value Define the value to give to the uniform
  19419. * @return the material itself allowing "fluent" like uniform updates
  19420. */
  19421. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19422. /**
  19423. * Set a mat3 in the shader from a Float32Array.
  19424. * @param name Define the name of the uniform as defined in the shader
  19425. * @param value Define the value to give to the uniform
  19426. * @return the material itself allowing "fluent" like uniform updates
  19427. */
  19428. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19429. /**
  19430. * Set a mat2 in the shader from a Float32Array.
  19431. * @param name Define the name of the uniform as defined in the shader
  19432. * @param value Define the value to give to the uniform
  19433. * @return the material itself allowing "fluent" like uniform updates
  19434. */
  19435. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19436. /**
  19437. * Set a vec2 array in the shader from a number array.
  19438. * @param name Define the name of the uniform as defined in the shader
  19439. * @param value Define the value to give to the uniform
  19440. * @return the material itself allowing "fluent" like uniform updates
  19441. */
  19442. setArray2(name: string, value: number[]): ShaderMaterial;
  19443. /**
  19444. * Set a vec3 array in the shader from a number array.
  19445. * @param name Define the name of the uniform as defined in the shader
  19446. * @param value Define the value to give to the uniform
  19447. * @return the material itself allowing "fluent" like uniform updates
  19448. */
  19449. setArray3(name: string, value: number[]): ShaderMaterial;
  19450. /**
  19451. * Set a vec4 array in the shader from a number array.
  19452. * @param name Define the name of the uniform as defined in the shader
  19453. * @param value Define the value to give to the uniform
  19454. * @return the material itself allowing "fluent" like uniform updates
  19455. */
  19456. setArray4(name: string, value: number[]): ShaderMaterial;
  19457. private _checkCache;
  19458. /**
  19459. * Specifies that the submesh is ready to be used
  19460. * @param mesh defines the mesh to check
  19461. * @param subMesh defines which submesh to check
  19462. * @param useInstances specifies that instances should be used
  19463. * @returns a boolean indicating that the submesh is ready or not
  19464. */
  19465. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19466. /**
  19467. * Checks if the material is ready to render the requested mesh
  19468. * @param mesh Define the mesh to render
  19469. * @param useInstances Define whether or not the material is used with instances
  19470. * @returns true if ready, otherwise false
  19471. */
  19472. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19473. /**
  19474. * Binds the world matrix to the material
  19475. * @param world defines the world transformation matrix
  19476. */
  19477. bindOnlyWorldMatrix(world: Matrix): void;
  19478. /**
  19479. * Binds the material to the mesh
  19480. * @param world defines the world transformation matrix
  19481. * @param mesh defines the mesh to bind the material to
  19482. */
  19483. bind(world: Matrix, mesh?: Mesh): void;
  19484. /**
  19485. * Gets the active textures from the material
  19486. * @returns an array of textures
  19487. */
  19488. getActiveTextures(): BaseTexture[];
  19489. /**
  19490. * Specifies if the material uses a texture
  19491. * @param texture defines the texture to check against the material
  19492. * @returns a boolean specifying if the material uses the texture
  19493. */
  19494. hasTexture(texture: BaseTexture): boolean;
  19495. /**
  19496. * Makes a duplicate of the material, and gives it a new name
  19497. * @param name defines the new name for the duplicated material
  19498. * @returns the cloned material
  19499. */
  19500. clone(name: string): ShaderMaterial;
  19501. /**
  19502. * Disposes the material
  19503. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19504. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19505. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19506. */
  19507. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19508. /**
  19509. * Serializes this material in a JSON representation
  19510. * @returns the serialized material object
  19511. */
  19512. serialize(): any;
  19513. /**
  19514. * Creates a shader material from parsed shader material data
  19515. * @param source defines the JSON represnetation of the material
  19516. * @param scene defines the hosting scene
  19517. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19518. * @returns a new material
  19519. */
  19520. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19521. }
  19522. }
  19523. declare module BABYLON {
  19524. /** @hidden */
  19525. export var colorPixelShader: {
  19526. name: string;
  19527. shader: string;
  19528. };
  19529. }
  19530. declare module BABYLON {
  19531. /** @hidden */
  19532. export var colorVertexShader: {
  19533. name: string;
  19534. shader: string;
  19535. };
  19536. }
  19537. declare module BABYLON {
  19538. /**
  19539. * Line mesh
  19540. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19541. */
  19542. export class LinesMesh extends Mesh {
  19543. /**
  19544. * If vertex color should be applied to the mesh
  19545. */
  19546. readonly useVertexColor?: boolean | undefined;
  19547. /**
  19548. * If vertex alpha should be applied to the mesh
  19549. */
  19550. readonly useVertexAlpha?: boolean | undefined;
  19551. /**
  19552. * Color of the line (Default: White)
  19553. */
  19554. color: Color3;
  19555. /**
  19556. * Alpha of the line (Default: 1)
  19557. */
  19558. alpha: number;
  19559. /**
  19560. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19561. * This margin is expressed in world space coordinates, so its value may vary.
  19562. * Default value is 0.1
  19563. */
  19564. intersectionThreshold: number;
  19565. private _colorShader;
  19566. private color4;
  19567. /**
  19568. * Creates a new LinesMesh
  19569. * @param name defines the name
  19570. * @param scene defines the hosting scene
  19571. * @param parent defines the parent mesh if any
  19572. * @param source defines the optional source LinesMesh used to clone data from
  19573. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19574. * When false, achieved by calling a clone(), also passing False.
  19575. * This will make creation of children, recursive.
  19576. * @param useVertexColor defines if this LinesMesh supports vertex color
  19577. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19578. */
  19579. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19580. /**
  19581. * If vertex color should be applied to the mesh
  19582. */
  19583. useVertexColor?: boolean | undefined,
  19584. /**
  19585. * If vertex alpha should be applied to the mesh
  19586. */
  19587. useVertexAlpha?: boolean | undefined);
  19588. private _addClipPlaneDefine;
  19589. private _removeClipPlaneDefine;
  19590. isReady(): boolean;
  19591. /**
  19592. * Returns the string "LineMesh"
  19593. */
  19594. getClassName(): string;
  19595. /**
  19596. * @hidden
  19597. */
  19598. /**
  19599. * @hidden
  19600. */
  19601. material: Material;
  19602. /**
  19603. * @hidden
  19604. */
  19605. readonly checkCollisions: boolean;
  19606. /** @hidden */
  19607. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19608. /** @hidden */
  19609. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19610. /**
  19611. * Disposes of the line mesh
  19612. * @param doNotRecurse If children should be disposed
  19613. */
  19614. dispose(doNotRecurse?: boolean): void;
  19615. /**
  19616. * Returns a new LineMesh object cloned from the current one.
  19617. */
  19618. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19619. /**
  19620. * Creates a new InstancedLinesMesh object from the mesh model.
  19621. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19622. * @param name defines the name of the new instance
  19623. * @returns a new InstancedLinesMesh
  19624. */
  19625. createInstance(name: string): InstancedLinesMesh;
  19626. }
  19627. /**
  19628. * Creates an instance based on a source LinesMesh
  19629. */
  19630. export class InstancedLinesMesh extends InstancedMesh {
  19631. /**
  19632. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19633. * This margin is expressed in world space coordinates, so its value may vary.
  19634. * Initilized with the intersectionThreshold value of the source LinesMesh
  19635. */
  19636. intersectionThreshold: number;
  19637. constructor(name: string, source: LinesMesh);
  19638. /**
  19639. * Returns the string "InstancedLinesMesh".
  19640. */
  19641. getClassName(): string;
  19642. }
  19643. }
  19644. declare module BABYLON {
  19645. /** @hidden */
  19646. export var linePixelShader: {
  19647. name: string;
  19648. shader: string;
  19649. };
  19650. }
  19651. declare module BABYLON {
  19652. /** @hidden */
  19653. export var lineVertexShader: {
  19654. name: string;
  19655. shader: string;
  19656. };
  19657. }
  19658. declare module BABYLON {
  19659. interface AbstractMesh {
  19660. /**
  19661. * Gets the edgesRenderer associated with the mesh
  19662. */
  19663. edgesRenderer: Nullable<EdgesRenderer>;
  19664. }
  19665. interface LinesMesh {
  19666. /**
  19667. * Enables the edge rendering mode on the mesh.
  19668. * This mode makes the mesh edges visible
  19669. * @param epsilon defines the maximal distance between two angles to detect a face
  19670. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19671. * @returns the currentAbstractMesh
  19672. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19673. */
  19674. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19675. }
  19676. interface InstancedLinesMesh {
  19677. /**
  19678. * Enables the edge rendering mode on the mesh.
  19679. * This mode makes the mesh edges visible
  19680. * @param epsilon defines the maximal distance between two angles to detect a face
  19681. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19682. * @returns the current InstancedLinesMesh
  19683. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19684. */
  19685. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19686. }
  19687. /**
  19688. * Defines the minimum contract an Edges renderer should follow.
  19689. */
  19690. export interface IEdgesRenderer extends IDisposable {
  19691. /**
  19692. * Gets or sets a boolean indicating if the edgesRenderer is active
  19693. */
  19694. isEnabled: boolean;
  19695. /**
  19696. * Renders the edges of the attached mesh,
  19697. */
  19698. render(): void;
  19699. /**
  19700. * Checks wether or not the edges renderer is ready to render.
  19701. * @return true if ready, otherwise false.
  19702. */
  19703. isReady(): boolean;
  19704. }
  19705. /**
  19706. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19707. */
  19708. export class EdgesRenderer implements IEdgesRenderer {
  19709. /**
  19710. * Define the size of the edges with an orthographic camera
  19711. */
  19712. edgesWidthScalerForOrthographic: number;
  19713. /**
  19714. * Define the size of the edges with a perspective camera
  19715. */
  19716. edgesWidthScalerForPerspective: number;
  19717. protected _source: AbstractMesh;
  19718. protected _linesPositions: number[];
  19719. protected _linesNormals: number[];
  19720. protected _linesIndices: number[];
  19721. protected _epsilon: number;
  19722. protected _indicesCount: number;
  19723. protected _lineShader: ShaderMaterial;
  19724. protected _ib: DataBuffer;
  19725. protected _buffers: {
  19726. [key: string]: Nullable<VertexBuffer>;
  19727. };
  19728. protected _checkVerticesInsteadOfIndices: boolean;
  19729. private _meshRebuildObserver;
  19730. private _meshDisposeObserver;
  19731. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19732. isEnabled: boolean;
  19733. /**
  19734. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19735. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19736. * @param source Mesh used to create edges
  19737. * @param epsilon sum of angles in adjacency to check for edge
  19738. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19739. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19740. */
  19741. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19742. protected _prepareRessources(): void;
  19743. /** @hidden */
  19744. _rebuild(): void;
  19745. /**
  19746. * Releases the required resources for the edges renderer
  19747. */
  19748. dispose(): void;
  19749. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19750. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19751. /**
  19752. * Checks if the pair of p0 and p1 is en edge
  19753. * @param faceIndex
  19754. * @param edge
  19755. * @param faceNormals
  19756. * @param p0
  19757. * @param p1
  19758. * @private
  19759. */
  19760. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19761. /**
  19762. * push line into the position, normal and index buffer
  19763. * @protected
  19764. */
  19765. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19766. /**
  19767. * Generates lines edges from adjacencjes
  19768. * @private
  19769. */
  19770. _generateEdgesLines(): void;
  19771. /**
  19772. * Checks wether or not the edges renderer is ready to render.
  19773. * @return true if ready, otherwise false.
  19774. */
  19775. isReady(): boolean;
  19776. /**
  19777. * Renders the edges of the attached mesh,
  19778. */
  19779. render(): void;
  19780. }
  19781. /**
  19782. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19783. */
  19784. export class LineEdgesRenderer extends EdgesRenderer {
  19785. /**
  19786. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19787. * @param source LineMesh used to generate edges
  19788. * @param epsilon not important (specified angle for edge detection)
  19789. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19790. */
  19791. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19792. /**
  19793. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19794. */
  19795. _generateEdgesLines(): void;
  19796. }
  19797. }
  19798. declare module BABYLON {
  19799. /**
  19800. * This represents the object necessary to create a rendering group.
  19801. * This is exclusively used and created by the rendering manager.
  19802. * To modify the behavior, you use the available helpers in your scene or meshes.
  19803. * @hidden
  19804. */
  19805. export class RenderingGroup {
  19806. index: number;
  19807. private static _zeroVector;
  19808. private _scene;
  19809. private _opaqueSubMeshes;
  19810. private _transparentSubMeshes;
  19811. private _alphaTestSubMeshes;
  19812. private _depthOnlySubMeshes;
  19813. private _particleSystems;
  19814. private _spriteManagers;
  19815. private _opaqueSortCompareFn;
  19816. private _alphaTestSortCompareFn;
  19817. private _transparentSortCompareFn;
  19818. private _renderOpaque;
  19819. private _renderAlphaTest;
  19820. private _renderTransparent;
  19821. /** @hidden */
  19822. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19823. onBeforeTransparentRendering: () => void;
  19824. /**
  19825. * Set the opaque sort comparison function.
  19826. * If null the sub meshes will be render in the order they were created
  19827. */
  19828. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19829. /**
  19830. * Set the alpha test sort comparison function.
  19831. * If null the sub meshes will be render in the order they were created
  19832. */
  19833. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19834. /**
  19835. * Set the transparent sort comparison function.
  19836. * If null the sub meshes will be render in the order they were created
  19837. */
  19838. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19839. /**
  19840. * Creates a new rendering group.
  19841. * @param index The rendering group index
  19842. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19843. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19844. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19845. */
  19846. 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>);
  19847. /**
  19848. * Render all the sub meshes contained in the group.
  19849. * @param customRenderFunction Used to override the default render behaviour of the group.
  19850. * @returns true if rendered some submeshes.
  19851. */
  19852. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19853. /**
  19854. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19855. * @param subMeshes The submeshes to render
  19856. */
  19857. private renderOpaqueSorted;
  19858. /**
  19859. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19860. * @param subMeshes The submeshes to render
  19861. */
  19862. private renderAlphaTestSorted;
  19863. /**
  19864. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19865. * @param subMeshes The submeshes to render
  19866. */
  19867. private renderTransparentSorted;
  19868. /**
  19869. * Renders the submeshes in a specified order.
  19870. * @param subMeshes The submeshes to sort before render
  19871. * @param sortCompareFn The comparison function use to sort
  19872. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19873. * @param transparent Specifies to activate blending if true
  19874. */
  19875. private static renderSorted;
  19876. /**
  19877. * Renders the submeshes in the order they were dispatched (no sort applied).
  19878. * @param subMeshes The submeshes to render
  19879. */
  19880. private static renderUnsorted;
  19881. /**
  19882. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19883. * are rendered back to front if in the same alpha index.
  19884. *
  19885. * @param a The first submesh
  19886. * @param b The second submesh
  19887. * @returns The result of the comparison
  19888. */
  19889. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19890. /**
  19891. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19892. * are rendered back to front.
  19893. *
  19894. * @param a The first submesh
  19895. * @param b The second submesh
  19896. * @returns The result of the comparison
  19897. */
  19898. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19899. /**
  19900. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19901. * are rendered front to back (prevent overdraw).
  19902. *
  19903. * @param a The first submesh
  19904. * @param b The second submesh
  19905. * @returns The result of the comparison
  19906. */
  19907. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19908. /**
  19909. * Resets the different lists of submeshes to prepare a new frame.
  19910. */
  19911. prepare(): void;
  19912. dispose(): void;
  19913. /**
  19914. * Inserts the submesh in its correct queue depending on its material.
  19915. * @param subMesh The submesh to dispatch
  19916. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19917. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19918. */
  19919. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19920. dispatchSprites(spriteManager: ISpriteManager): void;
  19921. dispatchParticles(particleSystem: IParticleSystem): void;
  19922. private _renderParticles;
  19923. private _renderSprites;
  19924. }
  19925. }
  19926. declare module BABYLON {
  19927. /**
  19928. * Interface describing the different options available in the rendering manager
  19929. * regarding Auto Clear between groups.
  19930. */
  19931. export interface IRenderingManagerAutoClearSetup {
  19932. /**
  19933. * Defines whether or not autoclear is enable.
  19934. */
  19935. autoClear: boolean;
  19936. /**
  19937. * Defines whether or not to autoclear the depth buffer.
  19938. */
  19939. depth: boolean;
  19940. /**
  19941. * Defines whether or not to autoclear the stencil buffer.
  19942. */
  19943. stencil: boolean;
  19944. }
  19945. /**
  19946. * This class is used by the onRenderingGroupObservable
  19947. */
  19948. export class RenderingGroupInfo {
  19949. /**
  19950. * The Scene that being rendered
  19951. */
  19952. scene: Scene;
  19953. /**
  19954. * The camera currently used for the rendering pass
  19955. */
  19956. camera: Nullable<Camera>;
  19957. /**
  19958. * The ID of the renderingGroup being processed
  19959. */
  19960. renderingGroupId: number;
  19961. }
  19962. /**
  19963. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19964. * It is enable to manage the different groups as well as the different necessary sort functions.
  19965. * This should not be used directly aside of the few static configurations
  19966. */
  19967. export class RenderingManager {
  19968. /**
  19969. * The max id used for rendering groups (not included)
  19970. */
  19971. static MAX_RENDERINGGROUPS: number;
  19972. /**
  19973. * The min id used for rendering groups (included)
  19974. */
  19975. static MIN_RENDERINGGROUPS: number;
  19976. /**
  19977. * Used to globally prevent autoclearing scenes.
  19978. */
  19979. static AUTOCLEAR: boolean;
  19980. /**
  19981. * @hidden
  19982. */
  19983. _useSceneAutoClearSetup: boolean;
  19984. private _scene;
  19985. private _renderingGroups;
  19986. private _depthStencilBufferAlreadyCleaned;
  19987. private _autoClearDepthStencil;
  19988. private _customOpaqueSortCompareFn;
  19989. private _customAlphaTestSortCompareFn;
  19990. private _customTransparentSortCompareFn;
  19991. private _renderingGroupInfo;
  19992. /**
  19993. * Instantiates a new rendering group for a particular scene
  19994. * @param scene Defines the scene the groups belongs to
  19995. */
  19996. constructor(scene: Scene);
  19997. private _clearDepthStencilBuffer;
  19998. /**
  19999. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20000. * @hidden
  20001. */
  20002. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20003. /**
  20004. * Resets the different information of the group to prepare a new frame
  20005. * @hidden
  20006. */
  20007. reset(): void;
  20008. /**
  20009. * Dispose and release the group and its associated resources.
  20010. * @hidden
  20011. */
  20012. dispose(): void;
  20013. /**
  20014. * Clear the info related to rendering groups preventing retention points during dispose.
  20015. */
  20016. freeRenderingGroups(): void;
  20017. private _prepareRenderingGroup;
  20018. /**
  20019. * Add a sprite manager to the rendering manager in order to render it this frame.
  20020. * @param spriteManager Define the sprite manager to render
  20021. */
  20022. dispatchSprites(spriteManager: ISpriteManager): void;
  20023. /**
  20024. * Add a particle system to the rendering manager in order to render it this frame.
  20025. * @param particleSystem Define the particle system to render
  20026. */
  20027. dispatchParticles(particleSystem: IParticleSystem): void;
  20028. /**
  20029. * Add a submesh to the manager in order to render it this frame
  20030. * @param subMesh The submesh to dispatch
  20031. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20032. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20033. */
  20034. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20035. /**
  20036. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20037. * This allowed control for front to back rendering or reversly depending of the special needs.
  20038. *
  20039. * @param renderingGroupId The rendering group id corresponding to its index
  20040. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20041. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20042. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20043. */
  20044. 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;
  20045. /**
  20046. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20047. *
  20048. * @param renderingGroupId The rendering group id corresponding to its index
  20049. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20050. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20051. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20052. */
  20053. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20054. /**
  20055. * Gets the current auto clear configuration for one rendering group of the rendering
  20056. * manager.
  20057. * @param index the rendering group index to get the information for
  20058. * @returns The auto clear setup for the requested rendering group
  20059. */
  20060. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20061. }
  20062. }
  20063. declare module BABYLON {
  20064. /**
  20065. * This Helps creating a texture that will be created from a camera in your scene.
  20066. * It is basically a dynamic texture that could be used to create special effects for instance.
  20067. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20068. */
  20069. export class RenderTargetTexture extends Texture {
  20070. isCube: boolean;
  20071. /**
  20072. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20073. */
  20074. static readonly REFRESHRATE_RENDER_ONCE: number;
  20075. /**
  20076. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20077. */
  20078. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20079. /**
  20080. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20081. * the central point of your effect and can save a lot of performances.
  20082. */
  20083. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20084. /**
  20085. * Use this predicate to dynamically define the list of mesh you want to render.
  20086. * If set, the renderList property will be overwritten.
  20087. */
  20088. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20089. private _renderList;
  20090. /**
  20091. * Use this list to define the list of mesh you want to render.
  20092. */
  20093. renderList: Nullable<Array<AbstractMesh>>;
  20094. private _hookArray;
  20095. /**
  20096. * Define if particles should be rendered in your texture.
  20097. */
  20098. renderParticles: boolean;
  20099. /**
  20100. * Define if sprites should be rendered in your texture.
  20101. */
  20102. renderSprites: boolean;
  20103. /**
  20104. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20105. */
  20106. coordinatesMode: number;
  20107. /**
  20108. * Define the camera used to render the texture.
  20109. */
  20110. activeCamera: Nullable<Camera>;
  20111. /**
  20112. * Override the render function of the texture with your own one.
  20113. */
  20114. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20115. /**
  20116. * Define if camera post processes should be use while rendering the texture.
  20117. */
  20118. useCameraPostProcesses: boolean;
  20119. /**
  20120. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20121. */
  20122. ignoreCameraViewport: boolean;
  20123. private _postProcessManager;
  20124. private _postProcesses;
  20125. private _resizeObserver;
  20126. /**
  20127. * An event triggered when the texture is unbind.
  20128. */
  20129. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20130. /**
  20131. * An event triggered when the texture is unbind.
  20132. */
  20133. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20134. private _onAfterUnbindObserver;
  20135. /**
  20136. * Set a after unbind callback in the texture.
  20137. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20138. */
  20139. onAfterUnbind: () => void;
  20140. /**
  20141. * An event triggered before rendering the texture
  20142. */
  20143. onBeforeRenderObservable: Observable<number>;
  20144. private _onBeforeRenderObserver;
  20145. /**
  20146. * Set a before render callback in the texture.
  20147. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20148. */
  20149. onBeforeRender: (faceIndex: number) => void;
  20150. /**
  20151. * An event triggered after rendering the texture
  20152. */
  20153. onAfterRenderObservable: Observable<number>;
  20154. private _onAfterRenderObserver;
  20155. /**
  20156. * Set a after render callback in the texture.
  20157. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20158. */
  20159. onAfterRender: (faceIndex: number) => void;
  20160. /**
  20161. * An event triggered after the texture clear
  20162. */
  20163. onClearObservable: Observable<Engine>;
  20164. private _onClearObserver;
  20165. /**
  20166. * Set a clear callback in the texture.
  20167. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20168. */
  20169. onClear: (Engine: Engine) => void;
  20170. /**
  20171. * An event triggered when the texture is resized.
  20172. */
  20173. onResizeObservable: Observable<RenderTargetTexture>;
  20174. /**
  20175. * Define the clear color of the Render Target if it should be different from the scene.
  20176. */
  20177. clearColor: Color4;
  20178. protected _size: number | {
  20179. width: number;
  20180. height: number;
  20181. };
  20182. protected _initialSizeParameter: number | {
  20183. width: number;
  20184. height: number;
  20185. } | {
  20186. ratio: number;
  20187. };
  20188. protected _sizeRatio: Nullable<number>;
  20189. /** @hidden */
  20190. _generateMipMaps: boolean;
  20191. protected _renderingManager: RenderingManager;
  20192. /** @hidden */
  20193. _waitingRenderList: string[];
  20194. protected _doNotChangeAspectRatio: boolean;
  20195. protected _currentRefreshId: number;
  20196. protected _refreshRate: number;
  20197. protected _textureMatrix: Matrix;
  20198. protected _samples: number;
  20199. protected _renderTargetOptions: RenderTargetCreationOptions;
  20200. /**
  20201. * Gets render target creation options that were used.
  20202. */
  20203. readonly renderTargetOptions: RenderTargetCreationOptions;
  20204. protected _engine: Engine;
  20205. protected _onRatioRescale(): void;
  20206. /**
  20207. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20208. * It must define where the camera used to render the texture is set
  20209. */
  20210. boundingBoxPosition: Vector3;
  20211. private _boundingBoxSize;
  20212. /**
  20213. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20214. * When defined, the cubemap will switch to local mode
  20215. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20216. * @example https://www.babylonjs-playground.com/#RNASML
  20217. */
  20218. boundingBoxSize: Vector3;
  20219. /**
  20220. * In case the RTT has been created with a depth texture, get the associated
  20221. * depth texture.
  20222. * Otherwise, return null.
  20223. */
  20224. depthStencilTexture: Nullable<InternalTexture>;
  20225. /**
  20226. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20227. * or used a shadow, depth texture...
  20228. * @param name The friendly name of the texture
  20229. * @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)
  20230. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20231. * @param generateMipMaps True if mip maps need to be generated after render.
  20232. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20233. * @param type The type of the buffer in the RTT (int, half float, float...)
  20234. * @param isCube True if a cube texture needs to be created
  20235. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20236. * @param generateDepthBuffer True to generate a depth buffer
  20237. * @param generateStencilBuffer True to generate a stencil buffer
  20238. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20239. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20240. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20241. */
  20242. constructor(name: string, size: number | {
  20243. width: number;
  20244. height: number;
  20245. } | {
  20246. ratio: number;
  20247. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20248. /**
  20249. * Creates a depth stencil texture.
  20250. * This is only available in WebGL 2 or with the depth texture extension available.
  20251. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20252. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20253. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20254. */
  20255. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20256. private _processSizeParameter;
  20257. /**
  20258. * Define the number of samples to use in case of MSAA.
  20259. * It defaults to one meaning no MSAA has been enabled.
  20260. */
  20261. samples: number;
  20262. /**
  20263. * Resets the refresh counter of the texture and start bak from scratch.
  20264. * Could be useful to regenerate the texture if it is setup to render only once.
  20265. */
  20266. resetRefreshCounter(): void;
  20267. /**
  20268. * Define the refresh rate of the texture or the rendering frequency.
  20269. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20270. */
  20271. refreshRate: number;
  20272. /**
  20273. * Adds a post process to the render target rendering passes.
  20274. * @param postProcess define the post process to add
  20275. */
  20276. addPostProcess(postProcess: PostProcess): void;
  20277. /**
  20278. * Clear all the post processes attached to the render target
  20279. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20280. */
  20281. clearPostProcesses(dispose?: boolean): void;
  20282. /**
  20283. * Remove one of the post process from the list of attached post processes to the texture
  20284. * @param postProcess define the post process to remove from the list
  20285. */
  20286. removePostProcess(postProcess: PostProcess): void;
  20287. /** @hidden */
  20288. _shouldRender(): boolean;
  20289. /**
  20290. * Gets the actual render size of the texture.
  20291. * @returns the width of the render size
  20292. */
  20293. getRenderSize(): number;
  20294. /**
  20295. * Gets the actual render width of the texture.
  20296. * @returns the width of the render size
  20297. */
  20298. getRenderWidth(): number;
  20299. /**
  20300. * Gets the actual render height of the texture.
  20301. * @returns the height of the render size
  20302. */
  20303. getRenderHeight(): number;
  20304. /**
  20305. * Get if the texture can be rescaled or not.
  20306. */
  20307. readonly canRescale: boolean;
  20308. /**
  20309. * Resize the texture using a ratio.
  20310. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20311. */
  20312. scale(ratio: number): void;
  20313. /**
  20314. * Get the texture reflection matrix used to rotate/transform the reflection.
  20315. * @returns the reflection matrix
  20316. */
  20317. getReflectionTextureMatrix(): Matrix;
  20318. /**
  20319. * Resize the texture to a new desired size.
  20320. * Be carrefull as it will recreate all the data in the new texture.
  20321. * @param size Define the new size. It can be:
  20322. * - a number for squared texture,
  20323. * - an object containing { width: number, height: number }
  20324. * - or an object containing a ratio { ratio: number }
  20325. */
  20326. resize(size: number | {
  20327. width: number;
  20328. height: number;
  20329. } | {
  20330. ratio: number;
  20331. }): void;
  20332. /**
  20333. * Renders all the objects from the render list into the texture.
  20334. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20335. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20336. */
  20337. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20338. private _bestReflectionRenderTargetDimension;
  20339. /**
  20340. * @hidden
  20341. * @param faceIndex face index to bind to if this is a cubetexture
  20342. */
  20343. _bindFrameBuffer(faceIndex?: number): void;
  20344. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20345. private renderToTarget;
  20346. /**
  20347. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20348. * This allowed control for front to back rendering or reversly depending of the special needs.
  20349. *
  20350. * @param renderingGroupId The rendering group id corresponding to its index
  20351. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20352. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20353. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20354. */
  20355. 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;
  20356. /**
  20357. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20358. *
  20359. * @param renderingGroupId The rendering group id corresponding to its index
  20360. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20361. */
  20362. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20363. /**
  20364. * Clones the texture.
  20365. * @returns the cloned texture
  20366. */
  20367. clone(): RenderTargetTexture;
  20368. /**
  20369. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20370. * @returns The JSON representation of the texture
  20371. */
  20372. serialize(): any;
  20373. /**
  20374. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20375. */
  20376. disposeFramebufferObjects(): void;
  20377. /**
  20378. * Dispose the texture and release its associated resources.
  20379. */
  20380. dispose(): void;
  20381. /** @hidden */
  20382. _rebuild(): void;
  20383. /**
  20384. * Clear the info related to rendering groups preventing retention point in material dispose.
  20385. */
  20386. freeRenderingGroups(): void;
  20387. /**
  20388. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20389. * @returns the view count
  20390. */
  20391. getViewCount(): number;
  20392. }
  20393. }
  20394. declare module BABYLON {
  20395. /**
  20396. * Options for compiling materials.
  20397. */
  20398. export interface IMaterialCompilationOptions {
  20399. /**
  20400. * Defines whether clip planes are enabled.
  20401. */
  20402. clipPlane: boolean;
  20403. /**
  20404. * Defines whether instances are enabled.
  20405. */
  20406. useInstances: boolean;
  20407. }
  20408. /**
  20409. * Base class for the main features of a material in Babylon.js
  20410. */
  20411. export class Material implements IAnimatable {
  20412. /**
  20413. * Returns the triangle fill mode
  20414. */
  20415. static readonly TriangleFillMode: number;
  20416. /**
  20417. * Returns the wireframe mode
  20418. */
  20419. static readonly WireFrameFillMode: number;
  20420. /**
  20421. * Returns the point fill mode
  20422. */
  20423. static readonly PointFillMode: number;
  20424. /**
  20425. * Returns the point list draw mode
  20426. */
  20427. static readonly PointListDrawMode: number;
  20428. /**
  20429. * Returns the line list draw mode
  20430. */
  20431. static readonly LineListDrawMode: number;
  20432. /**
  20433. * Returns the line loop draw mode
  20434. */
  20435. static readonly LineLoopDrawMode: number;
  20436. /**
  20437. * Returns the line strip draw mode
  20438. */
  20439. static readonly LineStripDrawMode: number;
  20440. /**
  20441. * Returns the triangle strip draw mode
  20442. */
  20443. static readonly TriangleStripDrawMode: number;
  20444. /**
  20445. * Returns the triangle fan draw mode
  20446. */
  20447. static readonly TriangleFanDrawMode: number;
  20448. /**
  20449. * Stores the clock-wise side orientation
  20450. */
  20451. static readonly ClockWiseSideOrientation: number;
  20452. /**
  20453. * Stores the counter clock-wise side orientation
  20454. */
  20455. static readonly CounterClockWiseSideOrientation: number;
  20456. /**
  20457. * The dirty texture flag value
  20458. */
  20459. static readonly TextureDirtyFlag: number;
  20460. /**
  20461. * The dirty light flag value
  20462. */
  20463. static readonly LightDirtyFlag: number;
  20464. /**
  20465. * The dirty fresnel flag value
  20466. */
  20467. static readonly FresnelDirtyFlag: number;
  20468. /**
  20469. * The dirty attribute flag value
  20470. */
  20471. static readonly AttributesDirtyFlag: number;
  20472. /**
  20473. * The dirty misc flag value
  20474. */
  20475. static readonly MiscDirtyFlag: number;
  20476. /**
  20477. * The all dirty flag value
  20478. */
  20479. static readonly AllDirtyFlag: number;
  20480. /**
  20481. * The ID of the material
  20482. */
  20483. id: string;
  20484. /**
  20485. * Gets or sets the unique id of the material
  20486. */
  20487. uniqueId: number;
  20488. /**
  20489. * The name of the material
  20490. */
  20491. name: string;
  20492. /**
  20493. * Gets or sets user defined metadata
  20494. */
  20495. metadata: any;
  20496. /**
  20497. * For internal use only. Please do not use.
  20498. */
  20499. reservedDataStore: any;
  20500. /**
  20501. * Specifies if the ready state should be checked on each call
  20502. */
  20503. checkReadyOnEveryCall: boolean;
  20504. /**
  20505. * Specifies if the ready state should be checked once
  20506. */
  20507. checkReadyOnlyOnce: boolean;
  20508. /**
  20509. * The state of the material
  20510. */
  20511. state: string;
  20512. /**
  20513. * The alpha value of the material
  20514. */
  20515. protected _alpha: number;
  20516. /**
  20517. * List of inspectable custom properties (used by the Inspector)
  20518. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20519. */
  20520. inspectableCustomProperties: IInspectable[];
  20521. /**
  20522. * Sets the alpha value of the material
  20523. */
  20524. /**
  20525. * Gets the alpha value of the material
  20526. */
  20527. alpha: number;
  20528. /**
  20529. * Specifies if back face culling is enabled
  20530. */
  20531. protected _backFaceCulling: boolean;
  20532. /**
  20533. * Sets the back-face culling state
  20534. */
  20535. /**
  20536. * Gets the back-face culling state
  20537. */
  20538. backFaceCulling: boolean;
  20539. /**
  20540. * Stores the value for side orientation
  20541. */
  20542. sideOrientation: number;
  20543. /**
  20544. * Callback triggered when the material is compiled
  20545. */
  20546. onCompiled: Nullable<(effect: Effect) => void>;
  20547. /**
  20548. * Callback triggered when an error occurs
  20549. */
  20550. onError: Nullable<(effect: Effect, errors: string) => void>;
  20551. /**
  20552. * Callback triggered to get the render target textures
  20553. */
  20554. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20555. /**
  20556. * Gets a boolean indicating that current material needs to register RTT
  20557. */
  20558. readonly hasRenderTargetTextures: boolean;
  20559. /**
  20560. * Specifies if the material should be serialized
  20561. */
  20562. doNotSerialize: boolean;
  20563. /**
  20564. * @hidden
  20565. */
  20566. _storeEffectOnSubMeshes: boolean;
  20567. /**
  20568. * Stores the animations for the material
  20569. */
  20570. animations: Nullable<Array<Animation>>;
  20571. /**
  20572. * An event triggered when the material is disposed
  20573. */
  20574. onDisposeObservable: Observable<Material>;
  20575. /**
  20576. * An observer which watches for dispose events
  20577. */
  20578. private _onDisposeObserver;
  20579. private _onUnBindObservable;
  20580. /**
  20581. * Called during a dispose event
  20582. */
  20583. onDispose: () => void;
  20584. private _onBindObservable;
  20585. /**
  20586. * An event triggered when the material is bound
  20587. */
  20588. readonly onBindObservable: Observable<AbstractMesh>;
  20589. /**
  20590. * An observer which watches for bind events
  20591. */
  20592. private _onBindObserver;
  20593. /**
  20594. * Called during a bind event
  20595. */
  20596. onBind: (Mesh: AbstractMesh) => void;
  20597. /**
  20598. * An event triggered when the material is unbound
  20599. */
  20600. readonly onUnBindObservable: Observable<Material>;
  20601. /**
  20602. * Stores the value of the alpha mode
  20603. */
  20604. private _alphaMode;
  20605. /**
  20606. * Sets the value of the alpha mode.
  20607. *
  20608. * | Value | Type | Description |
  20609. * | --- | --- | --- |
  20610. * | 0 | ALPHA_DISABLE | |
  20611. * | 1 | ALPHA_ADD | |
  20612. * | 2 | ALPHA_COMBINE | |
  20613. * | 3 | ALPHA_SUBTRACT | |
  20614. * | 4 | ALPHA_MULTIPLY | |
  20615. * | 5 | ALPHA_MAXIMIZED | |
  20616. * | 6 | ALPHA_ONEONE | |
  20617. * | 7 | ALPHA_PREMULTIPLIED | |
  20618. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20619. * | 9 | ALPHA_INTERPOLATE | |
  20620. * | 10 | ALPHA_SCREENMODE | |
  20621. *
  20622. */
  20623. /**
  20624. * Gets the value of the alpha mode
  20625. */
  20626. alphaMode: number;
  20627. /**
  20628. * Stores the state of the need depth pre-pass value
  20629. */
  20630. private _needDepthPrePass;
  20631. /**
  20632. * Sets the need depth pre-pass value
  20633. */
  20634. /**
  20635. * Gets the depth pre-pass value
  20636. */
  20637. needDepthPrePass: boolean;
  20638. /**
  20639. * Specifies if depth writing should be disabled
  20640. */
  20641. disableDepthWrite: boolean;
  20642. /**
  20643. * Specifies if depth writing should be forced
  20644. */
  20645. forceDepthWrite: boolean;
  20646. /**
  20647. * Specifies the depth function that should be used. 0 means the default engine function
  20648. */
  20649. depthFunction: number;
  20650. /**
  20651. * Specifies if there should be a separate pass for culling
  20652. */
  20653. separateCullingPass: boolean;
  20654. /**
  20655. * Stores the state specifing if fog should be enabled
  20656. */
  20657. private _fogEnabled;
  20658. /**
  20659. * Sets the state for enabling fog
  20660. */
  20661. /**
  20662. * Gets the value of the fog enabled state
  20663. */
  20664. fogEnabled: boolean;
  20665. /**
  20666. * Stores the size of points
  20667. */
  20668. pointSize: number;
  20669. /**
  20670. * Stores the z offset value
  20671. */
  20672. zOffset: number;
  20673. /**
  20674. * Gets a value specifying if wireframe mode is enabled
  20675. */
  20676. /**
  20677. * Sets the state of wireframe mode
  20678. */
  20679. wireframe: boolean;
  20680. /**
  20681. * Gets the value specifying if point clouds are enabled
  20682. */
  20683. /**
  20684. * Sets the state of point cloud mode
  20685. */
  20686. pointsCloud: boolean;
  20687. /**
  20688. * Gets the material fill mode
  20689. */
  20690. /**
  20691. * Sets the material fill mode
  20692. */
  20693. fillMode: number;
  20694. /**
  20695. * @hidden
  20696. * Stores the effects for the material
  20697. */
  20698. _effect: Nullable<Effect>;
  20699. /**
  20700. * @hidden
  20701. * Specifies if the material was previously ready
  20702. */
  20703. _wasPreviouslyReady: boolean;
  20704. /**
  20705. * Specifies if uniform buffers should be used
  20706. */
  20707. private _useUBO;
  20708. /**
  20709. * Stores a reference to the scene
  20710. */
  20711. private _scene;
  20712. /**
  20713. * Stores the fill mode state
  20714. */
  20715. private _fillMode;
  20716. /**
  20717. * Specifies if the depth write state should be cached
  20718. */
  20719. private _cachedDepthWriteState;
  20720. /**
  20721. * Specifies if the depth function state should be cached
  20722. */
  20723. private _cachedDepthFunctionState;
  20724. /**
  20725. * Stores the uniform buffer
  20726. */
  20727. protected _uniformBuffer: UniformBuffer;
  20728. /** @hidden */
  20729. _indexInSceneMaterialArray: number;
  20730. /** @hidden */
  20731. meshMap: Nullable<{
  20732. [id: string]: AbstractMesh | undefined;
  20733. }>;
  20734. /**
  20735. * Creates a material instance
  20736. * @param name defines the name of the material
  20737. * @param scene defines the scene to reference
  20738. * @param doNotAdd specifies if the material should be added to the scene
  20739. */
  20740. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20741. /**
  20742. * Returns a string representation of the current material
  20743. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20744. * @returns a string with material information
  20745. */
  20746. toString(fullDetails?: boolean): string;
  20747. /**
  20748. * Gets the class name of the material
  20749. * @returns a string with the class name of the material
  20750. */
  20751. getClassName(): string;
  20752. /**
  20753. * Specifies if updates for the material been locked
  20754. */
  20755. readonly isFrozen: boolean;
  20756. /**
  20757. * Locks updates for the material
  20758. */
  20759. freeze(): void;
  20760. /**
  20761. * Unlocks updates for the material
  20762. */
  20763. unfreeze(): void;
  20764. /**
  20765. * Specifies if the material is ready to be used
  20766. * @param mesh defines the mesh to check
  20767. * @param useInstances specifies if instances should be used
  20768. * @returns a boolean indicating if the material is ready to be used
  20769. */
  20770. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20771. /**
  20772. * Specifies that the submesh is ready to be used
  20773. * @param mesh defines the mesh to check
  20774. * @param subMesh defines which submesh to check
  20775. * @param useInstances specifies that instances should be used
  20776. * @returns a boolean indicating that the submesh is ready or not
  20777. */
  20778. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20779. /**
  20780. * Returns the material effect
  20781. * @returns the effect associated with the material
  20782. */
  20783. getEffect(): Nullable<Effect>;
  20784. /**
  20785. * Returns the current scene
  20786. * @returns a Scene
  20787. */
  20788. getScene(): Scene;
  20789. /**
  20790. * Specifies if the material will require alpha blending
  20791. * @returns a boolean specifying if alpha blending is needed
  20792. */
  20793. needAlphaBlending(): boolean;
  20794. /**
  20795. * Specifies if the mesh will require alpha blending
  20796. * @param mesh defines the mesh to check
  20797. * @returns a boolean specifying if alpha blending is needed for the mesh
  20798. */
  20799. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20800. /**
  20801. * Specifies if this material should be rendered in alpha test mode
  20802. * @returns a boolean specifying if an alpha test is needed.
  20803. */
  20804. needAlphaTesting(): boolean;
  20805. /**
  20806. * Gets the texture used for the alpha test
  20807. * @returns the texture to use for alpha testing
  20808. */
  20809. getAlphaTestTexture(): Nullable<BaseTexture>;
  20810. /**
  20811. * Marks the material to indicate that it needs to be re-calculated
  20812. */
  20813. markDirty(): void;
  20814. /** @hidden */
  20815. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20816. /**
  20817. * Binds the material to the mesh
  20818. * @param world defines the world transformation matrix
  20819. * @param mesh defines the mesh to bind the material to
  20820. */
  20821. bind(world: Matrix, mesh?: Mesh): void;
  20822. /**
  20823. * Binds the submesh to the material
  20824. * @param world defines the world transformation matrix
  20825. * @param mesh defines the mesh containing the submesh
  20826. * @param subMesh defines the submesh to bind the material to
  20827. */
  20828. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20829. /**
  20830. * Binds the world matrix to the material
  20831. * @param world defines the world transformation matrix
  20832. */
  20833. bindOnlyWorldMatrix(world: Matrix): void;
  20834. /**
  20835. * Binds the scene's uniform buffer to the effect.
  20836. * @param effect defines the effect to bind to the scene uniform buffer
  20837. * @param sceneUbo defines the uniform buffer storing scene data
  20838. */
  20839. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20840. /**
  20841. * Binds the view matrix to the effect
  20842. * @param effect defines the effect to bind the view matrix to
  20843. */
  20844. bindView(effect: Effect): void;
  20845. /**
  20846. * Binds the view projection matrix to the effect
  20847. * @param effect defines the effect to bind the view projection matrix to
  20848. */
  20849. bindViewProjection(effect: Effect): void;
  20850. /**
  20851. * Specifies if material alpha testing should be turned on for the mesh
  20852. * @param mesh defines the mesh to check
  20853. */
  20854. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20855. /**
  20856. * Processes to execute after binding the material to a mesh
  20857. * @param mesh defines the rendered mesh
  20858. */
  20859. protected _afterBind(mesh?: Mesh): void;
  20860. /**
  20861. * Unbinds the material from the mesh
  20862. */
  20863. unbind(): void;
  20864. /**
  20865. * Gets the active textures from the material
  20866. * @returns an array of textures
  20867. */
  20868. getActiveTextures(): BaseTexture[];
  20869. /**
  20870. * Specifies if the material uses a texture
  20871. * @param texture defines the texture to check against the material
  20872. * @returns a boolean specifying if the material uses the texture
  20873. */
  20874. hasTexture(texture: BaseTexture): boolean;
  20875. /**
  20876. * Makes a duplicate of the material, and gives it a new name
  20877. * @param name defines the new name for the duplicated material
  20878. * @returns the cloned material
  20879. */
  20880. clone(name: string): Nullable<Material>;
  20881. /**
  20882. * Gets the meshes bound to the material
  20883. * @returns an array of meshes bound to the material
  20884. */
  20885. getBindedMeshes(): AbstractMesh[];
  20886. /**
  20887. * Force shader compilation
  20888. * @param mesh defines the mesh associated with this material
  20889. * @param onCompiled defines a function to execute once the material is compiled
  20890. * @param options defines the options to configure the compilation
  20891. * @param onError defines a function to execute if the material fails compiling
  20892. */
  20893. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20894. /**
  20895. * Force shader compilation
  20896. * @param mesh defines the mesh that will use this material
  20897. * @param options defines additional options for compiling the shaders
  20898. * @returns a promise that resolves when the compilation completes
  20899. */
  20900. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20901. private static readonly _AllDirtyCallBack;
  20902. private static readonly _ImageProcessingDirtyCallBack;
  20903. private static readonly _TextureDirtyCallBack;
  20904. private static readonly _FresnelDirtyCallBack;
  20905. private static readonly _MiscDirtyCallBack;
  20906. private static readonly _LightsDirtyCallBack;
  20907. private static readonly _AttributeDirtyCallBack;
  20908. private static _FresnelAndMiscDirtyCallBack;
  20909. private static _TextureAndMiscDirtyCallBack;
  20910. private static readonly _DirtyCallbackArray;
  20911. private static readonly _RunDirtyCallBacks;
  20912. /**
  20913. * Marks a define in the material to indicate that it needs to be re-computed
  20914. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20915. */
  20916. markAsDirty(flag: number): void;
  20917. /**
  20918. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20919. * @param func defines a function which checks material defines against the submeshes
  20920. */
  20921. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20922. /**
  20923. * Indicates that we need to re-calculated for all submeshes
  20924. */
  20925. protected _markAllSubMeshesAsAllDirty(): void;
  20926. /**
  20927. * Indicates that image processing needs to be re-calculated for all submeshes
  20928. */
  20929. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20930. /**
  20931. * Indicates that textures need to be re-calculated for all submeshes
  20932. */
  20933. protected _markAllSubMeshesAsTexturesDirty(): void;
  20934. /**
  20935. * Indicates that fresnel needs to be re-calculated for all submeshes
  20936. */
  20937. protected _markAllSubMeshesAsFresnelDirty(): void;
  20938. /**
  20939. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20940. */
  20941. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20942. /**
  20943. * Indicates that lights need to be re-calculated for all submeshes
  20944. */
  20945. protected _markAllSubMeshesAsLightsDirty(): void;
  20946. /**
  20947. * Indicates that attributes need to be re-calculated for all submeshes
  20948. */
  20949. protected _markAllSubMeshesAsAttributesDirty(): void;
  20950. /**
  20951. * Indicates that misc needs to be re-calculated for all submeshes
  20952. */
  20953. protected _markAllSubMeshesAsMiscDirty(): void;
  20954. /**
  20955. * Indicates that textures and misc need to be re-calculated for all submeshes
  20956. */
  20957. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20958. /**
  20959. * Disposes the material
  20960. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20961. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20962. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20963. */
  20964. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20965. /** @hidden */
  20966. private releaseVertexArrayObject;
  20967. /**
  20968. * Serializes this material
  20969. * @returns the serialized material object
  20970. */
  20971. serialize(): any;
  20972. /**
  20973. * Creates a material from parsed material data
  20974. * @param parsedMaterial defines parsed material data
  20975. * @param scene defines the hosting scene
  20976. * @param rootUrl defines the root URL to use to load textures
  20977. * @returns a new material
  20978. */
  20979. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20980. }
  20981. }
  20982. declare module BABYLON {
  20983. /**
  20984. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20985. * separate meshes. This can be use to improve performances.
  20986. * @see http://doc.babylonjs.com/how_to/multi_materials
  20987. */
  20988. export class MultiMaterial extends Material {
  20989. private _subMaterials;
  20990. /**
  20991. * Gets or Sets the list of Materials used within the multi material.
  20992. * They need to be ordered according to the submeshes order in the associated mesh
  20993. */
  20994. subMaterials: Nullable<Material>[];
  20995. /**
  20996. * Function used to align with Node.getChildren()
  20997. * @returns the list of Materials used within the multi material
  20998. */
  20999. getChildren(): Nullable<Material>[];
  21000. /**
  21001. * Instantiates a new Multi Material
  21002. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21003. * separate meshes. This can be use to improve performances.
  21004. * @see http://doc.babylonjs.com/how_to/multi_materials
  21005. * @param name Define the name in the scene
  21006. * @param scene Define the scene the material belongs to
  21007. */
  21008. constructor(name: string, scene: Scene);
  21009. private _hookArray;
  21010. /**
  21011. * Get one of the submaterial by its index in the submaterials array
  21012. * @param index The index to look the sub material at
  21013. * @returns The Material if the index has been defined
  21014. */
  21015. getSubMaterial(index: number): Nullable<Material>;
  21016. /**
  21017. * Get the list of active textures for the whole sub materials list.
  21018. * @returns All the textures that will be used during the rendering
  21019. */
  21020. getActiveTextures(): BaseTexture[];
  21021. /**
  21022. * Gets the current class name of the material e.g. "MultiMaterial"
  21023. * Mainly use in serialization.
  21024. * @returns the class name
  21025. */
  21026. getClassName(): string;
  21027. /**
  21028. * Checks if the material is ready to render the requested sub mesh
  21029. * @param mesh Define the mesh the submesh belongs to
  21030. * @param subMesh Define the sub mesh to look readyness for
  21031. * @param useInstances Define whether or not the material is used with instances
  21032. * @returns true if ready, otherwise false
  21033. */
  21034. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21035. /**
  21036. * Clones the current material and its related sub materials
  21037. * @param name Define the name of the newly cloned material
  21038. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21039. * @returns the cloned material
  21040. */
  21041. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21042. /**
  21043. * Serializes the materials into a JSON representation.
  21044. * @returns the JSON representation
  21045. */
  21046. serialize(): any;
  21047. /**
  21048. * Dispose the material and release its associated resources
  21049. * @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)
  21050. * @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)
  21051. * @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)
  21052. */
  21053. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21054. /**
  21055. * Creates a MultiMaterial from parsed MultiMaterial data.
  21056. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21057. * @param scene defines the hosting scene
  21058. * @returns a new MultiMaterial
  21059. */
  21060. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21061. }
  21062. }
  21063. declare module BABYLON {
  21064. /**
  21065. * Base class for submeshes
  21066. */
  21067. export class BaseSubMesh {
  21068. /** @hidden */
  21069. _materialDefines: Nullable<MaterialDefines>;
  21070. /** @hidden */
  21071. _materialEffect: Nullable<Effect>;
  21072. /**
  21073. * Gets material defines used by the effect associated to the sub mesh
  21074. */
  21075. /**
  21076. * Sets material defines used by the effect associated to the sub mesh
  21077. */
  21078. materialDefines: Nullable<MaterialDefines>;
  21079. /**
  21080. * Gets associated effect
  21081. */
  21082. readonly effect: Nullable<Effect>;
  21083. /**
  21084. * Sets associated effect (effect used to render this submesh)
  21085. * @param effect defines the effect to associate with
  21086. * @param defines defines the set of defines used to compile this effect
  21087. */
  21088. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21089. }
  21090. /**
  21091. * Defines a subdivision inside a mesh
  21092. */
  21093. export class SubMesh extends BaseSubMesh implements ICullable {
  21094. /** the material index to use */
  21095. materialIndex: number;
  21096. /** vertex index start */
  21097. verticesStart: number;
  21098. /** vertices count */
  21099. verticesCount: number;
  21100. /** index start */
  21101. indexStart: number;
  21102. /** indices count */
  21103. indexCount: number;
  21104. /** @hidden */
  21105. _linesIndexCount: number;
  21106. private _mesh;
  21107. private _renderingMesh;
  21108. private _boundingInfo;
  21109. private _linesIndexBuffer;
  21110. /** @hidden */
  21111. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21112. /** @hidden */
  21113. _trianglePlanes: Plane[];
  21114. /** @hidden */
  21115. _lastColliderTransformMatrix: Nullable<Matrix>;
  21116. /** @hidden */
  21117. _renderId: number;
  21118. /** @hidden */
  21119. _alphaIndex: number;
  21120. /** @hidden */
  21121. _distanceToCamera: number;
  21122. /** @hidden */
  21123. _id: number;
  21124. private _currentMaterial;
  21125. /**
  21126. * Add a new submesh to a mesh
  21127. * @param materialIndex defines the material index to use
  21128. * @param verticesStart defines vertex index start
  21129. * @param verticesCount defines vertices count
  21130. * @param indexStart defines index start
  21131. * @param indexCount defines indices count
  21132. * @param mesh defines the parent mesh
  21133. * @param renderingMesh defines an optional rendering mesh
  21134. * @param createBoundingBox defines if bounding box should be created for this submesh
  21135. * @returns the new submesh
  21136. */
  21137. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21138. /**
  21139. * Creates a new submesh
  21140. * @param materialIndex defines the material index to use
  21141. * @param verticesStart defines vertex index start
  21142. * @param verticesCount defines vertices count
  21143. * @param indexStart defines index start
  21144. * @param indexCount defines indices count
  21145. * @param mesh defines the parent mesh
  21146. * @param renderingMesh defines an optional rendering mesh
  21147. * @param createBoundingBox defines if bounding box should be created for this submesh
  21148. */
  21149. constructor(
  21150. /** the material index to use */
  21151. materialIndex: number,
  21152. /** vertex index start */
  21153. verticesStart: number,
  21154. /** vertices count */
  21155. verticesCount: number,
  21156. /** index start */
  21157. indexStart: number,
  21158. /** indices count */
  21159. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21160. /**
  21161. * Returns true if this submesh covers the entire parent mesh
  21162. * @ignorenaming
  21163. */
  21164. readonly IsGlobal: boolean;
  21165. /**
  21166. * Returns the submesh BoudingInfo object
  21167. * @returns current bounding info (or mesh's one if the submesh is global)
  21168. */
  21169. getBoundingInfo(): BoundingInfo;
  21170. /**
  21171. * Sets the submesh BoundingInfo
  21172. * @param boundingInfo defines the new bounding info to use
  21173. * @returns the SubMesh
  21174. */
  21175. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21176. /**
  21177. * Returns the mesh of the current submesh
  21178. * @return the parent mesh
  21179. */
  21180. getMesh(): AbstractMesh;
  21181. /**
  21182. * Returns the rendering mesh of the submesh
  21183. * @returns the rendering mesh (could be different from parent mesh)
  21184. */
  21185. getRenderingMesh(): Mesh;
  21186. /**
  21187. * Returns the submesh material
  21188. * @returns null or the current material
  21189. */
  21190. getMaterial(): Nullable<Material>;
  21191. /**
  21192. * Sets a new updated BoundingInfo object to the submesh
  21193. * @param data defines an optional position array to use to determine the bounding info
  21194. * @returns the SubMesh
  21195. */
  21196. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21197. /** @hidden */
  21198. _checkCollision(collider: Collider): boolean;
  21199. /**
  21200. * Updates the submesh BoundingInfo
  21201. * @param world defines the world matrix to use to update the bounding info
  21202. * @returns the submesh
  21203. */
  21204. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21205. /**
  21206. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21207. * @param frustumPlanes defines the frustum planes
  21208. * @returns true if the submesh is intersecting with the frustum
  21209. */
  21210. isInFrustum(frustumPlanes: Plane[]): boolean;
  21211. /**
  21212. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21213. * @param frustumPlanes defines the frustum planes
  21214. * @returns true if the submesh is inside the frustum
  21215. */
  21216. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21217. /**
  21218. * Renders the submesh
  21219. * @param enableAlphaMode defines if alpha needs to be used
  21220. * @returns the submesh
  21221. */
  21222. render(enableAlphaMode: boolean): SubMesh;
  21223. /**
  21224. * @hidden
  21225. */
  21226. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21227. /**
  21228. * Checks if the submesh intersects with a ray
  21229. * @param ray defines the ray to test
  21230. * @returns true is the passed ray intersects the submesh bounding box
  21231. */
  21232. canIntersects(ray: Ray): boolean;
  21233. /**
  21234. * Intersects current submesh with a ray
  21235. * @param ray defines the ray to test
  21236. * @param positions defines mesh's positions array
  21237. * @param indices defines mesh's indices array
  21238. * @param fastCheck defines if only bounding info should be used
  21239. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21240. * @returns intersection info or null if no intersection
  21241. */
  21242. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21243. /** @hidden */
  21244. private _intersectLines;
  21245. /** @hidden */
  21246. private _intersectUnIndexedLines;
  21247. /** @hidden */
  21248. private _intersectTriangles;
  21249. /** @hidden */
  21250. private _intersectUnIndexedTriangles;
  21251. /** @hidden */
  21252. _rebuild(): void;
  21253. /**
  21254. * Creates a new submesh from the passed mesh
  21255. * @param newMesh defines the new hosting mesh
  21256. * @param newRenderingMesh defines an optional rendering mesh
  21257. * @returns the new submesh
  21258. */
  21259. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21260. /**
  21261. * Release associated resources
  21262. */
  21263. dispose(): void;
  21264. /**
  21265. * Gets the class name
  21266. * @returns the string "SubMesh".
  21267. */
  21268. getClassName(): string;
  21269. /**
  21270. * Creates a new submesh from indices data
  21271. * @param materialIndex the index of the main mesh material
  21272. * @param startIndex the index where to start the copy in the mesh indices array
  21273. * @param indexCount the number of indices to copy then from the startIndex
  21274. * @param mesh the main mesh to create the submesh from
  21275. * @param renderingMesh the optional rendering mesh
  21276. * @returns a new submesh
  21277. */
  21278. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21279. }
  21280. }
  21281. declare module BABYLON {
  21282. /**
  21283. * Class used to represent data loading progression
  21284. */
  21285. export class SceneLoaderFlags {
  21286. private static _ForceFullSceneLoadingForIncremental;
  21287. private static _ShowLoadingScreen;
  21288. private static _CleanBoneMatrixWeights;
  21289. private static _loggingLevel;
  21290. /**
  21291. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21292. */
  21293. static ForceFullSceneLoadingForIncremental: boolean;
  21294. /**
  21295. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21296. */
  21297. static ShowLoadingScreen: boolean;
  21298. /**
  21299. * Defines the current logging level (while loading the scene)
  21300. * @ignorenaming
  21301. */
  21302. static loggingLevel: number;
  21303. /**
  21304. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21305. */
  21306. static CleanBoneMatrixWeights: boolean;
  21307. }
  21308. }
  21309. declare module BABYLON {
  21310. /**
  21311. * Class used to store geometry data (vertex buffers + index buffer)
  21312. */
  21313. export class Geometry implements IGetSetVerticesData {
  21314. /**
  21315. * Gets or sets the ID of the geometry
  21316. */
  21317. id: string;
  21318. /**
  21319. * Gets or sets the unique ID of the geometry
  21320. */
  21321. uniqueId: number;
  21322. /**
  21323. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21324. */
  21325. delayLoadState: number;
  21326. /**
  21327. * Gets the file containing the data to load when running in delay load state
  21328. */
  21329. delayLoadingFile: Nullable<string>;
  21330. /**
  21331. * Callback called when the geometry is updated
  21332. */
  21333. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21334. private _scene;
  21335. private _engine;
  21336. private _meshes;
  21337. private _totalVertices;
  21338. /** @hidden */
  21339. _indices: IndicesArray;
  21340. /** @hidden */
  21341. _vertexBuffers: {
  21342. [key: string]: VertexBuffer;
  21343. };
  21344. private _isDisposed;
  21345. private _extend;
  21346. private _boundingBias;
  21347. /** @hidden */
  21348. _delayInfo: Array<string>;
  21349. private _indexBuffer;
  21350. private _indexBufferIsUpdatable;
  21351. /** @hidden */
  21352. _boundingInfo: Nullable<BoundingInfo>;
  21353. /** @hidden */
  21354. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21355. /** @hidden */
  21356. _softwareSkinningFrameId: number;
  21357. private _vertexArrayObjects;
  21358. private _updatable;
  21359. /** @hidden */
  21360. _positions: Nullable<Vector3[]>;
  21361. /**
  21362. * 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
  21363. */
  21364. /**
  21365. * 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
  21366. */
  21367. boundingBias: Vector2;
  21368. /**
  21369. * Static function used to attach a new empty geometry to a mesh
  21370. * @param mesh defines the mesh to attach the geometry to
  21371. * @returns the new Geometry
  21372. */
  21373. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21374. /**
  21375. * Creates a new geometry
  21376. * @param id defines the unique ID
  21377. * @param scene defines the hosting scene
  21378. * @param vertexData defines the VertexData used to get geometry data
  21379. * @param updatable defines if geometry must be updatable (false by default)
  21380. * @param mesh defines the mesh that will be associated with the geometry
  21381. */
  21382. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21383. /**
  21384. * Gets the current extend of the geometry
  21385. */
  21386. readonly extend: {
  21387. minimum: Vector3;
  21388. maximum: Vector3;
  21389. };
  21390. /**
  21391. * Gets the hosting scene
  21392. * @returns the hosting Scene
  21393. */
  21394. getScene(): Scene;
  21395. /**
  21396. * Gets the hosting engine
  21397. * @returns the hosting Engine
  21398. */
  21399. getEngine(): Engine;
  21400. /**
  21401. * Defines if the geometry is ready to use
  21402. * @returns true if the geometry is ready to be used
  21403. */
  21404. isReady(): boolean;
  21405. /**
  21406. * Gets a value indicating that the geometry should not be serialized
  21407. */
  21408. readonly doNotSerialize: boolean;
  21409. /** @hidden */
  21410. _rebuild(): void;
  21411. /**
  21412. * Affects all geometry data in one call
  21413. * @param vertexData defines the geometry data
  21414. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21415. */
  21416. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21417. /**
  21418. * Set specific vertex data
  21419. * @param kind defines the data kind (Position, normal, etc...)
  21420. * @param data defines the vertex data to use
  21421. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21422. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21423. */
  21424. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21425. /**
  21426. * Removes a specific vertex data
  21427. * @param kind defines the data kind (Position, normal, etc...)
  21428. */
  21429. removeVerticesData(kind: string): void;
  21430. /**
  21431. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21432. * @param buffer defines the vertex buffer to use
  21433. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21434. */
  21435. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21436. /**
  21437. * Update a specific vertex buffer
  21438. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21439. * It will do nothing if the buffer is not updatable
  21440. * @param kind defines the data kind (Position, normal, etc...)
  21441. * @param data defines the data to use
  21442. * @param offset defines the offset in the target buffer where to store the data
  21443. * @param useBytes set to true if the offset is in bytes
  21444. */
  21445. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21446. /**
  21447. * Update a specific vertex buffer
  21448. * This function will create a new buffer if the current one is not updatable
  21449. * @param kind defines the data kind (Position, normal, etc...)
  21450. * @param data defines the data to use
  21451. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21452. */
  21453. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21454. private _updateBoundingInfo;
  21455. /** @hidden */
  21456. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21457. /**
  21458. * Gets total number of vertices
  21459. * @returns the total number of vertices
  21460. */
  21461. getTotalVertices(): number;
  21462. /**
  21463. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21464. * @param kind defines the data kind (Position, normal, etc...)
  21465. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21466. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21467. * @returns a float array containing vertex data
  21468. */
  21469. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21470. /**
  21471. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21472. * @param kind defines the data kind (Position, normal, etc...)
  21473. * @returns true if the vertex buffer with the specified kind is updatable
  21474. */
  21475. isVertexBufferUpdatable(kind: string): boolean;
  21476. /**
  21477. * Gets a specific vertex buffer
  21478. * @param kind defines the data kind (Position, normal, etc...)
  21479. * @returns a VertexBuffer
  21480. */
  21481. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21482. /**
  21483. * Returns all vertex buffers
  21484. * @return an object holding all vertex buffers indexed by kind
  21485. */
  21486. getVertexBuffers(): Nullable<{
  21487. [key: string]: VertexBuffer;
  21488. }>;
  21489. /**
  21490. * Gets a boolean indicating if specific vertex buffer is present
  21491. * @param kind defines the data kind (Position, normal, etc...)
  21492. * @returns true if data is present
  21493. */
  21494. isVerticesDataPresent(kind: string): boolean;
  21495. /**
  21496. * Gets a list of all attached data kinds (Position, normal, etc...)
  21497. * @returns a list of string containing all kinds
  21498. */
  21499. getVerticesDataKinds(): string[];
  21500. /**
  21501. * Update index buffer
  21502. * @param indices defines the indices to store in the index buffer
  21503. * @param offset defines the offset in the target buffer where to store the data
  21504. * @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)
  21505. */
  21506. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21507. /**
  21508. * Creates a new index buffer
  21509. * @param indices defines the indices to store in the index buffer
  21510. * @param totalVertices defines the total number of vertices (could be null)
  21511. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21512. */
  21513. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21514. /**
  21515. * Return the total number of indices
  21516. * @returns the total number of indices
  21517. */
  21518. getTotalIndices(): number;
  21519. /**
  21520. * Gets the index buffer array
  21521. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21522. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21523. * @returns the index buffer array
  21524. */
  21525. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21526. /**
  21527. * Gets the index buffer
  21528. * @return the index buffer
  21529. */
  21530. getIndexBuffer(): Nullable<DataBuffer>;
  21531. /** @hidden */
  21532. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21533. /**
  21534. * Release the associated resources for a specific mesh
  21535. * @param mesh defines the source mesh
  21536. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21537. */
  21538. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21539. /**
  21540. * Apply current geometry to a given mesh
  21541. * @param mesh defines the mesh to apply geometry to
  21542. */
  21543. applyToMesh(mesh: Mesh): void;
  21544. private _updateExtend;
  21545. private _applyToMesh;
  21546. private notifyUpdate;
  21547. /**
  21548. * Load the geometry if it was flagged as delay loaded
  21549. * @param scene defines the hosting scene
  21550. * @param onLoaded defines a callback called when the geometry is loaded
  21551. */
  21552. load(scene: Scene, onLoaded?: () => void): void;
  21553. private _queueLoad;
  21554. /**
  21555. * Invert the geometry to move from a right handed system to a left handed one.
  21556. */
  21557. toLeftHanded(): void;
  21558. /** @hidden */
  21559. _resetPointsArrayCache(): void;
  21560. /** @hidden */
  21561. _generatePointsArray(): boolean;
  21562. /**
  21563. * Gets a value indicating if the geometry is disposed
  21564. * @returns true if the geometry was disposed
  21565. */
  21566. isDisposed(): boolean;
  21567. private _disposeVertexArrayObjects;
  21568. /**
  21569. * Free all associated resources
  21570. */
  21571. dispose(): void;
  21572. /**
  21573. * Clone the current geometry into a new geometry
  21574. * @param id defines the unique ID of the new geometry
  21575. * @returns a new geometry object
  21576. */
  21577. copy(id: string): Geometry;
  21578. /**
  21579. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21580. * @return a JSON representation of the current geometry data (without the vertices data)
  21581. */
  21582. serialize(): any;
  21583. private toNumberArray;
  21584. /**
  21585. * Serialize all vertices data into a JSON oject
  21586. * @returns a JSON representation of the current geometry data
  21587. */
  21588. serializeVerticeData(): any;
  21589. /**
  21590. * Extracts a clone of a mesh geometry
  21591. * @param mesh defines the source mesh
  21592. * @param id defines the unique ID of the new geometry object
  21593. * @returns the new geometry object
  21594. */
  21595. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21596. /**
  21597. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21598. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21599. * Be aware Math.random() could cause collisions, but:
  21600. * "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"
  21601. * @returns a string containing a new GUID
  21602. */
  21603. static RandomId(): string;
  21604. /** @hidden */
  21605. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21606. private static _CleanMatricesWeights;
  21607. /**
  21608. * Create a new geometry from persisted data (Using .babylon file format)
  21609. * @param parsedVertexData defines the persisted data
  21610. * @param scene defines the hosting scene
  21611. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21612. * @returns the new geometry object
  21613. */
  21614. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21615. }
  21616. }
  21617. declare module BABYLON {
  21618. /**
  21619. * Define an interface for all classes that will get and set the data on vertices
  21620. */
  21621. export interface IGetSetVerticesData {
  21622. /**
  21623. * Gets a boolean indicating if specific vertex data is present
  21624. * @param kind defines the vertex data kind to use
  21625. * @returns true is data kind is present
  21626. */
  21627. isVerticesDataPresent(kind: string): boolean;
  21628. /**
  21629. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21630. * @param kind defines the data kind (Position, normal, etc...)
  21631. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21632. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21633. * @returns a float array containing vertex data
  21634. */
  21635. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21636. /**
  21637. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21638. * @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.
  21639. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21640. * @returns the indices array or an empty array if the mesh has no geometry
  21641. */
  21642. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21643. /**
  21644. * Set specific vertex data
  21645. * @param kind defines the data kind (Position, normal, etc...)
  21646. * @param data defines the vertex data to use
  21647. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21648. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21649. */
  21650. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21651. /**
  21652. * Update a specific associated vertex buffer
  21653. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21654. * - VertexBuffer.PositionKind
  21655. * - VertexBuffer.UVKind
  21656. * - VertexBuffer.UV2Kind
  21657. * - VertexBuffer.UV3Kind
  21658. * - VertexBuffer.UV4Kind
  21659. * - VertexBuffer.UV5Kind
  21660. * - VertexBuffer.UV6Kind
  21661. * - VertexBuffer.ColorKind
  21662. * - VertexBuffer.MatricesIndicesKind
  21663. * - VertexBuffer.MatricesIndicesExtraKind
  21664. * - VertexBuffer.MatricesWeightsKind
  21665. * - VertexBuffer.MatricesWeightsExtraKind
  21666. * @param data defines the data source
  21667. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21668. * @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)
  21669. */
  21670. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21671. /**
  21672. * Creates a new index buffer
  21673. * @param indices defines the indices to store in the index buffer
  21674. * @param totalVertices defines the total number of vertices (could be null)
  21675. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21676. */
  21677. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21678. }
  21679. /**
  21680. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21681. */
  21682. export class VertexData {
  21683. /**
  21684. * Mesh side orientation : usually the external or front surface
  21685. */
  21686. static readonly FRONTSIDE: number;
  21687. /**
  21688. * Mesh side orientation : usually the internal or back surface
  21689. */
  21690. static readonly BACKSIDE: number;
  21691. /**
  21692. * Mesh side orientation : both internal and external or front and back surfaces
  21693. */
  21694. static readonly DOUBLESIDE: number;
  21695. /**
  21696. * Mesh side orientation : by default, `FRONTSIDE`
  21697. */
  21698. static readonly DEFAULTSIDE: number;
  21699. /**
  21700. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21701. */
  21702. positions: Nullable<FloatArray>;
  21703. /**
  21704. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21705. */
  21706. normals: Nullable<FloatArray>;
  21707. /**
  21708. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21709. */
  21710. tangents: Nullable<FloatArray>;
  21711. /**
  21712. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21713. */
  21714. uvs: Nullable<FloatArray>;
  21715. /**
  21716. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21717. */
  21718. uvs2: Nullable<FloatArray>;
  21719. /**
  21720. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21721. */
  21722. uvs3: Nullable<FloatArray>;
  21723. /**
  21724. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21725. */
  21726. uvs4: Nullable<FloatArray>;
  21727. /**
  21728. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21729. */
  21730. uvs5: Nullable<FloatArray>;
  21731. /**
  21732. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21733. */
  21734. uvs6: Nullable<FloatArray>;
  21735. /**
  21736. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21737. */
  21738. colors: Nullable<FloatArray>;
  21739. /**
  21740. * 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).
  21741. */
  21742. matricesIndices: Nullable<FloatArray>;
  21743. /**
  21744. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21745. */
  21746. matricesWeights: Nullable<FloatArray>;
  21747. /**
  21748. * An array extending the number of possible indices
  21749. */
  21750. matricesIndicesExtra: Nullable<FloatArray>;
  21751. /**
  21752. * An array extending the number of possible weights when the number of indices is extended
  21753. */
  21754. matricesWeightsExtra: Nullable<FloatArray>;
  21755. /**
  21756. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21757. */
  21758. indices: Nullable<IndicesArray>;
  21759. /**
  21760. * Uses the passed data array to set the set the values for the specified kind of data
  21761. * @param data a linear array of floating numbers
  21762. * @param kind the type of data that is being set, eg positions, colors etc
  21763. */
  21764. set(data: FloatArray, kind: string): void;
  21765. /**
  21766. * Associates the vertexData to the passed Mesh.
  21767. * Sets it as updatable or not (default `false`)
  21768. * @param mesh the mesh the vertexData is applied to
  21769. * @param updatable when used and having the value true allows new data to update the vertexData
  21770. * @returns the VertexData
  21771. */
  21772. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21773. /**
  21774. * Associates the vertexData to the passed Geometry.
  21775. * Sets it as updatable or not (default `false`)
  21776. * @param geometry the geometry the vertexData is applied to
  21777. * @param updatable when used and having the value true allows new data to update the vertexData
  21778. * @returns VertexData
  21779. */
  21780. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21781. /**
  21782. * Updates the associated mesh
  21783. * @param mesh the mesh to be updated
  21784. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21785. * @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
  21786. * @returns VertexData
  21787. */
  21788. updateMesh(mesh: Mesh): VertexData;
  21789. /**
  21790. * Updates the associated geometry
  21791. * @param geometry the geometry to be updated
  21792. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21793. * @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
  21794. * @returns VertexData.
  21795. */
  21796. updateGeometry(geometry: Geometry): VertexData;
  21797. private _applyTo;
  21798. private _update;
  21799. /**
  21800. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21801. * @param matrix the transforming matrix
  21802. * @returns the VertexData
  21803. */
  21804. transform(matrix: Matrix): VertexData;
  21805. /**
  21806. * Merges the passed VertexData into the current one
  21807. * @param other the VertexData to be merged into the current one
  21808. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21809. * @returns the modified VertexData
  21810. */
  21811. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21812. private _mergeElement;
  21813. private _validate;
  21814. /**
  21815. * Serializes the VertexData
  21816. * @returns a serialized object
  21817. */
  21818. serialize(): any;
  21819. /**
  21820. * Extracts the vertexData from a mesh
  21821. * @param mesh the mesh from which to extract the VertexData
  21822. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21823. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21824. * @returns the object VertexData associated to the passed mesh
  21825. */
  21826. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21827. /**
  21828. * Extracts the vertexData from the geometry
  21829. * @param geometry the geometry from which to extract the VertexData
  21830. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21831. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21832. * @returns the object VertexData associated to the passed mesh
  21833. */
  21834. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21835. private static _ExtractFrom;
  21836. /**
  21837. * Creates the VertexData for a Ribbon
  21838. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21839. * * pathArray array of paths, each of which an array of successive Vector3
  21840. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21841. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21842. * * 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
  21843. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21844. * * 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)
  21845. * * 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)
  21846. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21847. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21848. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21849. * @returns the VertexData of the ribbon
  21850. */
  21851. static CreateRibbon(options: {
  21852. pathArray: Vector3[][];
  21853. closeArray?: boolean;
  21854. closePath?: boolean;
  21855. offset?: number;
  21856. sideOrientation?: number;
  21857. frontUVs?: Vector4;
  21858. backUVs?: Vector4;
  21859. invertUV?: boolean;
  21860. uvs?: Vector2[];
  21861. colors?: Color4[];
  21862. }): VertexData;
  21863. /**
  21864. * Creates the VertexData for a box
  21865. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21866. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21867. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21868. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21869. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21870. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21871. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21873. * * 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)
  21874. * * 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)
  21875. * @returns the VertexData of the box
  21876. */
  21877. static CreateBox(options: {
  21878. size?: number;
  21879. width?: number;
  21880. height?: number;
  21881. depth?: number;
  21882. faceUV?: Vector4[];
  21883. faceColors?: Color4[];
  21884. sideOrientation?: number;
  21885. frontUVs?: Vector4;
  21886. backUVs?: Vector4;
  21887. }): VertexData;
  21888. /**
  21889. * Creates the VertexData for a tiled box
  21890. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21891. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21892. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21893. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21894. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21895. * @returns the VertexData of the box
  21896. */
  21897. static CreateTiledBox(options: {
  21898. pattern?: number;
  21899. width?: number;
  21900. height?: number;
  21901. depth?: number;
  21902. tileSize?: number;
  21903. tileWidth?: number;
  21904. tileHeight?: number;
  21905. alignHorizontal?: number;
  21906. alignVertical?: number;
  21907. faceUV?: Vector4[];
  21908. faceColors?: Color4[];
  21909. sideOrientation?: number;
  21910. }): VertexData;
  21911. /**
  21912. * Creates the VertexData for a tiled plane
  21913. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21914. * * pattern a limited pattern arrangement depending on the number
  21915. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21916. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21917. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21918. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21919. * * 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)
  21920. * * 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)
  21921. * @returns the VertexData of the tiled plane
  21922. */
  21923. static CreateTiledPlane(options: {
  21924. pattern?: number;
  21925. tileSize?: number;
  21926. tileWidth?: number;
  21927. tileHeight?: number;
  21928. size?: number;
  21929. width?: number;
  21930. height?: number;
  21931. alignHorizontal?: number;
  21932. alignVertical?: number;
  21933. sideOrientation?: number;
  21934. frontUVs?: Vector4;
  21935. backUVs?: Vector4;
  21936. }): VertexData;
  21937. /**
  21938. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21939. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21940. * * segments sets the number of horizontal strips optional, default 32
  21941. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21942. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21943. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21944. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21945. * * 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
  21946. * * 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
  21947. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21948. * * 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)
  21949. * * 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)
  21950. * @returns the VertexData of the ellipsoid
  21951. */
  21952. static CreateSphere(options: {
  21953. segments?: number;
  21954. diameter?: number;
  21955. diameterX?: number;
  21956. diameterY?: number;
  21957. diameterZ?: number;
  21958. arc?: number;
  21959. slice?: number;
  21960. sideOrientation?: number;
  21961. frontUVs?: Vector4;
  21962. backUVs?: Vector4;
  21963. }): VertexData;
  21964. /**
  21965. * Creates the VertexData for a cylinder, cone or prism
  21966. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21967. * * height sets the height (y direction) of the cylinder, optional, default 2
  21968. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21969. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21970. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21971. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21972. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21973. * * 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
  21974. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21975. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21976. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21977. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21978. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21979. * * 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)
  21980. * * 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)
  21981. * @returns the VertexData of the cylinder, cone or prism
  21982. */
  21983. static CreateCylinder(options: {
  21984. height?: number;
  21985. diameterTop?: number;
  21986. diameterBottom?: number;
  21987. diameter?: number;
  21988. tessellation?: number;
  21989. subdivisions?: number;
  21990. arc?: number;
  21991. faceColors?: Color4[];
  21992. faceUV?: Vector4[];
  21993. hasRings?: boolean;
  21994. enclose?: boolean;
  21995. sideOrientation?: number;
  21996. frontUVs?: Vector4;
  21997. backUVs?: Vector4;
  21998. }): VertexData;
  21999. /**
  22000. * Creates the VertexData for a torus
  22001. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22002. * * diameter the diameter of the torus, optional default 1
  22003. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22004. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22005. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22006. * * 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)
  22007. * * 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)
  22008. * @returns the VertexData of the torus
  22009. */
  22010. static CreateTorus(options: {
  22011. diameter?: number;
  22012. thickness?: number;
  22013. tessellation?: number;
  22014. sideOrientation?: number;
  22015. frontUVs?: Vector4;
  22016. backUVs?: Vector4;
  22017. }): VertexData;
  22018. /**
  22019. * Creates the VertexData of the LineSystem
  22020. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22021. * - lines an array of lines, each line being an array of successive Vector3
  22022. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22023. * @returns the VertexData of the LineSystem
  22024. */
  22025. static CreateLineSystem(options: {
  22026. lines: Vector3[][];
  22027. colors?: Nullable<Color4[][]>;
  22028. }): VertexData;
  22029. /**
  22030. * Create the VertexData for a DashedLines
  22031. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22032. * - points an array successive Vector3
  22033. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22034. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22035. * - dashNb the intended total number of dashes, optional, default 200
  22036. * @returns the VertexData for the DashedLines
  22037. */
  22038. static CreateDashedLines(options: {
  22039. points: Vector3[];
  22040. dashSize?: number;
  22041. gapSize?: number;
  22042. dashNb?: number;
  22043. }): VertexData;
  22044. /**
  22045. * Creates the VertexData for a Ground
  22046. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22047. * - width the width (x direction) of the ground, optional, default 1
  22048. * - height the height (z direction) of the ground, optional, default 1
  22049. * - subdivisions the number of subdivisions per side, optional, default 1
  22050. * @returns the VertexData of the Ground
  22051. */
  22052. static CreateGround(options: {
  22053. width?: number;
  22054. height?: number;
  22055. subdivisions?: number;
  22056. subdivisionsX?: number;
  22057. subdivisionsY?: number;
  22058. }): VertexData;
  22059. /**
  22060. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22061. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22062. * * xmin the ground minimum X coordinate, optional, default -1
  22063. * * zmin the ground minimum Z coordinate, optional, default -1
  22064. * * xmax the ground maximum X coordinate, optional, default 1
  22065. * * zmax the ground maximum Z coordinate, optional, default 1
  22066. * * 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}
  22067. * * 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}
  22068. * @returns the VertexData of the TiledGround
  22069. */
  22070. static CreateTiledGround(options: {
  22071. xmin: number;
  22072. zmin: number;
  22073. xmax: number;
  22074. zmax: number;
  22075. subdivisions?: {
  22076. w: number;
  22077. h: number;
  22078. };
  22079. precision?: {
  22080. w: number;
  22081. h: number;
  22082. };
  22083. }): VertexData;
  22084. /**
  22085. * Creates the VertexData of the Ground designed from a heightmap
  22086. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22087. * * width the width (x direction) of the ground
  22088. * * height the height (z direction) of the ground
  22089. * * subdivisions the number of subdivisions per side
  22090. * * minHeight the minimum altitude on the ground, optional, default 0
  22091. * * maxHeight the maximum altitude on the ground, optional default 1
  22092. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22093. * * buffer the array holding the image color data
  22094. * * bufferWidth the width of image
  22095. * * bufferHeight the height of image
  22096. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22097. * @returns the VertexData of the Ground designed from a heightmap
  22098. */
  22099. static CreateGroundFromHeightMap(options: {
  22100. width: number;
  22101. height: number;
  22102. subdivisions: number;
  22103. minHeight: number;
  22104. maxHeight: number;
  22105. colorFilter: Color3;
  22106. buffer: Uint8Array;
  22107. bufferWidth: number;
  22108. bufferHeight: number;
  22109. alphaFilter: number;
  22110. }): VertexData;
  22111. /**
  22112. * Creates the VertexData for a Plane
  22113. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22114. * * size sets the width and height of the plane to the value of size, optional default 1
  22115. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22116. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22118. * * 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)
  22119. * * 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)
  22120. * @returns the VertexData of the box
  22121. */
  22122. static CreatePlane(options: {
  22123. size?: number;
  22124. width?: number;
  22125. height?: number;
  22126. sideOrientation?: number;
  22127. frontUVs?: Vector4;
  22128. backUVs?: Vector4;
  22129. }): VertexData;
  22130. /**
  22131. * Creates the VertexData of the Disc or regular Polygon
  22132. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22133. * * radius the radius of the disc, optional default 0.5
  22134. * * tessellation the number of polygon sides, optional, default 64
  22135. * * 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
  22136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22137. * * 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)
  22138. * * 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)
  22139. * @returns the VertexData of the box
  22140. */
  22141. static CreateDisc(options: {
  22142. radius?: number;
  22143. tessellation?: number;
  22144. arc?: number;
  22145. sideOrientation?: number;
  22146. frontUVs?: Vector4;
  22147. backUVs?: Vector4;
  22148. }): VertexData;
  22149. /**
  22150. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22151. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22152. * @param polygon a mesh built from polygonTriangulation.build()
  22153. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22154. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22155. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22156. * @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)
  22157. * @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)
  22158. * @returns the VertexData of the Polygon
  22159. */
  22160. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22161. /**
  22162. * Creates the VertexData of the IcoSphere
  22163. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22164. * * radius the radius of the IcoSphere, optional default 1
  22165. * * radiusX allows stretching in the x direction, optional, default radius
  22166. * * radiusY allows stretching in the y direction, optional, default radius
  22167. * * radiusZ allows stretching in the z direction, optional, default radius
  22168. * * flat when true creates a flat shaded mesh, optional, default true
  22169. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22171. * * 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)
  22172. * * 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)
  22173. * @returns the VertexData of the IcoSphere
  22174. */
  22175. static CreateIcoSphere(options: {
  22176. radius?: number;
  22177. radiusX?: number;
  22178. radiusY?: number;
  22179. radiusZ?: number;
  22180. flat?: boolean;
  22181. subdivisions?: number;
  22182. sideOrientation?: number;
  22183. frontUVs?: Vector4;
  22184. backUVs?: Vector4;
  22185. }): VertexData;
  22186. /**
  22187. * Creates the VertexData for a Polyhedron
  22188. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22189. * * type provided types are:
  22190. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22191. * * 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)
  22192. * * size the size of the IcoSphere, optional default 1
  22193. * * sizeX allows stretching in the x direction, optional, default size
  22194. * * sizeY allows stretching in the y direction, optional, default size
  22195. * * sizeZ allows stretching in the z direction, optional, default size
  22196. * * 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
  22197. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22198. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22199. * * flat when true creates a flat shaded mesh, optional, default true
  22200. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22201. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22202. * * 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)
  22203. * * 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)
  22204. * @returns the VertexData of the Polyhedron
  22205. */
  22206. static CreatePolyhedron(options: {
  22207. type?: number;
  22208. size?: number;
  22209. sizeX?: number;
  22210. sizeY?: number;
  22211. sizeZ?: number;
  22212. custom?: any;
  22213. faceUV?: Vector4[];
  22214. faceColors?: Color4[];
  22215. flat?: boolean;
  22216. sideOrientation?: number;
  22217. frontUVs?: Vector4;
  22218. backUVs?: Vector4;
  22219. }): VertexData;
  22220. /**
  22221. * Creates the VertexData for a TorusKnot
  22222. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22223. * * radius the radius of the torus knot, optional, default 2
  22224. * * tube the thickness of the tube, optional, default 0.5
  22225. * * radialSegments the number of sides on each tube segments, optional, default 32
  22226. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22227. * * p the number of windings around the z axis, optional, default 2
  22228. * * q the number of windings around the x axis, optional, default 3
  22229. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22230. * * 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)
  22231. * * 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)
  22232. * @returns the VertexData of the Torus Knot
  22233. */
  22234. static CreateTorusKnot(options: {
  22235. radius?: number;
  22236. tube?: number;
  22237. radialSegments?: number;
  22238. tubularSegments?: number;
  22239. p?: number;
  22240. q?: number;
  22241. sideOrientation?: number;
  22242. frontUVs?: Vector4;
  22243. backUVs?: Vector4;
  22244. }): VertexData;
  22245. /**
  22246. * Compute normals for given positions and indices
  22247. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22248. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22249. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22250. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22251. * * facetNormals : optional array of facet normals (vector3)
  22252. * * facetPositions : optional array of facet positions (vector3)
  22253. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22254. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22255. * * bInfo : optional bounding info, required for facetPartitioning computation
  22256. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22257. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22258. * * useRightHandedSystem: optional boolean to for right handed system computation
  22259. * * depthSort : optional boolean to enable the facet depth sort computation
  22260. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22261. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22262. */
  22263. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22264. facetNormals?: any;
  22265. facetPositions?: any;
  22266. facetPartitioning?: any;
  22267. ratio?: number;
  22268. bInfo?: any;
  22269. bbSize?: Vector3;
  22270. subDiv?: any;
  22271. useRightHandedSystem?: boolean;
  22272. depthSort?: boolean;
  22273. distanceTo?: Vector3;
  22274. depthSortedFacets?: any;
  22275. }): void;
  22276. /** @hidden */
  22277. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22278. /**
  22279. * Applies VertexData created from the imported parameters to the geometry
  22280. * @param parsedVertexData the parsed data from an imported file
  22281. * @param geometry the geometry to apply the VertexData to
  22282. */
  22283. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22284. }
  22285. }
  22286. declare module BABYLON {
  22287. /**
  22288. * Defines a target to use with MorphTargetManager
  22289. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22290. */
  22291. export class MorphTarget implements IAnimatable {
  22292. /** defines the name of the target */
  22293. name: string;
  22294. /**
  22295. * Gets or sets the list of animations
  22296. */
  22297. animations: Animation[];
  22298. private _scene;
  22299. private _positions;
  22300. private _normals;
  22301. private _tangents;
  22302. private _uvs;
  22303. private _influence;
  22304. private _uniqueId;
  22305. /**
  22306. * Observable raised when the influence changes
  22307. */
  22308. onInfluenceChanged: Observable<boolean>;
  22309. /** @hidden */
  22310. _onDataLayoutChanged: Observable<void>;
  22311. /**
  22312. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22313. */
  22314. influence: number;
  22315. /**
  22316. * Gets or sets the id of the morph Target
  22317. */
  22318. id: string;
  22319. private _animationPropertiesOverride;
  22320. /**
  22321. * Gets or sets the animation properties override
  22322. */
  22323. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22324. /**
  22325. * Creates a new MorphTarget
  22326. * @param name defines the name of the target
  22327. * @param influence defines the influence to use
  22328. * @param scene defines the scene the morphtarget belongs to
  22329. */
  22330. constructor(
  22331. /** defines the name of the target */
  22332. name: string, influence?: number, scene?: Nullable<Scene>);
  22333. /**
  22334. * Gets the unique ID of this manager
  22335. */
  22336. readonly uniqueId: number;
  22337. /**
  22338. * Gets a boolean defining if the target contains position data
  22339. */
  22340. readonly hasPositions: boolean;
  22341. /**
  22342. * Gets a boolean defining if the target contains normal data
  22343. */
  22344. readonly hasNormals: boolean;
  22345. /**
  22346. * Gets a boolean defining if the target contains tangent data
  22347. */
  22348. readonly hasTangents: boolean;
  22349. /**
  22350. * Gets a boolean defining if the target contains texture coordinates data
  22351. */
  22352. readonly hasUVs: boolean;
  22353. /**
  22354. * Affects position data to this target
  22355. * @param data defines the position data to use
  22356. */
  22357. setPositions(data: Nullable<FloatArray>): void;
  22358. /**
  22359. * Gets the position data stored in this target
  22360. * @returns a FloatArray containing the position data (or null if not present)
  22361. */
  22362. getPositions(): Nullable<FloatArray>;
  22363. /**
  22364. * Affects normal data to this target
  22365. * @param data defines the normal data to use
  22366. */
  22367. setNormals(data: Nullable<FloatArray>): void;
  22368. /**
  22369. * Gets the normal data stored in this target
  22370. * @returns a FloatArray containing the normal data (or null if not present)
  22371. */
  22372. getNormals(): Nullable<FloatArray>;
  22373. /**
  22374. * Affects tangent data to this target
  22375. * @param data defines the tangent data to use
  22376. */
  22377. setTangents(data: Nullable<FloatArray>): void;
  22378. /**
  22379. * Gets the tangent data stored in this target
  22380. * @returns a FloatArray containing the tangent data (or null if not present)
  22381. */
  22382. getTangents(): Nullable<FloatArray>;
  22383. /**
  22384. * Affects texture coordinates data to this target
  22385. * @param data defines the texture coordinates data to use
  22386. */
  22387. setUVs(data: Nullable<FloatArray>): void;
  22388. /**
  22389. * Gets the texture coordinates data stored in this target
  22390. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22391. */
  22392. getUVs(): Nullable<FloatArray>;
  22393. /**
  22394. * Clone the current target
  22395. * @returns a new MorphTarget
  22396. */
  22397. clone(): MorphTarget;
  22398. /**
  22399. * Serializes the current target into a Serialization object
  22400. * @returns the serialized object
  22401. */
  22402. serialize(): any;
  22403. /**
  22404. * Returns the string "MorphTarget"
  22405. * @returns "MorphTarget"
  22406. */
  22407. getClassName(): string;
  22408. /**
  22409. * Creates a new target from serialized data
  22410. * @param serializationObject defines the serialized data to use
  22411. * @returns a new MorphTarget
  22412. */
  22413. static Parse(serializationObject: any): MorphTarget;
  22414. /**
  22415. * Creates a MorphTarget from mesh data
  22416. * @param mesh defines the source mesh
  22417. * @param name defines the name to use for the new target
  22418. * @param influence defines the influence to attach to the target
  22419. * @returns a new MorphTarget
  22420. */
  22421. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22422. }
  22423. }
  22424. declare module BABYLON {
  22425. /**
  22426. * This class is used to deform meshes using morphing between different targets
  22427. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22428. */
  22429. export class MorphTargetManager {
  22430. private _targets;
  22431. private _targetInfluenceChangedObservers;
  22432. private _targetDataLayoutChangedObservers;
  22433. private _activeTargets;
  22434. private _scene;
  22435. private _influences;
  22436. private _supportsNormals;
  22437. private _supportsTangents;
  22438. private _supportsUVs;
  22439. private _vertexCount;
  22440. private _uniqueId;
  22441. private _tempInfluences;
  22442. /**
  22443. * Gets or sets a boolean indicating if normals must be morphed
  22444. */
  22445. enableNormalMorphing: boolean;
  22446. /**
  22447. * Gets or sets a boolean indicating if tangents must be morphed
  22448. */
  22449. enableTangentMorphing: boolean;
  22450. /**
  22451. * Gets or sets a boolean indicating if UV must be morphed
  22452. */
  22453. enableUVMorphing: boolean;
  22454. /**
  22455. * Creates a new MorphTargetManager
  22456. * @param scene defines the current scene
  22457. */
  22458. constructor(scene?: Nullable<Scene>);
  22459. /**
  22460. * Gets the unique ID of this manager
  22461. */
  22462. readonly uniqueId: number;
  22463. /**
  22464. * Gets the number of vertices handled by this manager
  22465. */
  22466. readonly vertexCount: number;
  22467. /**
  22468. * Gets a boolean indicating if this manager supports morphing of normals
  22469. */
  22470. readonly supportsNormals: boolean;
  22471. /**
  22472. * Gets a boolean indicating if this manager supports morphing of tangents
  22473. */
  22474. readonly supportsTangents: boolean;
  22475. /**
  22476. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22477. */
  22478. readonly supportsUVs: boolean;
  22479. /**
  22480. * Gets the number of targets stored in this manager
  22481. */
  22482. readonly numTargets: number;
  22483. /**
  22484. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22485. */
  22486. readonly numInfluencers: number;
  22487. /**
  22488. * Gets the list of influences (one per target)
  22489. */
  22490. readonly influences: Float32Array;
  22491. /**
  22492. * Gets the active target at specified index. An active target is a target with an influence > 0
  22493. * @param index defines the index to check
  22494. * @returns the requested target
  22495. */
  22496. getActiveTarget(index: number): MorphTarget;
  22497. /**
  22498. * Gets the target at specified index
  22499. * @param index defines the index to check
  22500. * @returns the requested target
  22501. */
  22502. getTarget(index: number): MorphTarget;
  22503. /**
  22504. * Add a new target to this manager
  22505. * @param target defines the target to add
  22506. */
  22507. addTarget(target: MorphTarget): void;
  22508. /**
  22509. * Removes a target from the manager
  22510. * @param target defines the target to remove
  22511. */
  22512. removeTarget(target: MorphTarget): void;
  22513. /**
  22514. * Clone the current manager
  22515. * @returns a new MorphTargetManager
  22516. */
  22517. clone(): MorphTargetManager;
  22518. /**
  22519. * Serializes the current manager into a Serialization object
  22520. * @returns the serialized object
  22521. */
  22522. serialize(): any;
  22523. private _syncActiveTargets;
  22524. /**
  22525. * Syncrhonize the targets with all the meshes using this morph target manager
  22526. */
  22527. synchronize(): void;
  22528. /**
  22529. * Creates a new MorphTargetManager from serialized data
  22530. * @param serializationObject defines the serialized data
  22531. * @param scene defines the hosting scene
  22532. * @returns the new MorphTargetManager
  22533. */
  22534. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22535. }
  22536. }
  22537. declare module BABYLON {
  22538. /**
  22539. * Class used to represent a specific level of detail of a mesh
  22540. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22541. */
  22542. export class MeshLODLevel {
  22543. /** Defines the distance where this level should start being displayed */
  22544. distance: number;
  22545. /** Defines the mesh to use to render this level */
  22546. mesh: Nullable<Mesh>;
  22547. /**
  22548. * Creates a new LOD level
  22549. * @param distance defines the distance where this level should star being displayed
  22550. * @param mesh defines the mesh to use to render this level
  22551. */
  22552. constructor(
  22553. /** Defines the distance where this level should start being displayed */
  22554. distance: number,
  22555. /** Defines the mesh to use to render this level */
  22556. mesh: Nullable<Mesh>);
  22557. }
  22558. }
  22559. declare module BABYLON {
  22560. /**
  22561. * Mesh representing the gorund
  22562. */
  22563. export class GroundMesh extends Mesh {
  22564. /** If octree should be generated */
  22565. generateOctree: boolean;
  22566. private _heightQuads;
  22567. /** @hidden */
  22568. _subdivisionsX: number;
  22569. /** @hidden */
  22570. _subdivisionsY: number;
  22571. /** @hidden */
  22572. _width: number;
  22573. /** @hidden */
  22574. _height: number;
  22575. /** @hidden */
  22576. _minX: number;
  22577. /** @hidden */
  22578. _maxX: number;
  22579. /** @hidden */
  22580. _minZ: number;
  22581. /** @hidden */
  22582. _maxZ: number;
  22583. constructor(name: string, scene: Scene);
  22584. /**
  22585. * "GroundMesh"
  22586. * @returns "GroundMesh"
  22587. */
  22588. getClassName(): string;
  22589. /**
  22590. * The minimum of x and y subdivisions
  22591. */
  22592. readonly subdivisions: number;
  22593. /**
  22594. * X subdivisions
  22595. */
  22596. readonly subdivisionsX: number;
  22597. /**
  22598. * Y subdivisions
  22599. */
  22600. readonly subdivisionsY: number;
  22601. /**
  22602. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22603. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22604. * @param chunksCount the number of subdivisions for x and y
  22605. * @param octreeBlocksSize (Default: 32)
  22606. */
  22607. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22608. /**
  22609. * Returns a height (y) value in the Worl system :
  22610. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22611. * @param x x coordinate
  22612. * @param z z coordinate
  22613. * @returns the ground y position if (x, z) are outside the ground surface.
  22614. */
  22615. getHeightAtCoordinates(x: number, z: number): number;
  22616. /**
  22617. * Returns a normalized vector (Vector3) orthogonal to the ground
  22618. * at the ground coordinates (x, z) expressed in the World system.
  22619. * @param x x coordinate
  22620. * @param z z coordinate
  22621. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22622. */
  22623. getNormalAtCoordinates(x: number, z: number): Vector3;
  22624. /**
  22625. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22626. * at the ground coordinates (x, z) expressed in the World system.
  22627. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22628. * @param x x coordinate
  22629. * @param z z coordinate
  22630. * @param ref vector to store the result
  22631. * @returns the GroundMesh.
  22632. */
  22633. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22634. /**
  22635. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22636. * if the ground has been updated.
  22637. * This can be used in the render loop.
  22638. * @returns the GroundMesh.
  22639. */
  22640. updateCoordinateHeights(): GroundMesh;
  22641. private _getFacetAt;
  22642. private _initHeightQuads;
  22643. private _computeHeightQuads;
  22644. /**
  22645. * Serializes this ground mesh
  22646. * @param serializationObject object to write serialization to
  22647. */
  22648. serialize(serializationObject: any): void;
  22649. /**
  22650. * Parses a serialized ground mesh
  22651. * @param parsedMesh the serialized mesh
  22652. * @param scene the scene to create the ground mesh in
  22653. * @returns the created ground mesh
  22654. */
  22655. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22656. }
  22657. }
  22658. declare module BABYLON {
  22659. /**
  22660. * Interface for Physics-Joint data
  22661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22662. */
  22663. export interface PhysicsJointData {
  22664. /**
  22665. * The main pivot of the joint
  22666. */
  22667. mainPivot?: Vector3;
  22668. /**
  22669. * The connected pivot of the joint
  22670. */
  22671. connectedPivot?: Vector3;
  22672. /**
  22673. * The main axis of the joint
  22674. */
  22675. mainAxis?: Vector3;
  22676. /**
  22677. * The connected axis of the joint
  22678. */
  22679. connectedAxis?: Vector3;
  22680. /**
  22681. * The collision of the joint
  22682. */
  22683. collision?: boolean;
  22684. /**
  22685. * Native Oimo/Cannon/Energy data
  22686. */
  22687. nativeParams?: any;
  22688. }
  22689. /**
  22690. * This is a holder class for the physics joint created by the physics plugin
  22691. * It holds a set of functions to control the underlying joint
  22692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22693. */
  22694. export class PhysicsJoint {
  22695. /**
  22696. * The type of the physics joint
  22697. */
  22698. type: number;
  22699. /**
  22700. * The data for the physics joint
  22701. */
  22702. jointData: PhysicsJointData;
  22703. private _physicsJoint;
  22704. protected _physicsPlugin: IPhysicsEnginePlugin;
  22705. /**
  22706. * Initializes the physics joint
  22707. * @param type The type of the physics joint
  22708. * @param jointData The data for the physics joint
  22709. */
  22710. constructor(
  22711. /**
  22712. * The type of the physics joint
  22713. */
  22714. type: number,
  22715. /**
  22716. * The data for the physics joint
  22717. */
  22718. jointData: PhysicsJointData);
  22719. /**
  22720. * Gets the physics joint
  22721. */
  22722. /**
  22723. * Sets the physics joint
  22724. */
  22725. physicsJoint: any;
  22726. /**
  22727. * Sets the physics plugin
  22728. */
  22729. physicsPlugin: IPhysicsEnginePlugin;
  22730. /**
  22731. * Execute a function that is physics-plugin specific.
  22732. * @param {Function} func the function that will be executed.
  22733. * It accepts two parameters: the physics world and the physics joint
  22734. */
  22735. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22736. /**
  22737. * Distance-Joint type
  22738. */
  22739. static DistanceJoint: number;
  22740. /**
  22741. * Hinge-Joint type
  22742. */
  22743. static HingeJoint: number;
  22744. /**
  22745. * Ball-and-Socket joint type
  22746. */
  22747. static BallAndSocketJoint: number;
  22748. /**
  22749. * Wheel-Joint type
  22750. */
  22751. static WheelJoint: number;
  22752. /**
  22753. * Slider-Joint type
  22754. */
  22755. static SliderJoint: number;
  22756. /**
  22757. * Prismatic-Joint type
  22758. */
  22759. static PrismaticJoint: number;
  22760. /**
  22761. * Universal-Joint type
  22762. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22763. */
  22764. static UniversalJoint: number;
  22765. /**
  22766. * Hinge-Joint 2 type
  22767. */
  22768. static Hinge2Joint: number;
  22769. /**
  22770. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22771. */
  22772. static PointToPointJoint: number;
  22773. /**
  22774. * Spring-Joint type
  22775. */
  22776. static SpringJoint: number;
  22777. /**
  22778. * Lock-Joint type
  22779. */
  22780. static LockJoint: number;
  22781. }
  22782. /**
  22783. * A class representing a physics distance joint
  22784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22785. */
  22786. export class DistanceJoint extends PhysicsJoint {
  22787. /**
  22788. *
  22789. * @param jointData The data for the Distance-Joint
  22790. */
  22791. constructor(jointData: DistanceJointData);
  22792. /**
  22793. * Update the predefined distance.
  22794. * @param maxDistance The maximum preferred distance
  22795. * @param minDistance The minimum preferred distance
  22796. */
  22797. updateDistance(maxDistance: number, minDistance?: number): void;
  22798. }
  22799. /**
  22800. * Represents a Motor-Enabled Joint
  22801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22802. */
  22803. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22804. /**
  22805. * Initializes the Motor-Enabled Joint
  22806. * @param type The type of the joint
  22807. * @param jointData The physica joint data for the joint
  22808. */
  22809. constructor(type: number, jointData: PhysicsJointData);
  22810. /**
  22811. * Set the motor values.
  22812. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22813. * @param force the force to apply
  22814. * @param maxForce max force for this motor.
  22815. */
  22816. setMotor(force?: number, maxForce?: number): void;
  22817. /**
  22818. * Set the motor's limits.
  22819. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22820. * @param upperLimit The upper limit of the motor
  22821. * @param lowerLimit The lower limit of the motor
  22822. */
  22823. setLimit(upperLimit: number, lowerLimit?: number): void;
  22824. }
  22825. /**
  22826. * This class represents a single physics Hinge-Joint
  22827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22828. */
  22829. export class HingeJoint extends MotorEnabledJoint {
  22830. /**
  22831. * Initializes the Hinge-Joint
  22832. * @param jointData The joint data for the Hinge-Joint
  22833. */
  22834. constructor(jointData: PhysicsJointData);
  22835. /**
  22836. * Set the motor values.
  22837. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22838. * @param {number} force the force to apply
  22839. * @param {number} maxForce max force for this motor.
  22840. */
  22841. setMotor(force?: number, maxForce?: number): void;
  22842. /**
  22843. * Set the motor's limits.
  22844. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22845. * @param upperLimit The upper limit of the motor
  22846. * @param lowerLimit The lower limit of the motor
  22847. */
  22848. setLimit(upperLimit: number, lowerLimit?: number): void;
  22849. }
  22850. /**
  22851. * This class represents a dual hinge physics joint (same as wheel joint)
  22852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22853. */
  22854. export class Hinge2Joint extends MotorEnabledJoint {
  22855. /**
  22856. * Initializes the Hinge2-Joint
  22857. * @param jointData The joint data for the Hinge2-Joint
  22858. */
  22859. constructor(jointData: PhysicsJointData);
  22860. /**
  22861. * Set the motor values.
  22862. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22863. * @param {number} targetSpeed the speed the motor is to reach
  22864. * @param {number} maxForce max force for this motor.
  22865. * @param {motorIndex} the motor's index, 0 or 1.
  22866. */
  22867. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22868. /**
  22869. * Set the motor limits.
  22870. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22871. * @param {number} upperLimit the upper limit
  22872. * @param {number} lowerLimit lower limit
  22873. * @param {motorIndex} the motor's index, 0 or 1.
  22874. */
  22875. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22876. }
  22877. /**
  22878. * Interface for a motor enabled joint
  22879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22880. */
  22881. export interface IMotorEnabledJoint {
  22882. /**
  22883. * Physics joint
  22884. */
  22885. physicsJoint: any;
  22886. /**
  22887. * Sets the motor of the motor-enabled joint
  22888. * @param force The force of the motor
  22889. * @param maxForce The maximum force of the motor
  22890. * @param motorIndex The index of the motor
  22891. */
  22892. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22893. /**
  22894. * Sets the limit of the motor
  22895. * @param upperLimit The upper limit of the motor
  22896. * @param lowerLimit The lower limit of the motor
  22897. * @param motorIndex The index of the motor
  22898. */
  22899. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22900. }
  22901. /**
  22902. * Joint data for a Distance-Joint
  22903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22904. */
  22905. export interface DistanceJointData extends PhysicsJointData {
  22906. /**
  22907. * Max distance the 2 joint objects can be apart
  22908. */
  22909. maxDistance: number;
  22910. }
  22911. /**
  22912. * Joint data from a spring joint
  22913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22914. */
  22915. export interface SpringJointData extends PhysicsJointData {
  22916. /**
  22917. * Length of the spring
  22918. */
  22919. length: number;
  22920. /**
  22921. * Stiffness of the spring
  22922. */
  22923. stiffness: number;
  22924. /**
  22925. * Damping of the spring
  22926. */
  22927. damping: number;
  22928. /** this callback will be called when applying the force to the impostors. */
  22929. forceApplicationCallback: () => void;
  22930. }
  22931. }
  22932. declare module BABYLON {
  22933. /**
  22934. * Holds the data for the raycast result
  22935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22936. */
  22937. export class PhysicsRaycastResult {
  22938. private _hasHit;
  22939. private _hitDistance;
  22940. private _hitNormalWorld;
  22941. private _hitPointWorld;
  22942. private _rayFromWorld;
  22943. private _rayToWorld;
  22944. /**
  22945. * Gets if there was a hit
  22946. */
  22947. readonly hasHit: boolean;
  22948. /**
  22949. * Gets the distance from the hit
  22950. */
  22951. readonly hitDistance: number;
  22952. /**
  22953. * Gets the hit normal/direction in the world
  22954. */
  22955. readonly hitNormalWorld: Vector3;
  22956. /**
  22957. * Gets the hit point in the world
  22958. */
  22959. readonly hitPointWorld: Vector3;
  22960. /**
  22961. * Gets the ray "start point" of the ray in the world
  22962. */
  22963. readonly rayFromWorld: Vector3;
  22964. /**
  22965. * Gets the ray "end point" of the ray in the world
  22966. */
  22967. readonly rayToWorld: Vector3;
  22968. /**
  22969. * Sets the hit data (normal & point in world space)
  22970. * @param hitNormalWorld defines the normal in world space
  22971. * @param hitPointWorld defines the point in world space
  22972. */
  22973. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22974. /**
  22975. * Sets the distance from the start point to the hit point
  22976. * @param distance
  22977. */
  22978. setHitDistance(distance: number): void;
  22979. /**
  22980. * Calculates the distance manually
  22981. */
  22982. calculateHitDistance(): void;
  22983. /**
  22984. * Resets all the values to default
  22985. * @param from The from point on world space
  22986. * @param to The to point on world space
  22987. */
  22988. reset(from?: Vector3, to?: Vector3): void;
  22989. }
  22990. /**
  22991. * Interface for the size containing width and height
  22992. */
  22993. interface IXYZ {
  22994. /**
  22995. * X
  22996. */
  22997. x: number;
  22998. /**
  22999. * Y
  23000. */
  23001. y: number;
  23002. /**
  23003. * Z
  23004. */
  23005. z: number;
  23006. }
  23007. }
  23008. declare module BABYLON {
  23009. /**
  23010. * Interface used to describe a physics joint
  23011. */
  23012. export interface PhysicsImpostorJoint {
  23013. /** Defines the main impostor to which the joint is linked */
  23014. mainImpostor: PhysicsImpostor;
  23015. /** Defines the impostor that is connected to the main impostor using this joint */
  23016. connectedImpostor: PhysicsImpostor;
  23017. /** Defines the joint itself */
  23018. joint: PhysicsJoint;
  23019. }
  23020. /** @hidden */
  23021. export interface IPhysicsEnginePlugin {
  23022. world: any;
  23023. name: string;
  23024. setGravity(gravity: Vector3): void;
  23025. setTimeStep(timeStep: number): void;
  23026. getTimeStep(): number;
  23027. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23028. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23029. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23030. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23031. removePhysicsBody(impostor: PhysicsImpostor): void;
  23032. generateJoint(joint: PhysicsImpostorJoint): void;
  23033. removeJoint(joint: PhysicsImpostorJoint): void;
  23034. isSupported(): boolean;
  23035. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23036. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23037. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23038. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23039. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23040. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23041. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23042. getBodyMass(impostor: PhysicsImpostor): number;
  23043. getBodyFriction(impostor: PhysicsImpostor): number;
  23044. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23045. getBodyRestitution(impostor: PhysicsImpostor): number;
  23046. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23047. getBodyPressure?(impostor: PhysicsImpostor): number;
  23048. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23049. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23050. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23051. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23052. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23053. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23054. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23055. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23056. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23057. sleepBody(impostor: PhysicsImpostor): void;
  23058. wakeUpBody(impostor: PhysicsImpostor): void;
  23059. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23060. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23061. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23062. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23063. getRadius(impostor: PhysicsImpostor): number;
  23064. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23065. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23066. dispose(): void;
  23067. }
  23068. /**
  23069. * Interface used to define a physics engine
  23070. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23071. */
  23072. export interface IPhysicsEngine {
  23073. /**
  23074. * Gets the gravity vector used by the simulation
  23075. */
  23076. gravity: Vector3;
  23077. /**
  23078. * Sets the gravity vector used by the simulation
  23079. * @param gravity defines the gravity vector to use
  23080. */
  23081. setGravity(gravity: Vector3): void;
  23082. /**
  23083. * Set the time step of the physics engine.
  23084. * Default is 1/60.
  23085. * To slow it down, enter 1/600 for example.
  23086. * To speed it up, 1/30
  23087. * @param newTimeStep the new timestep to apply to this world.
  23088. */
  23089. setTimeStep(newTimeStep: number): void;
  23090. /**
  23091. * Get the time step of the physics engine.
  23092. * @returns the current time step
  23093. */
  23094. getTimeStep(): number;
  23095. /**
  23096. * Set the sub time step of the physics engine.
  23097. * Default is 0 meaning there is no sub steps
  23098. * To increase physics resolution precision, set a small value (like 1 ms)
  23099. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23100. */
  23101. setSubTimeStep(subTimeStep: number): void;
  23102. /**
  23103. * Get the sub time step of the physics engine.
  23104. * @returns the current sub time step
  23105. */
  23106. getSubTimeStep(): number;
  23107. /**
  23108. * Release all resources
  23109. */
  23110. dispose(): void;
  23111. /**
  23112. * Gets the name of the current physics plugin
  23113. * @returns the name of the plugin
  23114. */
  23115. getPhysicsPluginName(): string;
  23116. /**
  23117. * Adding a new impostor for the impostor tracking.
  23118. * This will be done by the impostor itself.
  23119. * @param impostor the impostor to add
  23120. */
  23121. addImpostor(impostor: PhysicsImpostor): void;
  23122. /**
  23123. * Remove an impostor from the engine.
  23124. * This impostor and its mesh will not longer be updated by the physics engine.
  23125. * @param impostor the impostor to remove
  23126. */
  23127. removeImpostor(impostor: PhysicsImpostor): void;
  23128. /**
  23129. * Add a joint to the physics engine
  23130. * @param mainImpostor defines the main impostor to which the joint is added.
  23131. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23132. * @param joint defines the joint that will connect both impostors.
  23133. */
  23134. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23135. /**
  23136. * Removes a joint from the simulation
  23137. * @param mainImpostor defines the impostor used with the joint
  23138. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23139. * @param joint defines the joint to remove
  23140. */
  23141. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23142. /**
  23143. * Gets the current plugin used to run the simulation
  23144. * @returns current plugin
  23145. */
  23146. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23147. /**
  23148. * Gets the list of physic impostors
  23149. * @returns an array of PhysicsImpostor
  23150. */
  23151. getImpostors(): Array<PhysicsImpostor>;
  23152. /**
  23153. * Gets the impostor for a physics enabled object
  23154. * @param object defines the object impersonated by the impostor
  23155. * @returns the PhysicsImpostor or null if not found
  23156. */
  23157. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23158. /**
  23159. * Gets the impostor for a physics body object
  23160. * @param body defines physics body used by the impostor
  23161. * @returns the PhysicsImpostor or null if not found
  23162. */
  23163. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23164. /**
  23165. * Does a raycast in the physics world
  23166. * @param from when should the ray start?
  23167. * @param to when should the ray end?
  23168. * @returns PhysicsRaycastResult
  23169. */
  23170. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23171. /**
  23172. * Called by the scene. No need to call it.
  23173. * @param delta defines the timespam between frames
  23174. */
  23175. _step(delta: number): void;
  23176. }
  23177. }
  23178. declare module BABYLON {
  23179. /**
  23180. * The interface for the physics imposter parameters
  23181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23182. */
  23183. export interface PhysicsImpostorParameters {
  23184. /**
  23185. * The mass of the physics imposter
  23186. */
  23187. mass: number;
  23188. /**
  23189. * The friction of the physics imposter
  23190. */
  23191. friction?: number;
  23192. /**
  23193. * The coefficient of restitution of the physics imposter
  23194. */
  23195. restitution?: number;
  23196. /**
  23197. * The native options of the physics imposter
  23198. */
  23199. nativeOptions?: any;
  23200. /**
  23201. * Specifies if the parent should be ignored
  23202. */
  23203. ignoreParent?: boolean;
  23204. /**
  23205. * Specifies if bi-directional transformations should be disabled
  23206. */
  23207. disableBidirectionalTransformation?: boolean;
  23208. /**
  23209. * The pressure inside the physics imposter, soft object only
  23210. */
  23211. pressure?: number;
  23212. /**
  23213. * The stiffness the physics imposter, soft object only
  23214. */
  23215. stiffness?: number;
  23216. /**
  23217. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23218. */
  23219. velocityIterations?: number;
  23220. /**
  23221. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23222. */
  23223. positionIterations?: number;
  23224. /**
  23225. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23226. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23227. * Add to fix multiple points
  23228. */
  23229. fixedPoints?: number;
  23230. /**
  23231. * The collision margin around a soft object
  23232. */
  23233. margin?: number;
  23234. /**
  23235. * The collision margin around a soft object
  23236. */
  23237. damping?: number;
  23238. /**
  23239. * The path for a rope based on an extrusion
  23240. */
  23241. path?: any;
  23242. /**
  23243. * The shape of an extrusion used for a rope based on an extrusion
  23244. */
  23245. shape?: any;
  23246. }
  23247. /**
  23248. * Interface for a physics-enabled object
  23249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23250. */
  23251. export interface IPhysicsEnabledObject {
  23252. /**
  23253. * The position of the physics-enabled object
  23254. */
  23255. position: Vector3;
  23256. /**
  23257. * The rotation of the physics-enabled object
  23258. */
  23259. rotationQuaternion: Nullable<Quaternion>;
  23260. /**
  23261. * The scale of the physics-enabled object
  23262. */
  23263. scaling: Vector3;
  23264. /**
  23265. * The rotation of the physics-enabled object
  23266. */
  23267. rotation?: Vector3;
  23268. /**
  23269. * The parent of the physics-enabled object
  23270. */
  23271. parent?: any;
  23272. /**
  23273. * The bounding info of the physics-enabled object
  23274. * @returns The bounding info of the physics-enabled object
  23275. */
  23276. getBoundingInfo(): BoundingInfo;
  23277. /**
  23278. * Computes the world matrix
  23279. * @param force Specifies if the world matrix should be computed by force
  23280. * @returns A world matrix
  23281. */
  23282. computeWorldMatrix(force: boolean): Matrix;
  23283. /**
  23284. * Gets the world matrix
  23285. * @returns A world matrix
  23286. */
  23287. getWorldMatrix?(): Matrix;
  23288. /**
  23289. * Gets the child meshes
  23290. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23291. * @returns An array of abstract meshes
  23292. */
  23293. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23294. /**
  23295. * Gets the vertex data
  23296. * @param kind The type of vertex data
  23297. * @returns A nullable array of numbers, or a float32 array
  23298. */
  23299. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23300. /**
  23301. * Gets the indices from the mesh
  23302. * @returns A nullable array of index arrays
  23303. */
  23304. getIndices?(): Nullable<IndicesArray>;
  23305. /**
  23306. * Gets the scene from the mesh
  23307. * @returns the indices array or null
  23308. */
  23309. getScene?(): Scene;
  23310. /**
  23311. * Gets the absolute position from the mesh
  23312. * @returns the absolute position
  23313. */
  23314. getAbsolutePosition(): Vector3;
  23315. /**
  23316. * Gets the absolute pivot point from the mesh
  23317. * @returns the absolute pivot point
  23318. */
  23319. getAbsolutePivotPoint(): Vector3;
  23320. /**
  23321. * Rotates the mesh
  23322. * @param axis The axis of rotation
  23323. * @param amount The amount of rotation
  23324. * @param space The space of the rotation
  23325. * @returns The rotation transform node
  23326. */
  23327. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23328. /**
  23329. * Translates the mesh
  23330. * @param axis The axis of translation
  23331. * @param distance The distance of translation
  23332. * @param space The space of the translation
  23333. * @returns The transform node
  23334. */
  23335. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23336. /**
  23337. * Sets the absolute position of the mesh
  23338. * @param absolutePosition The absolute position of the mesh
  23339. * @returns The transform node
  23340. */
  23341. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23342. /**
  23343. * Gets the class name of the mesh
  23344. * @returns The class name
  23345. */
  23346. getClassName(): string;
  23347. }
  23348. /**
  23349. * Represents a physics imposter
  23350. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23351. */
  23352. export class PhysicsImpostor {
  23353. /**
  23354. * The physics-enabled object used as the physics imposter
  23355. */
  23356. object: IPhysicsEnabledObject;
  23357. /**
  23358. * The type of the physics imposter
  23359. */
  23360. type: number;
  23361. private _options;
  23362. private _scene?;
  23363. /**
  23364. * The default object size of the imposter
  23365. */
  23366. static DEFAULT_OBJECT_SIZE: Vector3;
  23367. /**
  23368. * The identity quaternion of the imposter
  23369. */
  23370. static IDENTITY_QUATERNION: Quaternion;
  23371. /** @hidden */
  23372. _pluginData: any;
  23373. private _physicsEngine;
  23374. private _physicsBody;
  23375. private _bodyUpdateRequired;
  23376. private _onBeforePhysicsStepCallbacks;
  23377. private _onAfterPhysicsStepCallbacks;
  23378. /** @hidden */
  23379. _onPhysicsCollideCallbacks: Array<{
  23380. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23381. otherImpostors: Array<PhysicsImpostor>;
  23382. }>;
  23383. private _deltaPosition;
  23384. private _deltaRotation;
  23385. private _deltaRotationConjugated;
  23386. /** @hidden */
  23387. _isFromLine: boolean;
  23388. private _parent;
  23389. private _isDisposed;
  23390. private static _tmpVecs;
  23391. private static _tmpQuat;
  23392. /**
  23393. * Specifies if the physics imposter is disposed
  23394. */
  23395. readonly isDisposed: boolean;
  23396. /**
  23397. * Gets the mass of the physics imposter
  23398. */
  23399. mass: number;
  23400. /**
  23401. * Gets the coefficient of friction
  23402. */
  23403. /**
  23404. * Sets the coefficient of friction
  23405. */
  23406. friction: number;
  23407. /**
  23408. * Gets the coefficient of restitution
  23409. */
  23410. /**
  23411. * Sets the coefficient of restitution
  23412. */
  23413. restitution: number;
  23414. /**
  23415. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23416. */
  23417. /**
  23418. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23419. */
  23420. pressure: number;
  23421. /**
  23422. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23423. */
  23424. /**
  23425. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23426. */
  23427. stiffness: number;
  23428. /**
  23429. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23430. */
  23431. /**
  23432. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23433. */
  23434. velocityIterations: number;
  23435. /**
  23436. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23437. */
  23438. /**
  23439. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23440. */
  23441. positionIterations: number;
  23442. /**
  23443. * The unique id of the physics imposter
  23444. * set by the physics engine when adding this impostor to the array
  23445. */
  23446. uniqueId: number;
  23447. /**
  23448. * @hidden
  23449. */
  23450. soft: boolean;
  23451. /**
  23452. * @hidden
  23453. */
  23454. segments: number;
  23455. private _joints;
  23456. /**
  23457. * Initializes the physics imposter
  23458. * @param object The physics-enabled object used as the physics imposter
  23459. * @param type The type of the physics imposter
  23460. * @param _options The options for the physics imposter
  23461. * @param _scene The Babylon scene
  23462. */
  23463. constructor(
  23464. /**
  23465. * The physics-enabled object used as the physics imposter
  23466. */
  23467. object: IPhysicsEnabledObject,
  23468. /**
  23469. * The type of the physics imposter
  23470. */
  23471. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23472. /**
  23473. * This function will completly initialize this impostor.
  23474. * It will create a new body - but only if this mesh has no parent.
  23475. * If it has, this impostor will not be used other than to define the impostor
  23476. * of the child mesh.
  23477. * @hidden
  23478. */
  23479. _init(): void;
  23480. private _getPhysicsParent;
  23481. /**
  23482. * Should a new body be generated.
  23483. * @returns boolean specifying if body initialization is required
  23484. */
  23485. isBodyInitRequired(): boolean;
  23486. /**
  23487. * Sets the updated scaling
  23488. * @param updated Specifies if the scaling is updated
  23489. */
  23490. setScalingUpdated(): void;
  23491. /**
  23492. * Force a regeneration of this or the parent's impostor's body.
  23493. * Use under cautious - This will remove all joints already implemented.
  23494. */
  23495. forceUpdate(): void;
  23496. /**
  23497. * Gets the body that holds this impostor. Either its own, or its parent.
  23498. */
  23499. /**
  23500. * Set the physics body. Used mainly by the physics engine/plugin
  23501. */
  23502. physicsBody: any;
  23503. /**
  23504. * Get the parent of the physics imposter
  23505. * @returns Physics imposter or null
  23506. */
  23507. /**
  23508. * Sets the parent of the physics imposter
  23509. */
  23510. parent: Nullable<PhysicsImpostor>;
  23511. /**
  23512. * Resets the update flags
  23513. */
  23514. resetUpdateFlags(): void;
  23515. /**
  23516. * Gets the object extend size
  23517. * @returns the object extend size
  23518. */
  23519. getObjectExtendSize(): Vector3;
  23520. /**
  23521. * Gets the object center
  23522. * @returns The object center
  23523. */
  23524. getObjectCenter(): Vector3;
  23525. /**
  23526. * Get a specific parametes from the options parameter
  23527. * @param paramName The object parameter name
  23528. * @returns The object parameter
  23529. */
  23530. getParam(paramName: string): any;
  23531. /**
  23532. * Sets a specific parameter in the options given to the physics plugin
  23533. * @param paramName The parameter name
  23534. * @param value The value of the parameter
  23535. */
  23536. setParam(paramName: string, value: number): void;
  23537. /**
  23538. * Specifically change the body's mass option. Won't recreate the physics body object
  23539. * @param mass The mass of the physics imposter
  23540. */
  23541. setMass(mass: number): void;
  23542. /**
  23543. * Gets the linear velocity
  23544. * @returns linear velocity or null
  23545. */
  23546. getLinearVelocity(): Nullable<Vector3>;
  23547. /**
  23548. * Sets the linear velocity
  23549. * @param velocity linear velocity or null
  23550. */
  23551. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23552. /**
  23553. * Gets the angular velocity
  23554. * @returns angular velocity or null
  23555. */
  23556. getAngularVelocity(): Nullable<Vector3>;
  23557. /**
  23558. * Sets the angular velocity
  23559. * @param velocity The velocity or null
  23560. */
  23561. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23562. /**
  23563. * Execute a function with the physics plugin native code
  23564. * Provide a function the will have two variables - the world object and the physics body object
  23565. * @param func The function to execute with the physics plugin native code
  23566. */
  23567. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23568. /**
  23569. * Register a function that will be executed before the physics world is stepping forward
  23570. * @param func The function to execute before the physics world is stepped forward
  23571. */
  23572. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23573. /**
  23574. * Unregister a function that will be executed before the physics world is stepping forward
  23575. * @param func The function to execute before the physics world is stepped forward
  23576. */
  23577. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23578. /**
  23579. * Register a function that will be executed after the physics step
  23580. * @param func The function to execute after physics step
  23581. */
  23582. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23583. /**
  23584. * Unregisters a function that will be executed after the physics step
  23585. * @param func The function to execute after physics step
  23586. */
  23587. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23588. /**
  23589. * register a function that will be executed when this impostor collides against a different body
  23590. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23591. * @param func Callback that is executed on collision
  23592. */
  23593. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23594. /**
  23595. * Unregisters the physics imposter on contact
  23596. * @param collideAgainst The physics object to collide against
  23597. * @param func Callback to execute on collision
  23598. */
  23599. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23600. private _tmpQuat;
  23601. private _tmpQuat2;
  23602. /**
  23603. * Get the parent rotation
  23604. * @returns The parent rotation
  23605. */
  23606. getParentsRotation(): Quaternion;
  23607. /**
  23608. * this function is executed by the physics engine.
  23609. */
  23610. beforeStep: () => void;
  23611. /**
  23612. * this function is executed by the physics engine
  23613. */
  23614. afterStep: () => void;
  23615. /**
  23616. * Legacy collision detection event support
  23617. */
  23618. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23619. /**
  23620. * event and body object due to cannon's event-based architecture.
  23621. */
  23622. onCollide: (e: {
  23623. body: any;
  23624. }) => void;
  23625. /**
  23626. * Apply a force
  23627. * @param force The force to apply
  23628. * @param contactPoint The contact point for the force
  23629. * @returns The physics imposter
  23630. */
  23631. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23632. /**
  23633. * Apply an impulse
  23634. * @param force The impulse force
  23635. * @param contactPoint The contact point for the impulse force
  23636. * @returns The physics imposter
  23637. */
  23638. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23639. /**
  23640. * A help function to create a joint
  23641. * @param otherImpostor A physics imposter used to create a joint
  23642. * @param jointType The type of joint
  23643. * @param jointData The data for the joint
  23644. * @returns The physics imposter
  23645. */
  23646. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23647. /**
  23648. * Add a joint to this impostor with a different impostor
  23649. * @param otherImpostor A physics imposter used to add a joint
  23650. * @param joint The joint to add
  23651. * @returns The physics imposter
  23652. */
  23653. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23654. /**
  23655. * Add an anchor to a cloth impostor
  23656. * @param otherImpostor rigid impostor to anchor to
  23657. * @param width ratio across width from 0 to 1
  23658. * @param height ratio up height from 0 to 1
  23659. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23660. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23661. * @returns impostor the soft imposter
  23662. */
  23663. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23664. /**
  23665. * Add a hook to a rope impostor
  23666. * @param otherImpostor rigid impostor to anchor to
  23667. * @param length ratio across rope from 0 to 1
  23668. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23669. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23670. * @returns impostor the rope imposter
  23671. */
  23672. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23673. /**
  23674. * Will keep this body still, in a sleep mode.
  23675. * @returns the physics imposter
  23676. */
  23677. sleep(): PhysicsImpostor;
  23678. /**
  23679. * Wake the body up.
  23680. * @returns The physics imposter
  23681. */
  23682. wakeUp(): PhysicsImpostor;
  23683. /**
  23684. * Clones the physics imposter
  23685. * @param newObject The physics imposter clones to this physics-enabled object
  23686. * @returns A nullable physics imposter
  23687. */
  23688. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23689. /**
  23690. * Disposes the physics imposter
  23691. */
  23692. dispose(): void;
  23693. /**
  23694. * Sets the delta position
  23695. * @param position The delta position amount
  23696. */
  23697. setDeltaPosition(position: Vector3): void;
  23698. /**
  23699. * Sets the delta rotation
  23700. * @param rotation The delta rotation amount
  23701. */
  23702. setDeltaRotation(rotation: Quaternion): void;
  23703. /**
  23704. * Gets the box size of the physics imposter and stores the result in the input parameter
  23705. * @param result Stores the box size
  23706. * @returns The physics imposter
  23707. */
  23708. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23709. /**
  23710. * Gets the radius of the physics imposter
  23711. * @returns Radius of the physics imposter
  23712. */
  23713. getRadius(): number;
  23714. /**
  23715. * Sync a bone with this impostor
  23716. * @param bone The bone to sync to the impostor.
  23717. * @param boneMesh The mesh that the bone is influencing.
  23718. * @param jointPivot The pivot of the joint / bone in local space.
  23719. * @param distToJoint Optional distance from the impostor to the joint.
  23720. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23721. */
  23722. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23723. /**
  23724. * Sync impostor to a bone
  23725. * @param bone The bone that the impostor will be synced to.
  23726. * @param boneMesh The mesh that the bone is influencing.
  23727. * @param jointPivot The pivot of the joint / bone in local space.
  23728. * @param distToJoint Optional distance from the impostor to the joint.
  23729. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23730. * @param boneAxis Optional vector3 axis the bone is aligned with
  23731. */
  23732. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23733. /**
  23734. * No-Imposter type
  23735. */
  23736. static NoImpostor: number;
  23737. /**
  23738. * Sphere-Imposter type
  23739. */
  23740. static SphereImpostor: number;
  23741. /**
  23742. * Box-Imposter type
  23743. */
  23744. static BoxImpostor: number;
  23745. /**
  23746. * Plane-Imposter type
  23747. */
  23748. static PlaneImpostor: number;
  23749. /**
  23750. * Mesh-imposter type
  23751. */
  23752. static MeshImpostor: number;
  23753. /**
  23754. * Capsule-Impostor type (Ammo.js plugin only)
  23755. */
  23756. static CapsuleImpostor: number;
  23757. /**
  23758. * Cylinder-Imposter type
  23759. */
  23760. static CylinderImpostor: number;
  23761. /**
  23762. * Particle-Imposter type
  23763. */
  23764. static ParticleImpostor: number;
  23765. /**
  23766. * Heightmap-Imposter type
  23767. */
  23768. static HeightmapImpostor: number;
  23769. /**
  23770. * ConvexHull-Impostor type (Ammo.js plugin only)
  23771. */
  23772. static ConvexHullImpostor: number;
  23773. /**
  23774. * Custom-Imposter type (Ammo.js plugin only)
  23775. */
  23776. static CustomImpostor: number;
  23777. /**
  23778. * Rope-Imposter type
  23779. */
  23780. static RopeImpostor: number;
  23781. /**
  23782. * Cloth-Imposter type
  23783. */
  23784. static ClothImpostor: number;
  23785. /**
  23786. * Softbody-Imposter type
  23787. */
  23788. static SoftbodyImpostor: number;
  23789. }
  23790. }
  23791. declare module BABYLON {
  23792. /**
  23793. * @hidden
  23794. **/
  23795. export class _CreationDataStorage {
  23796. closePath?: boolean;
  23797. closeArray?: boolean;
  23798. idx: number[];
  23799. dashSize: number;
  23800. gapSize: number;
  23801. path3D: Path3D;
  23802. pathArray: Vector3[][];
  23803. arc: number;
  23804. radius: number;
  23805. cap: number;
  23806. tessellation: number;
  23807. }
  23808. /**
  23809. * @hidden
  23810. **/
  23811. class _InstanceDataStorage {
  23812. visibleInstances: any;
  23813. batchCache: _InstancesBatch;
  23814. instancesBufferSize: number;
  23815. instancesBuffer: Nullable<Buffer>;
  23816. instancesData: Float32Array;
  23817. overridenInstanceCount: number;
  23818. isFrozen: boolean;
  23819. previousBatch: Nullable<_InstancesBatch>;
  23820. hardwareInstancedRendering: boolean;
  23821. sideOrientation: number;
  23822. manualUpdate: boolean;
  23823. }
  23824. /**
  23825. * @hidden
  23826. **/
  23827. export class _InstancesBatch {
  23828. mustReturn: boolean;
  23829. visibleInstances: Nullable<InstancedMesh[]>[];
  23830. renderSelf: boolean[];
  23831. hardwareInstancedRendering: boolean[];
  23832. }
  23833. /**
  23834. * Class used to represent renderable models
  23835. */
  23836. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23837. /**
  23838. * Mesh side orientation : usually the external or front surface
  23839. */
  23840. static readonly FRONTSIDE: number;
  23841. /**
  23842. * Mesh side orientation : usually the internal or back surface
  23843. */
  23844. static readonly BACKSIDE: number;
  23845. /**
  23846. * Mesh side orientation : both internal and external or front and back surfaces
  23847. */
  23848. static readonly DOUBLESIDE: number;
  23849. /**
  23850. * Mesh side orientation : by default, `FRONTSIDE`
  23851. */
  23852. static readonly DEFAULTSIDE: number;
  23853. /**
  23854. * Mesh cap setting : no cap
  23855. */
  23856. static readonly NO_CAP: number;
  23857. /**
  23858. * Mesh cap setting : one cap at the beginning of the mesh
  23859. */
  23860. static readonly CAP_START: number;
  23861. /**
  23862. * Mesh cap setting : one cap at the end of the mesh
  23863. */
  23864. static readonly CAP_END: number;
  23865. /**
  23866. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23867. */
  23868. static readonly CAP_ALL: number;
  23869. /**
  23870. * Mesh pattern setting : no flip or rotate
  23871. */
  23872. static readonly NO_FLIP: number;
  23873. /**
  23874. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23875. */
  23876. static readonly FLIP_TILE: number;
  23877. /**
  23878. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23879. */
  23880. static readonly ROTATE_TILE: number;
  23881. /**
  23882. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23883. */
  23884. static readonly FLIP_ROW: number;
  23885. /**
  23886. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23887. */
  23888. static readonly ROTATE_ROW: number;
  23889. /**
  23890. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23891. */
  23892. static readonly FLIP_N_ROTATE_TILE: number;
  23893. /**
  23894. * Mesh pattern setting : rotate pattern and rotate
  23895. */
  23896. static readonly FLIP_N_ROTATE_ROW: number;
  23897. /**
  23898. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23899. */
  23900. static readonly CENTER: number;
  23901. /**
  23902. * Mesh tile positioning : part tiles on left
  23903. */
  23904. static readonly LEFT: number;
  23905. /**
  23906. * Mesh tile positioning : part tiles on right
  23907. */
  23908. static readonly RIGHT: number;
  23909. /**
  23910. * Mesh tile positioning : part tiles on top
  23911. */
  23912. static readonly TOP: number;
  23913. /**
  23914. * Mesh tile positioning : part tiles on bottom
  23915. */
  23916. static readonly BOTTOM: number;
  23917. /**
  23918. * Gets the default side orientation.
  23919. * @param orientation the orientation to value to attempt to get
  23920. * @returns the default orientation
  23921. * @hidden
  23922. */
  23923. static _GetDefaultSideOrientation(orientation?: number): number;
  23924. private _internalMeshDataInfo;
  23925. /**
  23926. * An event triggered before rendering the mesh
  23927. */
  23928. readonly onBeforeRenderObservable: Observable<Mesh>;
  23929. /**
  23930. * An event triggered before binding the mesh
  23931. */
  23932. readonly onBeforeBindObservable: Observable<Mesh>;
  23933. /**
  23934. * An event triggered after rendering the mesh
  23935. */
  23936. readonly onAfterRenderObservable: Observable<Mesh>;
  23937. /**
  23938. * An event triggered before drawing the mesh
  23939. */
  23940. readonly onBeforeDrawObservable: Observable<Mesh>;
  23941. private _onBeforeDrawObserver;
  23942. /**
  23943. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23944. */
  23945. onBeforeDraw: () => void;
  23946. readonly hasInstances: boolean;
  23947. /**
  23948. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23949. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23950. */
  23951. delayLoadState: number;
  23952. /**
  23953. * Gets the list of instances created from this mesh
  23954. * it is not supposed to be modified manually.
  23955. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23956. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23957. */
  23958. instances: InstancedMesh[];
  23959. /**
  23960. * Gets the file containing delay loading data for this mesh
  23961. */
  23962. delayLoadingFile: string;
  23963. /** @hidden */
  23964. _binaryInfo: any;
  23965. /**
  23966. * User defined function used to change how LOD level selection is done
  23967. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23968. */
  23969. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23970. /**
  23971. * Gets or sets the morph target manager
  23972. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23973. */
  23974. morphTargetManager: Nullable<MorphTargetManager>;
  23975. /** @hidden */
  23976. _creationDataStorage: Nullable<_CreationDataStorage>;
  23977. /** @hidden */
  23978. _geometry: Nullable<Geometry>;
  23979. /** @hidden */
  23980. _delayInfo: Array<string>;
  23981. /** @hidden */
  23982. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23983. /** @hidden */
  23984. _instanceDataStorage: _InstanceDataStorage;
  23985. private _effectiveMaterial;
  23986. /** @hidden */
  23987. _shouldGenerateFlatShading: boolean;
  23988. /** @hidden */
  23989. _originalBuilderSideOrientation: number;
  23990. /**
  23991. * Use this property to change the original side orientation defined at construction time
  23992. */
  23993. overrideMaterialSideOrientation: Nullable<number>;
  23994. /**
  23995. * Gets the source mesh (the one used to clone this one from)
  23996. */
  23997. readonly source: Nullable<Mesh>;
  23998. /**
  23999. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24000. */
  24001. isUnIndexed: boolean;
  24002. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24003. readonly worldMatrixInstancedBuffer: Float32Array;
  24004. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24005. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24006. /**
  24007. * @constructor
  24008. * @param name The value used by scene.getMeshByName() to do a lookup.
  24009. * @param scene The scene to add this mesh to.
  24010. * @param parent The parent of this mesh, if it has one
  24011. * @param source An optional Mesh from which geometry is shared, cloned.
  24012. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24013. * When false, achieved by calling a clone(), also passing False.
  24014. * This will make creation of children, recursive.
  24015. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24016. */
  24017. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24018. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24019. doNotInstantiate: boolean;
  24020. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24021. /**
  24022. * Gets the class name
  24023. * @returns the string "Mesh".
  24024. */
  24025. getClassName(): string;
  24026. /** @hidden */
  24027. readonly _isMesh: boolean;
  24028. /**
  24029. * Returns a description of this mesh
  24030. * @param fullDetails define if full details about this mesh must be used
  24031. * @returns a descriptive string representing this mesh
  24032. */
  24033. toString(fullDetails?: boolean): string;
  24034. /** @hidden */
  24035. _unBindEffect(): void;
  24036. /**
  24037. * Gets a boolean indicating if this mesh has LOD
  24038. */
  24039. readonly hasLODLevels: boolean;
  24040. /**
  24041. * Gets the list of MeshLODLevel associated with the current mesh
  24042. * @returns an array of MeshLODLevel
  24043. */
  24044. getLODLevels(): MeshLODLevel[];
  24045. private _sortLODLevels;
  24046. /**
  24047. * Add a mesh as LOD level triggered at the given distance.
  24048. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24049. * @param distance The distance from the center of the object to show this level
  24050. * @param mesh The mesh to be added as LOD level (can be null)
  24051. * @return This mesh (for chaining)
  24052. */
  24053. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24054. /**
  24055. * Returns the LOD level mesh at the passed distance or null if not found.
  24056. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24057. * @param distance The distance from the center of the object to show this level
  24058. * @returns a Mesh or `null`
  24059. */
  24060. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24061. /**
  24062. * Remove a mesh from the LOD array
  24063. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24064. * @param mesh defines the mesh to be removed
  24065. * @return This mesh (for chaining)
  24066. */
  24067. removeLODLevel(mesh: Mesh): Mesh;
  24068. /**
  24069. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24070. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24071. * @param camera defines the camera to use to compute distance
  24072. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24073. * @return This mesh (for chaining)
  24074. */
  24075. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24076. /**
  24077. * Gets the mesh internal Geometry object
  24078. */
  24079. readonly geometry: Nullable<Geometry>;
  24080. /**
  24081. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24082. * @returns the total number of vertices
  24083. */
  24084. getTotalVertices(): number;
  24085. /**
  24086. * Returns the content of an associated vertex buffer
  24087. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24088. * - VertexBuffer.PositionKind
  24089. * - VertexBuffer.UVKind
  24090. * - VertexBuffer.UV2Kind
  24091. * - VertexBuffer.UV3Kind
  24092. * - VertexBuffer.UV4Kind
  24093. * - VertexBuffer.UV5Kind
  24094. * - VertexBuffer.UV6Kind
  24095. * - VertexBuffer.ColorKind
  24096. * - VertexBuffer.MatricesIndicesKind
  24097. * - VertexBuffer.MatricesIndicesExtraKind
  24098. * - VertexBuffer.MatricesWeightsKind
  24099. * - VertexBuffer.MatricesWeightsExtraKind
  24100. * @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
  24101. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24102. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24103. */
  24104. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24105. /**
  24106. * Returns the mesh VertexBuffer object from the requested `kind`
  24107. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24108. * - VertexBuffer.PositionKind
  24109. * - VertexBuffer.NormalKind
  24110. * - VertexBuffer.UVKind
  24111. * - VertexBuffer.UV2Kind
  24112. * - VertexBuffer.UV3Kind
  24113. * - VertexBuffer.UV4Kind
  24114. * - VertexBuffer.UV5Kind
  24115. * - VertexBuffer.UV6Kind
  24116. * - VertexBuffer.ColorKind
  24117. * - VertexBuffer.MatricesIndicesKind
  24118. * - VertexBuffer.MatricesIndicesExtraKind
  24119. * - VertexBuffer.MatricesWeightsKind
  24120. * - VertexBuffer.MatricesWeightsExtraKind
  24121. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24122. */
  24123. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24124. /**
  24125. * Tests if a specific vertex buffer is associated with this mesh
  24126. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24127. * - VertexBuffer.PositionKind
  24128. * - VertexBuffer.NormalKind
  24129. * - VertexBuffer.UVKind
  24130. * - VertexBuffer.UV2Kind
  24131. * - VertexBuffer.UV3Kind
  24132. * - VertexBuffer.UV4Kind
  24133. * - VertexBuffer.UV5Kind
  24134. * - VertexBuffer.UV6Kind
  24135. * - VertexBuffer.ColorKind
  24136. * - VertexBuffer.MatricesIndicesKind
  24137. * - VertexBuffer.MatricesIndicesExtraKind
  24138. * - VertexBuffer.MatricesWeightsKind
  24139. * - VertexBuffer.MatricesWeightsExtraKind
  24140. * @returns a boolean
  24141. */
  24142. isVerticesDataPresent(kind: string): boolean;
  24143. /**
  24144. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24145. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24146. * - VertexBuffer.PositionKind
  24147. * - VertexBuffer.UVKind
  24148. * - VertexBuffer.UV2Kind
  24149. * - VertexBuffer.UV3Kind
  24150. * - VertexBuffer.UV4Kind
  24151. * - VertexBuffer.UV5Kind
  24152. * - VertexBuffer.UV6Kind
  24153. * - VertexBuffer.ColorKind
  24154. * - VertexBuffer.MatricesIndicesKind
  24155. * - VertexBuffer.MatricesIndicesExtraKind
  24156. * - VertexBuffer.MatricesWeightsKind
  24157. * - VertexBuffer.MatricesWeightsExtraKind
  24158. * @returns a boolean
  24159. */
  24160. isVertexBufferUpdatable(kind: string): boolean;
  24161. /**
  24162. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24163. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24164. * - VertexBuffer.PositionKind
  24165. * - VertexBuffer.NormalKind
  24166. * - VertexBuffer.UVKind
  24167. * - VertexBuffer.UV2Kind
  24168. * - VertexBuffer.UV3Kind
  24169. * - VertexBuffer.UV4Kind
  24170. * - VertexBuffer.UV5Kind
  24171. * - VertexBuffer.UV6Kind
  24172. * - VertexBuffer.ColorKind
  24173. * - VertexBuffer.MatricesIndicesKind
  24174. * - VertexBuffer.MatricesIndicesExtraKind
  24175. * - VertexBuffer.MatricesWeightsKind
  24176. * - VertexBuffer.MatricesWeightsExtraKind
  24177. * @returns an array of strings
  24178. */
  24179. getVerticesDataKinds(): string[];
  24180. /**
  24181. * Returns a positive integer : the total number of indices in this mesh geometry.
  24182. * @returns the numner of indices or zero if the mesh has no geometry.
  24183. */
  24184. getTotalIndices(): number;
  24185. /**
  24186. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24187. * @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.
  24188. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24189. * @returns the indices array or an empty array if the mesh has no geometry
  24190. */
  24191. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24192. readonly isBlocked: boolean;
  24193. /**
  24194. * Determine if the current mesh is ready to be rendered
  24195. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24196. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24197. * @returns true if all associated assets are ready (material, textures, shaders)
  24198. */
  24199. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24200. /**
  24201. * 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.
  24202. */
  24203. readonly areNormalsFrozen: boolean;
  24204. /**
  24205. * 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.
  24206. * @returns the current mesh
  24207. */
  24208. freezeNormals(): Mesh;
  24209. /**
  24210. * 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
  24211. * @returns the current mesh
  24212. */
  24213. unfreezeNormals(): Mesh;
  24214. /**
  24215. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24216. */
  24217. overridenInstanceCount: number;
  24218. /** @hidden */
  24219. _preActivate(): Mesh;
  24220. /** @hidden */
  24221. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24222. /** @hidden */
  24223. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24224. /**
  24225. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24226. * This means the mesh underlying bounding box and sphere are recomputed.
  24227. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24228. * @returns the current mesh
  24229. */
  24230. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24231. /** @hidden */
  24232. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24233. /**
  24234. * This function will subdivide the mesh into multiple submeshes
  24235. * @param count defines the expected number of submeshes
  24236. */
  24237. subdivide(count: number): void;
  24238. /**
  24239. * Copy a FloatArray into a specific associated vertex buffer
  24240. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24241. * - VertexBuffer.PositionKind
  24242. * - VertexBuffer.UVKind
  24243. * - VertexBuffer.UV2Kind
  24244. * - VertexBuffer.UV3Kind
  24245. * - VertexBuffer.UV4Kind
  24246. * - VertexBuffer.UV5Kind
  24247. * - VertexBuffer.UV6Kind
  24248. * - VertexBuffer.ColorKind
  24249. * - VertexBuffer.MatricesIndicesKind
  24250. * - VertexBuffer.MatricesIndicesExtraKind
  24251. * - VertexBuffer.MatricesWeightsKind
  24252. * - VertexBuffer.MatricesWeightsExtraKind
  24253. * @param data defines the data source
  24254. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24255. * @param stride defines the data stride size (can be null)
  24256. * @returns the current mesh
  24257. */
  24258. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24259. /**
  24260. * Delete a vertex buffer associated with this mesh
  24261. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24262. * - VertexBuffer.PositionKind
  24263. * - VertexBuffer.UVKind
  24264. * - VertexBuffer.UV2Kind
  24265. * - VertexBuffer.UV3Kind
  24266. * - VertexBuffer.UV4Kind
  24267. * - VertexBuffer.UV5Kind
  24268. * - VertexBuffer.UV6Kind
  24269. * - VertexBuffer.ColorKind
  24270. * - VertexBuffer.MatricesIndicesKind
  24271. * - VertexBuffer.MatricesIndicesExtraKind
  24272. * - VertexBuffer.MatricesWeightsKind
  24273. * - VertexBuffer.MatricesWeightsExtraKind
  24274. */
  24275. removeVerticesData(kind: string): void;
  24276. /**
  24277. * Flags an associated vertex buffer as updatable
  24278. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24279. * - VertexBuffer.PositionKind
  24280. * - VertexBuffer.UVKind
  24281. * - VertexBuffer.UV2Kind
  24282. * - VertexBuffer.UV3Kind
  24283. * - VertexBuffer.UV4Kind
  24284. * - VertexBuffer.UV5Kind
  24285. * - VertexBuffer.UV6Kind
  24286. * - VertexBuffer.ColorKind
  24287. * - VertexBuffer.MatricesIndicesKind
  24288. * - VertexBuffer.MatricesIndicesExtraKind
  24289. * - VertexBuffer.MatricesWeightsKind
  24290. * - VertexBuffer.MatricesWeightsExtraKind
  24291. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24292. */
  24293. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24294. /**
  24295. * Sets the mesh global Vertex Buffer
  24296. * @param buffer defines the buffer to use
  24297. * @returns the current mesh
  24298. */
  24299. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24300. /**
  24301. * Update a specific associated vertex buffer
  24302. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24303. * - VertexBuffer.PositionKind
  24304. * - VertexBuffer.UVKind
  24305. * - VertexBuffer.UV2Kind
  24306. * - VertexBuffer.UV3Kind
  24307. * - VertexBuffer.UV4Kind
  24308. * - VertexBuffer.UV5Kind
  24309. * - VertexBuffer.UV6Kind
  24310. * - VertexBuffer.ColorKind
  24311. * - VertexBuffer.MatricesIndicesKind
  24312. * - VertexBuffer.MatricesIndicesExtraKind
  24313. * - VertexBuffer.MatricesWeightsKind
  24314. * - VertexBuffer.MatricesWeightsExtraKind
  24315. * @param data defines the data source
  24316. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24317. * @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)
  24318. * @returns the current mesh
  24319. */
  24320. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24321. /**
  24322. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24323. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24324. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24325. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24326. * @returns the current mesh
  24327. */
  24328. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24329. /**
  24330. * Creates a un-shared specific occurence of the geometry for the mesh.
  24331. * @returns the current mesh
  24332. */
  24333. makeGeometryUnique(): Mesh;
  24334. /**
  24335. * Set the index buffer of this mesh
  24336. * @param indices defines the source data
  24337. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24338. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24339. * @returns the current mesh
  24340. */
  24341. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24342. /**
  24343. * Update the current index buffer
  24344. * @param indices defines the source data
  24345. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24346. * @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)
  24347. * @returns the current mesh
  24348. */
  24349. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24350. /**
  24351. * Invert the geometry to move from a right handed system to a left handed one.
  24352. * @returns the current mesh
  24353. */
  24354. toLeftHanded(): Mesh;
  24355. /** @hidden */
  24356. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24357. /** @hidden */
  24358. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24359. /**
  24360. * Registers for this mesh a javascript function called just before the rendering process
  24361. * @param func defines the function to call before rendering this mesh
  24362. * @returns the current mesh
  24363. */
  24364. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24365. /**
  24366. * Disposes a previously registered javascript function called before the rendering
  24367. * @param func defines the function to remove
  24368. * @returns the current mesh
  24369. */
  24370. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24371. /**
  24372. * Registers for this mesh a javascript function called just after the rendering is complete
  24373. * @param func defines the function to call after rendering this mesh
  24374. * @returns the current mesh
  24375. */
  24376. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24377. /**
  24378. * Disposes a previously registered javascript function called after the rendering.
  24379. * @param func defines the function to remove
  24380. * @returns the current mesh
  24381. */
  24382. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24383. /** @hidden */
  24384. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24385. /** @hidden */
  24386. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24387. /** @hidden */
  24388. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24389. /** @hidden */
  24390. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24391. /** @hidden */
  24392. _rebuild(): void;
  24393. /** @hidden */
  24394. _freeze(): void;
  24395. /** @hidden */
  24396. _unFreeze(): void;
  24397. /**
  24398. * 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
  24399. * @param subMesh defines the subMesh to render
  24400. * @param enableAlphaMode defines if alpha mode can be changed
  24401. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24402. * @returns the current mesh
  24403. */
  24404. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24405. private _onBeforeDraw;
  24406. /**
  24407. * Renormalize the mesh and patch it up if there are no weights
  24408. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24409. * However in the case of zero weights then we set just a single influence to 1.
  24410. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24411. */
  24412. cleanMatrixWeights(): void;
  24413. private normalizeSkinFourWeights;
  24414. private normalizeSkinWeightsAndExtra;
  24415. /**
  24416. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24417. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24418. * the user know there was an issue with importing the mesh
  24419. * @returns a validation object with skinned, valid and report string
  24420. */
  24421. validateSkinning(): {
  24422. skinned: boolean;
  24423. valid: boolean;
  24424. report: string;
  24425. };
  24426. /** @hidden */
  24427. _checkDelayState(): Mesh;
  24428. private _queueLoad;
  24429. /**
  24430. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24431. * A mesh is in the frustum if its bounding box intersects the frustum
  24432. * @param frustumPlanes defines the frustum to test
  24433. * @returns true if the mesh is in the frustum planes
  24434. */
  24435. isInFrustum(frustumPlanes: Plane[]): boolean;
  24436. /**
  24437. * Sets the mesh material by the material or multiMaterial `id` property
  24438. * @param id is a string identifying the material or the multiMaterial
  24439. * @returns the current mesh
  24440. */
  24441. setMaterialByID(id: string): Mesh;
  24442. /**
  24443. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24444. * @returns an array of IAnimatable
  24445. */
  24446. getAnimatables(): IAnimatable[];
  24447. /**
  24448. * Modifies the mesh geometry according to the passed transformation matrix.
  24449. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24450. * The mesh normals are modified using the same transformation.
  24451. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24452. * @param transform defines the transform matrix to use
  24453. * @see http://doc.babylonjs.com/resources/baking_transformations
  24454. * @returns the current mesh
  24455. */
  24456. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24457. /**
  24458. * Modifies the mesh geometry according to its own current World Matrix.
  24459. * The mesh World Matrix is then reset.
  24460. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24461. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24462. * @see http://doc.babylonjs.com/resources/baking_transformations
  24463. * @returns the current mesh
  24464. */
  24465. bakeCurrentTransformIntoVertices(): Mesh;
  24466. /** @hidden */
  24467. readonly _positions: Nullable<Vector3[]>;
  24468. /** @hidden */
  24469. _resetPointsArrayCache(): Mesh;
  24470. /** @hidden */
  24471. _generatePointsArray(): boolean;
  24472. /**
  24473. * Returns a new Mesh object generated from the current mesh properties.
  24474. * This method must not get confused with createInstance()
  24475. * @param name is a string, the name given to the new mesh
  24476. * @param newParent can be any Node object (default `null`)
  24477. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24478. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24479. * @returns a new mesh
  24480. */
  24481. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24482. /**
  24483. * Releases resources associated with this mesh.
  24484. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24485. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24486. */
  24487. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24488. /** @hidden */
  24489. _disposeInstanceSpecificData(): void;
  24490. /**
  24491. * Modifies the mesh geometry according to a displacement map.
  24492. * 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.
  24493. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24494. * @param url is a string, the URL from the image file is to be downloaded.
  24495. * @param minHeight is the lower limit of the displacement.
  24496. * @param maxHeight is the upper limit of the displacement.
  24497. * @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.
  24498. * @param uvOffset is an optional vector2 used to offset UV.
  24499. * @param uvScale is an optional vector2 used to scale UV.
  24500. * @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.
  24501. * @returns the Mesh.
  24502. */
  24503. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24504. /**
  24505. * Modifies the mesh geometry according to a displacementMap buffer.
  24506. * 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.
  24507. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24508. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24509. * @param heightMapWidth is the width of the buffer image.
  24510. * @param heightMapHeight is the height of the buffer image.
  24511. * @param minHeight is the lower limit of the displacement.
  24512. * @param maxHeight is the upper limit of the displacement.
  24513. * @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.
  24514. * @param uvOffset is an optional vector2 used to offset UV.
  24515. * @param uvScale is an optional vector2 used to scale UV.
  24516. * @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.
  24517. * @returns the Mesh.
  24518. */
  24519. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24520. /**
  24521. * Modify the mesh to get a flat shading rendering.
  24522. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24523. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24524. * @returns current mesh
  24525. */
  24526. convertToFlatShadedMesh(): Mesh;
  24527. /**
  24528. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24529. * In other words, more vertices, no more indices and a single bigger VBO.
  24530. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24531. * @returns current mesh
  24532. */
  24533. convertToUnIndexedMesh(): Mesh;
  24534. /**
  24535. * Inverses facet orientations.
  24536. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24537. * @param flipNormals will also inverts the normals
  24538. * @returns current mesh
  24539. */
  24540. flipFaces(flipNormals?: boolean): Mesh;
  24541. /**
  24542. * Increase the number of facets and hence vertices in a mesh
  24543. * Vertex normals are interpolated from existing vertex normals
  24544. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24545. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24546. */
  24547. increaseVertices(numberPerEdge: number): void;
  24548. /**
  24549. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24550. * This will undo any application of covertToFlatShadedMesh
  24551. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24552. */
  24553. forceSharedVertices(): void;
  24554. /** @hidden */
  24555. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24556. /** @hidden */
  24557. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24558. /**
  24559. * Creates a new InstancedMesh object from the mesh model.
  24560. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24561. * @param name defines the name of the new instance
  24562. * @returns a new InstancedMesh
  24563. */
  24564. createInstance(name: string): InstancedMesh;
  24565. /**
  24566. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24567. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24568. * @returns the current mesh
  24569. */
  24570. synchronizeInstances(): Mesh;
  24571. /**
  24572. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24573. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24574. * This should be used together with the simplification to avoid disappearing triangles.
  24575. * @param successCallback an optional success callback to be called after the optimization finished.
  24576. * @returns the current mesh
  24577. */
  24578. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24579. /**
  24580. * Serialize current mesh
  24581. * @param serializationObject defines the object which will receive the serialization data
  24582. */
  24583. serialize(serializationObject: any): void;
  24584. /** @hidden */
  24585. _syncGeometryWithMorphTargetManager(): void;
  24586. /** @hidden */
  24587. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24588. /**
  24589. * Returns a new Mesh object parsed from the source provided.
  24590. * @param parsedMesh is the source
  24591. * @param scene defines the hosting scene
  24592. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24593. * @returns a new Mesh
  24594. */
  24595. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24596. /**
  24597. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24598. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24599. * @param name defines the name of the mesh to create
  24600. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24601. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24602. * @param closePath creates a seam between the first and the last points of each path of the path array
  24603. * @param offset is taken in account only if the `pathArray` is containing a single path
  24604. * @param scene defines the hosting scene
  24605. * @param updatable defines if the mesh must be flagged as updatable
  24606. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24607. * @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)
  24608. * @returns a new Mesh
  24609. */
  24610. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24611. /**
  24612. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24613. * @param name defines the name of the mesh to create
  24614. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24615. * @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
  24616. * @param scene defines the hosting scene
  24617. * @param updatable defines if the mesh must be flagged as updatable
  24618. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24619. * @returns a new Mesh
  24620. */
  24621. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24622. /**
  24623. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24624. * @param name defines the name of the mesh to create
  24625. * @param size sets the size (float) of each box side (default 1)
  24626. * @param scene defines the hosting scene
  24627. * @param updatable defines if the mesh must be flagged as updatable
  24628. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24629. * @returns a new Mesh
  24630. */
  24631. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24632. /**
  24633. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24634. * @param name defines the name of the mesh to create
  24635. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24636. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24637. * @param scene defines the hosting scene
  24638. * @param updatable defines if the mesh must be flagged as updatable
  24639. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24640. * @returns a new Mesh
  24641. */
  24642. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24643. /**
  24644. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24645. * @param name defines the name of the mesh to create
  24646. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24647. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24648. * @param scene defines the hosting scene
  24649. * @returns a new Mesh
  24650. */
  24651. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24652. /**
  24653. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24654. * @param name defines the name of the mesh to create
  24655. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24656. * @param diameterTop set the top cap diameter (floats, default 1)
  24657. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24658. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24659. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24660. * @param scene defines the hosting scene
  24661. * @param updatable defines if the mesh must be flagged as updatable
  24662. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24663. * @returns a new Mesh
  24664. */
  24665. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24666. /**
  24667. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24668. * @param name defines the name of the mesh to create
  24669. * @param diameter sets the diameter size (float) of the torus (default 1)
  24670. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24671. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24672. * @param scene defines the hosting scene
  24673. * @param updatable defines if the mesh must be flagged as updatable
  24674. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24675. * @returns a new Mesh
  24676. */
  24677. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24678. /**
  24679. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24680. * @param name defines the name of the mesh to create
  24681. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24682. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24683. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24684. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24685. * @param p the number of windings on X axis (positive integers, default 2)
  24686. * @param q the number of windings on Y axis (positive integers, default 3)
  24687. * @param scene defines the hosting scene
  24688. * @param updatable defines if the mesh must be flagged as updatable
  24689. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24690. * @returns a new Mesh
  24691. */
  24692. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24693. /**
  24694. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24695. * @param name defines the name of the mesh to create
  24696. * @param points is an array successive Vector3
  24697. * @param scene defines the hosting scene
  24698. * @param updatable defines if the mesh must be flagged as updatable
  24699. * @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).
  24700. * @returns a new Mesh
  24701. */
  24702. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24703. /**
  24704. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24705. * @param name defines the name of the mesh to create
  24706. * @param points is an array successive Vector3
  24707. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24708. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24709. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24710. * @param scene defines the hosting scene
  24711. * @param updatable defines if the mesh must be flagged as updatable
  24712. * @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)
  24713. * @returns a new Mesh
  24714. */
  24715. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24716. /**
  24717. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24718. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24719. * 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.
  24720. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24721. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24722. * Remember you can only change the shape positions, not their number when updating a polygon.
  24723. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24724. * @param name defines the name of the mesh to create
  24725. * @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
  24726. * @param scene defines the hosting scene
  24727. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24728. * @param updatable defines if the mesh must be flagged as updatable
  24729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24730. * @param earcutInjection can be used to inject your own earcut reference
  24731. * @returns a new Mesh
  24732. */
  24733. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24734. /**
  24735. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24736. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24737. * @param name defines the name of the mesh to create
  24738. * @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
  24739. * @param depth defines the height of extrusion
  24740. * @param scene defines the hosting scene
  24741. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24742. * @param updatable defines if the mesh must be flagged as updatable
  24743. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24744. * @param earcutInjection can be used to inject your own earcut reference
  24745. * @returns a new Mesh
  24746. */
  24747. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24748. /**
  24749. * Creates an extruded shape mesh.
  24750. * 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
  24751. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24752. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24753. * @param name defines the name of the mesh to create
  24754. * @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
  24755. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24756. * @param scale is the value to scale the shape
  24757. * @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
  24758. * @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
  24759. * @param scene defines the hosting scene
  24760. * @param updatable defines if the mesh must be flagged as updatable
  24761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24762. * @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)
  24763. * @returns a new Mesh
  24764. */
  24765. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24766. /**
  24767. * Creates an custom extruded shape mesh.
  24768. * The custom extrusion is a parametric shape.
  24769. * It has no predefined shape. Its final shape will depend on the input parameters.
  24770. * Please consider using the same method from the MeshBuilder class instead
  24771. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24772. * @param name defines the name of the mesh to create
  24773. * @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
  24774. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24775. * @param scaleFunction is a custom Javascript function called on each path point
  24776. * @param rotationFunction is a custom Javascript function called on each path point
  24777. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24778. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24779. * @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
  24780. * @param scene defines the hosting scene
  24781. * @param updatable defines if the mesh must be flagged as updatable
  24782. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24783. * @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)
  24784. * @returns a new Mesh
  24785. */
  24786. 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;
  24787. /**
  24788. * Creates lathe mesh.
  24789. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24790. * Please consider using the same method from the MeshBuilder class instead
  24791. * @param name defines the name of the mesh to create
  24792. * @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
  24793. * @param radius is the radius value of the lathe
  24794. * @param tessellation is the side number of the lathe.
  24795. * @param scene defines the hosting scene
  24796. * @param updatable defines if the mesh must be flagged as updatable
  24797. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24798. * @returns a new Mesh
  24799. */
  24800. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24801. /**
  24802. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24803. * @param name defines the name of the mesh to create
  24804. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24805. * @param scene defines the hosting scene
  24806. * @param updatable defines if the mesh must be flagged as updatable
  24807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24808. * @returns a new Mesh
  24809. */
  24810. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24811. /**
  24812. * Creates a ground mesh.
  24813. * Please consider using the same method from the MeshBuilder class instead
  24814. * @param name defines the name of the mesh to create
  24815. * @param width set the width of the ground
  24816. * @param height set the height of the ground
  24817. * @param subdivisions sets the number of subdivisions per side
  24818. * @param scene defines the hosting scene
  24819. * @param updatable defines if the mesh must be flagged as updatable
  24820. * @returns a new Mesh
  24821. */
  24822. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24823. /**
  24824. * Creates a tiled ground mesh.
  24825. * Please consider using the same method from the MeshBuilder class instead
  24826. * @param name defines the name of the mesh to create
  24827. * @param xmin set the ground minimum X coordinate
  24828. * @param zmin set the ground minimum Y coordinate
  24829. * @param xmax set the ground maximum X coordinate
  24830. * @param zmax set the ground maximum Z coordinate
  24831. * @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
  24832. * @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
  24833. * @param scene defines the hosting scene
  24834. * @param updatable defines if the mesh must be flagged as updatable
  24835. * @returns a new Mesh
  24836. */
  24837. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24838. w: number;
  24839. h: number;
  24840. }, precision: {
  24841. w: number;
  24842. h: number;
  24843. }, scene: Scene, updatable?: boolean): Mesh;
  24844. /**
  24845. * Creates a ground mesh from a height map.
  24846. * Please consider using the same method from the MeshBuilder class instead
  24847. * @see http://doc.babylonjs.com/babylon101/height_map
  24848. * @param name defines the name of the mesh to create
  24849. * @param url sets the URL of the height map image resource
  24850. * @param width set the ground width size
  24851. * @param height set the ground height size
  24852. * @param subdivisions sets the number of subdivision per side
  24853. * @param minHeight is the minimum altitude on the ground
  24854. * @param maxHeight is the maximum altitude on the ground
  24855. * @param scene defines the hosting scene
  24856. * @param updatable defines if the mesh must be flagged as updatable
  24857. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24858. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24859. * @returns a new Mesh
  24860. */
  24861. 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;
  24862. /**
  24863. * Creates a tube mesh.
  24864. * The tube is a parametric shape.
  24865. * It has no predefined shape. Its final shape will depend on the input parameters.
  24866. * Please consider using the same method from the MeshBuilder class instead
  24867. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24868. * @param name defines the name of the mesh to create
  24869. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24870. * @param radius sets the tube radius size
  24871. * @param tessellation is the number of sides on the tubular surface
  24872. * @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
  24873. * @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
  24874. * @param scene defines the hosting scene
  24875. * @param updatable defines if the mesh must be flagged as updatable
  24876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24877. * @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)
  24878. * @returns a new Mesh
  24879. */
  24880. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24881. (i: number, distance: number): number;
  24882. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24883. /**
  24884. * Creates a polyhedron mesh.
  24885. * Please consider using the same method from the MeshBuilder class instead.
  24886. * * 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
  24887. * * The parameter `size` (positive float, default 1) sets the polygon size
  24888. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24889. * * 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`
  24890. * * 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
  24891. * * 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)`)
  24892. * * 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
  24893. * * 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
  24894. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24895. * * 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
  24896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24897. * @param name defines the name of the mesh to create
  24898. * @param options defines the options used to create the mesh
  24899. * @param scene defines the hosting scene
  24900. * @returns a new Mesh
  24901. */
  24902. static CreatePolyhedron(name: string, options: {
  24903. type?: number;
  24904. size?: number;
  24905. sizeX?: number;
  24906. sizeY?: number;
  24907. sizeZ?: number;
  24908. custom?: any;
  24909. faceUV?: Vector4[];
  24910. faceColors?: Color4[];
  24911. updatable?: boolean;
  24912. sideOrientation?: number;
  24913. }, scene: Scene): Mesh;
  24914. /**
  24915. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24916. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24917. * * 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`)
  24918. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24919. * * 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
  24920. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24921. * * 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
  24922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24923. * @param name defines the name of the mesh
  24924. * @param options defines the options used to create the mesh
  24925. * @param scene defines the hosting scene
  24926. * @returns a new Mesh
  24927. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24928. */
  24929. static CreateIcoSphere(name: string, options: {
  24930. radius?: number;
  24931. flat?: boolean;
  24932. subdivisions?: number;
  24933. sideOrientation?: number;
  24934. updatable?: boolean;
  24935. }, scene: Scene): Mesh;
  24936. /**
  24937. * Creates a decal mesh.
  24938. * Please consider using the same method from the MeshBuilder class instead.
  24939. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24940. * @param name defines the name of the mesh
  24941. * @param sourceMesh defines the mesh receiving the decal
  24942. * @param position sets the position of the decal in world coordinates
  24943. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24944. * @param size sets the decal scaling
  24945. * @param angle sets the angle to rotate the decal
  24946. * @returns a new Mesh
  24947. */
  24948. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24949. /**
  24950. * Prepare internal position array for software CPU skinning
  24951. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24952. */
  24953. setPositionsForCPUSkinning(): Float32Array;
  24954. /**
  24955. * Prepare internal normal array for software CPU skinning
  24956. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24957. */
  24958. setNormalsForCPUSkinning(): Float32Array;
  24959. /**
  24960. * Updates the vertex buffer by applying transformation from the bones
  24961. * @param skeleton defines the skeleton to apply to current mesh
  24962. * @returns the current mesh
  24963. */
  24964. applySkeleton(skeleton: Skeleton): Mesh;
  24965. /**
  24966. * 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
  24967. * @param meshes defines the list of meshes to scan
  24968. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24969. */
  24970. static MinMax(meshes: AbstractMesh[]): {
  24971. min: Vector3;
  24972. max: Vector3;
  24973. };
  24974. /**
  24975. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24976. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24977. * @returns a vector3
  24978. */
  24979. static Center(meshesOrMinMaxVector: {
  24980. min: Vector3;
  24981. max: Vector3;
  24982. } | AbstractMesh[]): Vector3;
  24983. /**
  24984. * Merge the array of meshes into a single mesh for performance reasons.
  24985. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24986. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24987. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24988. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24989. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24990. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24991. * @returns a new mesh
  24992. */
  24993. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24994. /** @hidden */
  24995. addInstance(instance: InstancedMesh): void;
  24996. /** @hidden */
  24997. removeInstance(instance: InstancedMesh): void;
  24998. }
  24999. }
  25000. declare module BABYLON {
  25001. /**
  25002. * This is the base class of all the camera used in the application.
  25003. * @see http://doc.babylonjs.com/features/cameras
  25004. */
  25005. export class Camera extends Node {
  25006. /** @hidden */
  25007. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25008. /**
  25009. * This is the default projection mode used by the cameras.
  25010. * It helps recreating a feeling of perspective and better appreciate depth.
  25011. * This is the best way to simulate real life cameras.
  25012. */
  25013. static readonly PERSPECTIVE_CAMERA: number;
  25014. /**
  25015. * This helps creating camera with an orthographic mode.
  25016. * 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.
  25017. */
  25018. static readonly ORTHOGRAPHIC_CAMERA: number;
  25019. /**
  25020. * This is the default FOV mode for perspective cameras.
  25021. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25022. */
  25023. static readonly FOVMODE_VERTICAL_FIXED: number;
  25024. /**
  25025. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25026. */
  25027. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25028. /**
  25029. * This specifies ther is no need for a camera rig.
  25030. * Basically only one eye is rendered corresponding to the camera.
  25031. */
  25032. static readonly RIG_MODE_NONE: number;
  25033. /**
  25034. * Simulates a camera Rig with one blue eye and one red eye.
  25035. * This can be use with 3d blue and red glasses.
  25036. */
  25037. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25038. /**
  25039. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25040. */
  25041. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25042. /**
  25043. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25044. */
  25045. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25046. /**
  25047. * Defines that both eyes of the camera will be rendered over under each other.
  25048. */
  25049. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25050. /**
  25051. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25052. */
  25053. static readonly RIG_MODE_VR: number;
  25054. /**
  25055. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25056. */
  25057. static readonly RIG_MODE_WEBVR: number;
  25058. /**
  25059. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25060. */
  25061. static readonly RIG_MODE_CUSTOM: number;
  25062. /**
  25063. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25064. */
  25065. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25066. /**
  25067. * Define the input manager associated with the camera.
  25068. */
  25069. inputs: CameraInputsManager<Camera>;
  25070. /** @hidden */
  25071. _position: Vector3;
  25072. /**
  25073. * Define the current local position of the camera in the scene
  25074. */
  25075. position: Vector3;
  25076. /**
  25077. * The vector the camera should consider as up.
  25078. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25079. */
  25080. upVector: Vector3;
  25081. /**
  25082. * Define the current limit on the left side for an orthographic camera
  25083. * In scene unit
  25084. */
  25085. orthoLeft: Nullable<number>;
  25086. /**
  25087. * Define the current limit on the right side for an orthographic camera
  25088. * In scene unit
  25089. */
  25090. orthoRight: Nullable<number>;
  25091. /**
  25092. * Define the current limit on the bottom side for an orthographic camera
  25093. * In scene unit
  25094. */
  25095. orthoBottom: Nullable<number>;
  25096. /**
  25097. * Define the current limit on the top side for an orthographic camera
  25098. * In scene unit
  25099. */
  25100. orthoTop: Nullable<number>;
  25101. /**
  25102. * Field Of View is set in Radians. (default is 0.8)
  25103. */
  25104. fov: number;
  25105. /**
  25106. * Define the minimum distance the camera can see from.
  25107. * This is important to note that the depth buffer are not infinite and the closer it starts
  25108. * the more your scene might encounter depth fighting issue.
  25109. */
  25110. minZ: number;
  25111. /**
  25112. * Define the maximum distance the camera can see to.
  25113. * This is important to note that the depth buffer are not infinite and the further it end
  25114. * the more your scene might encounter depth fighting issue.
  25115. */
  25116. maxZ: number;
  25117. /**
  25118. * Define the default inertia of the camera.
  25119. * This helps giving a smooth feeling to the camera movement.
  25120. */
  25121. inertia: number;
  25122. /**
  25123. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25124. */
  25125. mode: number;
  25126. /**
  25127. * Define wether the camera is intermediate.
  25128. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25129. */
  25130. isIntermediate: boolean;
  25131. /**
  25132. * Define the viewport of the camera.
  25133. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25134. */
  25135. viewport: Viewport;
  25136. /**
  25137. * Restricts the camera to viewing objects with the same layerMask.
  25138. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25139. */
  25140. layerMask: number;
  25141. /**
  25142. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25143. */
  25144. fovMode: number;
  25145. /**
  25146. * Rig mode of the camera.
  25147. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25148. * This is normally controlled byt the camera themselves as internal use.
  25149. */
  25150. cameraRigMode: number;
  25151. /**
  25152. * Defines the distance between both "eyes" in case of a RIG
  25153. */
  25154. interaxialDistance: number;
  25155. /**
  25156. * Defines if stereoscopic rendering is done side by side or over under.
  25157. */
  25158. isStereoscopicSideBySide: boolean;
  25159. /**
  25160. * 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
  25161. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25162. * else in the scene. (Eg. security camera)
  25163. *
  25164. * 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)
  25165. */
  25166. customRenderTargets: RenderTargetTexture[];
  25167. /**
  25168. * When set, the camera will render to this render target instead of the default canvas
  25169. *
  25170. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25171. */
  25172. outputRenderTarget: Nullable<RenderTargetTexture>;
  25173. /**
  25174. * Observable triggered when the camera view matrix has changed.
  25175. */
  25176. onViewMatrixChangedObservable: Observable<Camera>;
  25177. /**
  25178. * Observable triggered when the camera Projection matrix has changed.
  25179. */
  25180. onProjectionMatrixChangedObservable: Observable<Camera>;
  25181. /**
  25182. * Observable triggered when the inputs have been processed.
  25183. */
  25184. onAfterCheckInputsObservable: Observable<Camera>;
  25185. /**
  25186. * Observable triggered when reset has been called and applied to the camera.
  25187. */
  25188. onRestoreStateObservable: Observable<Camera>;
  25189. /** @hidden */
  25190. _cameraRigParams: any;
  25191. /** @hidden */
  25192. _rigCameras: Camera[];
  25193. /** @hidden */
  25194. _rigPostProcess: Nullable<PostProcess>;
  25195. protected _webvrViewMatrix: Matrix;
  25196. /** @hidden */
  25197. _skipRendering: boolean;
  25198. /** @hidden */
  25199. _projectionMatrix: Matrix;
  25200. /** @hidden */
  25201. _postProcesses: Nullable<PostProcess>[];
  25202. /** @hidden */
  25203. _activeMeshes: SmartArray<AbstractMesh>;
  25204. protected _globalPosition: Vector3;
  25205. /** @hidden */
  25206. _computedViewMatrix: Matrix;
  25207. private _doNotComputeProjectionMatrix;
  25208. private _transformMatrix;
  25209. private _frustumPlanes;
  25210. private _refreshFrustumPlanes;
  25211. private _storedFov;
  25212. private _stateStored;
  25213. /**
  25214. * Instantiates a new camera object.
  25215. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25216. * @see http://doc.babylonjs.com/features/cameras
  25217. * @param name Defines the name of the camera in the scene
  25218. * @param position Defines the position of the camera
  25219. * @param scene Defines the scene the camera belongs too
  25220. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25221. */
  25222. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25223. /**
  25224. * Store current camera state (fov, position, etc..)
  25225. * @returns the camera
  25226. */
  25227. storeState(): Camera;
  25228. /**
  25229. * Restores the camera state values if it has been stored. You must call storeState() first
  25230. */
  25231. protected _restoreStateValues(): boolean;
  25232. /**
  25233. * Restored camera state. You must call storeState() first.
  25234. * @returns true if restored and false otherwise
  25235. */
  25236. restoreState(): boolean;
  25237. /**
  25238. * Gets the class name of the camera.
  25239. * @returns the class name
  25240. */
  25241. getClassName(): string;
  25242. /** @hidden */
  25243. readonly _isCamera: boolean;
  25244. /**
  25245. * Gets a string representation of the camera useful for debug purpose.
  25246. * @param fullDetails Defines that a more verboe level of logging is required
  25247. * @returns the string representation
  25248. */
  25249. toString(fullDetails?: boolean): string;
  25250. /**
  25251. * Gets the current world space position of the camera.
  25252. */
  25253. readonly globalPosition: Vector3;
  25254. /**
  25255. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25256. * @returns the active meshe list
  25257. */
  25258. getActiveMeshes(): SmartArray<AbstractMesh>;
  25259. /**
  25260. * Check wether a mesh is part of the current active mesh list of the camera
  25261. * @param mesh Defines the mesh to check
  25262. * @returns true if active, false otherwise
  25263. */
  25264. isActiveMesh(mesh: Mesh): boolean;
  25265. /**
  25266. * Is this camera ready to be used/rendered
  25267. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25268. * @return true if the camera is ready
  25269. */
  25270. isReady(completeCheck?: boolean): boolean;
  25271. /** @hidden */
  25272. _initCache(): void;
  25273. /** @hidden */
  25274. _updateCache(ignoreParentClass?: boolean): void;
  25275. /** @hidden */
  25276. _isSynchronized(): boolean;
  25277. /** @hidden */
  25278. _isSynchronizedViewMatrix(): boolean;
  25279. /** @hidden */
  25280. _isSynchronizedProjectionMatrix(): boolean;
  25281. /**
  25282. * Attach the input controls to a specific dom element to get the input from.
  25283. * @param element Defines the element the controls should be listened from
  25284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25285. */
  25286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25287. /**
  25288. * Detach the current controls from the specified dom element.
  25289. * @param element Defines the element to stop listening the inputs from
  25290. */
  25291. detachControl(element: HTMLElement): void;
  25292. /**
  25293. * Update the camera state according to the different inputs gathered during the frame.
  25294. */
  25295. update(): void;
  25296. /** @hidden */
  25297. _checkInputs(): void;
  25298. /** @hidden */
  25299. readonly rigCameras: Camera[];
  25300. /**
  25301. * Gets the post process used by the rig cameras
  25302. */
  25303. readonly rigPostProcess: Nullable<PostProcess>;
  25304. /**
  25305. * Internal, gets the first post proces.
  25306. * @returns the first post process to be run on this camera.
  25307. */
  25308. _getFirstPostProcess(): Nullable<PostProcess>;
  25309. private _cascadePostProcessesToRigCams;
  25310. /**
  25311. * Attach a post process to the camera.
  25312. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25313. * @param postProcess The post process to attach to the camera
  25314. * @param insertAt The position of the post process in case several of them are in use in the scene
  25315. * @returns the position the post process has been inserted at
  25316. */
  25317. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25318. /**
  25319. * Detach a post process to the camera.
  25320. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25321. * @param postProcess The post process to detach from the camera
  25322. */
  25323. detachPostProcess(postProcess: PostProcess): void;
  25324. /**
  25325. * Gets the current world matrix of the camera
  25326. */
  25327. getWorldMatrix(): Matrix;
  25328. /** @hidden */
  25329. _getViewMatrix(): Matrix;
  25330. /**
  25331. * Gets the current view matrix of the camera.
  25332. * @param force forces the camera to recompute the matrix without looking at the cached state
  25333. * @returns the view matrix
  25334. */
  25335. getViewMatrix(force?: boolean): Matrix;
  25336. /**
  25337. * Freeze the projection matrix.
  25338. * It will prevent the cache check of the camera projection compute and can speed up perf
  25339. * if no parameter of the camera are meant to change
  25340. * @param projection Defines manually a projection if necessary
  25341. */
  25342. freezeProjectionMatrix(projection?: Matrix): void;
  25343. /**
  25344. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25345. */
  25346. unfreezeProjectionMatrix(): void;
  25347. /**
  25348. * Gets the current projection matrix of the camera.
  25349. * @param force forces the camera to recompute the matrix without looking at the cached state
  25350. * @returns the projection matrix
  25351. */
  25352. getProjectionMatrix(force?: boolean): Matrix;
  25353. /**
  25354. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25355. * @returns a Matrix
  25356. */
  25357. getTransformationMatrix(): Matrix;
  25358. private _updateFrustumPlanes;
  25359. /**
  25360. * Checks if a cullable object (mesh...) is in the camera frustum
  25361. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25362. * @param target The object to check
  25363. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25364. * @returns true if the object is in frustum otherwise false
  25365. */
  25366. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25367. /**
  25368. * Checks if a cullable object (mesh...) is in the camera frustum
  25369. * Unlike isInFrustum this cheks the full bounding box
  25370. * @param target The object to check
  25371. * @returns true if the object is in frustum otherwise false
  25372. */
  25373. isCompletelyInFrustum(target: ICullable): boolean;
  25374. /**
  25375. * Gets a ray in the forward direction from the camera.
  25376. * @param length Defines the length of the ray to create
  25377. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25378. * @param origin Defines the start point of the ray which defaults to the camera position
  25379. * @returns the forward ray
  25380. */
  25381. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25382. /**
  25383. * Releases resources associated with this node.
  25384. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25385. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25386. */
  25387. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25388. /** @hidden */
  25389. _isLeftCamera: boolean;
  25390. /**
  25391. * Gets the left camera of a rig setup in case of Rigged Camera
  25392. */
  25393. readonly isLeftCamera: boolean;
  25394. /** @hidden */
  25395. _isRightCamera: boolean;
  25396. /**
  25397. * Gets the right camera of a rig setup in case of Rigged Camera
  25398. */
  25399. readonly isRightCamera: boolean;
  25400. /**
  25401. * Gets the left camera of a rig setup in case of Rigged Camera
  25402. */
  25403. readonly leftCamera: Nullable<FreeCamera>;
  25404. /**
  25405. * Gets the right camera of a rig setup in case of Rigged Camera
  25406. */
  25407. readonly rightCamera: Nullable<FreeCamera>;
  25408. /**
  25409. * Gets the left camera target of a rig setup in case of Rigged Camera
  25410. * @returns the target position
  25411. */
  25412. getLeftTarget(): Nullable<Vector3>;
  25413. /**
  25414. * Gets the right camera target of a rig setup in case of Rigged Camera
  25415. * @returns the target position
  25416. */
  25417. getRightTarget(): Nullable<Vector3>;
  25418. /**
  25419. * @hidden
  25420. */
  25421. setCameraRigMode(mode: number, rigParams: any): void;
  25422. /** @hidden */
  25423. static _setStereoscopicRigMode(camera: Camera): void;
  25424. /** @hidden */
  25425. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25426. /** @hidden */
  25427. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25428. /** @hidden */
  25429. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25430. /** @hidden */
  25431. _getVRProjectionMatrix(): Matrix;
  25432. protected _updateCameraRotationMatrix(): void;
  25433. protected _updateWebVRCameraRotationMatrix(): void;
  25434. /**
  25435. * This function MUST be overwritten by the different WebVR cameras available.
  25436. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25437. * @hidden
  25438. */
  25439. _getWebVRProjectionMatrix(): Matrix;
  25440. /**
  25441. * This function MUST be overwritten by the different WebVR cameras available.
  25442. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25443. * @hidden
  25444. */
  25445. _getWebVRViewMatrix(): Matrix;
  25446. /** @hidden */
  25447. setCameraRigParameter(name: string, value: any): void;
  25448. /**
  25449. * needs to be overridden by children so sub has required properties to be copied
  25450. * @hidden
  25451. */
  25452. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25453. /**
  25454. * May need to be overridden by children
  25455. * @hidden
  25456. */
  25457. _updateRigCameras(): void;
  25458. /** @hidden */
  25459. _setupInputs(): void;
  25460. /**
  25461. * Serialiaze the camera setup to a json represention
  25462. * @returns the JSON representation
  25463. */
  25464. serialize(): any;
  25465. /**
  25466. * Clones the current camera.
  25467. * @param name The cloned camera name
  25468. * @returns the cloned camera
  25469. */
  25470. clone(name: string): Camera;
  25471. /**
  25472. * Gets the direction of the camera relative to a given local axis.
  25473. * @param localAxis Defines the reference axis to provide a relative direction.
  25474. * @return the direction
  25475. */
  25476. getDirection(localAxis: Vector3): Vector3;
  25477. /**
  25478. * Returns the current camera absolute rotation
  25479. */
  25480. readonly absoluteRotation: Quaternion;
  25481. /**
  25482. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25483. * @param localAxis Defines the reference axis to provide a relative direction.
  25484. * @param result Defines the vector to store the result in
  25485. */
  25486. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25487. /**
  25488. * Gets a camera constructor for a given camera type
  25489. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25490. * @param name The name of the camera the result will be able to instantiate
  25491. * @param scene The scene the result will construct the camera in
  25492. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25493. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25494. * @returns a factory method to construc the camera
  25495. */
  25496. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25497. /**
  25498. * Compute the world matrix of the camera.
  25499. * @returns the camera world matrix
  25500. */
  25501. computeWorldMatrix(): Matrix;
  25502. /**
  25503. * Parse a JSON and creates the camera from the parsed information
  25504. * @param parsedCamera The JSON to parse
  25505. * @param scene The scene to instantiate the camera in
  25506. * @returns the newly constructed camera
  25507. */
  25508. static Parse(parsedCamera: any, scene: Scene): Camera;
  25509. }
  25510. }
  25511. declare module BABYLON {
  25512. /**
  25513. * Class containing static functions to help procedurally build meshes
  25514. */
  25515. export class DiscBuilder {
  25516. /**
  25517. * Creates a plane polygonal mesh. By default, this is a disc
  25518. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25519. * * 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
  25520. * * 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
  25521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25522. * * 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
  25523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25524. * @param name defines the name of the mesh
  25525. * @param options defines the options used to create the mesh
  25526. * @param scene defines the hosting scene
  25527. * @returns the plane polygonal mesh
  25528. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25529. */
  25530. static CreateDisc(name: string, options: {
  25531. radius?: number;
  25532. tessellation?: number;
  25533. arc?: number;
  25534. updatable?: boolean;
  25535. sideOrientation?: number;
  25536. frontUVs?: Vector4;
  25537. backUVs?: Vector4;
  25538. }, scene?: Nullable<Scene>): Mesh;
  25539. }
  25540. }
  25541. declare module BABYLON {
  25542. /**
  25543. * This represents all the required information to add a fresnel effect on a material:
  25544. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25545. */
  25546. export class FresnelParameters {
  25547. private _isEnabled;
  25548. /**
  25549. * Define if the fresnel effect is enable or not.
  25550. */
  25551. isEnabled: boolean;
  25552. /**
  25553. * Define the color used on edges (grazing angle)
  25554. */
  25555. leftColor: Color3;
  25556. /**
  25557. * Define the color used on center
  25558. */
  25559. rightColor: Color3;
  25560. /**
  25561. * Define bias applied to computed fresnel term
  25562. */
  25563. bias: number;
  25564. /**
  25565. * Defined the power exponent applied to fresnel term
  25566. */
  25567. power: number;
  25568. /**
  25569. * Clones the current fresnel and its valuues
  25570. * @returns a clone fresnel configuration
  25571. */
  25572. clone(): FresnelParameters;
  25573. /**
  25574. * Serializes the current fresnel parameters to a JSON representation.
  25575. * @return the JSON serialization
  25576. */
  25577. serialize(): any;
  25578. /**
  25579. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25580. * @param parsedFresnelParameters Define the JSON representation
  25581. * @returns the parsed parameters
  25582. */
  25583. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25584. }
  25585. }
  25586. declare module BABYLON {
  25587. /**
  25588. * Base class of materials working in push mode in babylon JS
  25589. * @hidden
  25590. */
  25591. export class PushMaterial extends Material {
  25592. protected _activeEffect: Effect;
  25593. protected _normalMatrix: Matrix;
  25594. /**
  25595. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25596. * This means that the material can keep using a previous shader while a new one is being compiled.
  25597. * This is mostly used when shader parallel compilation is supported (true by default)
  25598. */
  25599. allowShaderHotSwapping: boolean;
  25600. constructor(name: string, scene: Scene);
  25601. getEffect(): Effect;
  25602. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25603. /**
  25604. * Binds the given world matrix to the active effect
  25605. *
  25606. * @param world the matrix to bind
  25607. */
  25608. bindOnlyWorldMatrix(world: Matrix): void;
  25609. /**
  25610. * Binds the given normal matrix to the active effect
  25611. *
  25612. * @param normalMatrix the matrix to bind
  25613. */
  25614. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25615. bind(world: Matrix, mesh?: Mesh): void;
  25616. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25617. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25618. }
  25619. }
  25620. declare module BABYLON {
  25621. /**
  25622. * This groups all the flags used to control the materials channel.
  25623. */
  25624. export class MaterialFlags {
  25625. private static _DiffuseTextureEnabled;
  25626. /**
  25627. * Are diffuse textures enabled in the application.
  25628. */
  25629. static DiffuseTextureEnabled: boolean;
  25630. private static _AmbientTextureEnabled;
  25631. /**
  25632. * Are ambient textures enabled in the application.
  25633. */
  25634. static AmbientTextureEnabled: boolean;
  25635. private static _OpacityTextureEnabled;
  25636. /**
  25637. * Are opacity textures enabled in the application.
  25638. */
  25639. static OpacityTextureEnabled: boolean;
  25640. private static _ReflectionTextureEnabled;
  25641. /**
  25642. * Are reflection textures enabled in the application.
  25643. */
  25644. static ReflectionTextureEnabled: boolean;
  25645. private static _EmissiveTextureEnabled;
  25646. /**
  25647. * Are emissive textures enabled in the application.
  25648. */
  25649. static EmissiveTextureEnabled: boolean;
  25650. private static _SpecularTextureEnabled;
  25651. /**
  25652. * Are specular textures enabled in the application.
  25653. */
  25654. static SpecularTextureEnabled: boolean;
  25655. private static _BumpTextureEnabled;
  25656. /**
  25657. * Are bump textures enabled in the application.
  25658. */
  25659. static BumpTextureEnabled: boolean;
  25660. private static _LightmapTextureEnabled;
  25661. /**
  25662. * Are lightmap textures enabled in the application.
  25663. */
  25664. static LightmapTextureEnabled: boolean;
  25665. private static _RefractionTextureEnabled;
  25666. /**
  25667. * Are refraction textures enabled in the application.
  25668. */
  25669. static RefractionTextureEnabled: boolean;
  25670. private static _ColorGradingTextureEnabled;
  25671. /**
  25672. * Are color grading textures enabled in the application.
  25673. */
  25674. static ColorGradingTextureEnabled: boolean;
  25675. private static _FresnelEnabled;
  25676. /**
  25677. * Are fresnels enabled in the application.
  25678. */
  25679. static FresnelEnabled: boolean;
  25680. private static _ClearCoatTextureEnabled;
  25681. /**
  25682. * Are clear coat textures enabled in the application.
  25683. */
  25684. static ClearCoatTextureEnabled: boolean;
  25685. private static _ClearCoatBumpTextureEnabled;
  25686. /**
  25687. * Are clear coat bump textures enabled in the application.
  25688. */
  25689. static ClearCoatBumpTextureEnabled: boolean;
  25690. private static _ClearCoatTintTextureEnabled;
  25691. /**
  25692. * Are clear coat tint textures enabled in the application.
  25693. */
  25694. static ClearCoatTintTextureEnabled: boolean;
  25695. private static _SheenTextureEnabled;
  25696. /**
  25697. * Are sheen textures enabled in the application.
  25698. */
  25699. static SheenTextureEnabled: boolean;
  25700. private static _AnisotropicTextureEnabled;
  25701. /**
  25702. * Are anisotropic textures enabled in the application.
  25703. */
  25704. static AnisotropicTextureEnabled: boolean;
  25705. private static _ThicknessTextureEnabled;
  25706. /**
  25707. * Are thickness textures enabled in the application.
  25708. */
  25709. static ThicknessTextureEnabled: boolean;
  25710. }
  25711. }
  25712. declare module BABYLON {
  25713. /** @hidden */
  25714. export var defaultFragmentDeclaration: {
  25715. name: string;
  25716. shader: string;
  25717. };
  25718. }
  25719. declare module BABYLON {
  25720. /** @hidden */
  25721. export var defaultUboDeclaration: {
  25722. name: string;
  25723. shader: string;
  25724. };
  25725. }
  25726. declare module BABYLON {
  25727. /** @hidden */
  25728. export var lightFragmentDeclaration: {
  25729. name: string;
  25730. shader: string;
  25731. };
  25732. }
  25733. declare module BABYLON {
  25734. /** @hidden */
  25735. export var lightUboDeclaration: {
  25736. name: string;
  25737. shader: string;
  25738. };
  25739. }
  25740. declare module BABYLON {
  25741. /** @hidden */
  25742. export var lightsFragmentFunctions: {
  25743. name: string;
  25744. shader: string;
  25745. };
  25746. }
  25747. declare module BABYLON {
  25748. /** @hidden */
  25749. export var shadowsFragmentFunctions: {
  25750. name: string;
  25751. shader: string;
  25752. };
  25753. }
  25754. declare module BABYLON {
  25755. /** @hidden */
  25756. export var fresnelFunction: {
  25757. name: string;
  25758. shader: string;
  25759. };
  25760. }
  25761. declare module BABYLON {
  25762. /** @hidden */
  25763. export var reflectionFunction: {
  25764. name: string;
  25765. shader: string;
  25766. };
  25767. }
  25768. declare module BABYLON {
  25769. /** @hidden */
  25770. export var bumpFragmentFunctions: {
  25771. name: string;
  25772. shader: string;
  25773. };
  25774. }
  25775. declare module BABYLON {
  25776. /** @hidden */
  25777. export var logDepthDeclaration: {
  25778. name: string;
  25779. shader: string;
  25780. };
  25781. }
  25782. declare module BABYLON {
  25783. /** @hidden */
  25784. export var bumpFragment: {
  25785. name: string;
  25786. shader: string;
  25787. };
  25788. }
  25789. declare module BABYLON {
  25790. /** @hidden */
  25791. export var depthPrePass: {
  25792. name: string;
  25793. shader: string;
  25794. };
  25795. }
  25796. declare module BABYLON {
  25797. /** @hidden */
  25798. export var lightFragment: {
  25799. name: string;
  25800. shader: string;
  25801. };
  25802. }
  25803. declare module BABYLON {
  25804. /** @hidden */
  25805. export var logDepthFragment: {
  25806. name: string;
  25807. shader: string;
  25808. };
  25809. }
  25810. declare module BABYLON {
  25811. /** @hidden */
  25812. export var defaultPixelShader: {
  25813. name: string;
  25814. shader: string;
  25815. };
  25816. }
  25817. declare module BABYLON {
  25818. /** @hidden */
  25819. export var defaultVertexDeclaration: {
  25820. name: string;
  25821. shader: string;
  25822. };
  25823. }
  25824. declare module BABYLON {
  25825. /** @hidden */
  25826. export var bumpVertexDeclaration: {
  25827. name: string;
  25828. shader: string;
  25829. };
  25830. }
  25831. declare module BABYLON {
  25832. /** @hidden */
  25833. export var bumpVertex: {
  25834. name: string;
  25835. shader: string;
  25836. };
  25837. }
  25838. declare module BABYLON {
  25839. /** @hidden */
  25840. export var fogVertex: {
  25841. name: string;
  25842. shader: string;
  25843. };
  25844. }
  25845. declare module BABYLON {
  25846. /** @hidden */
  25847. export var shadowsVertex: {
  25848. name: string;
  25849. shader: string;
  25850. };
  25851. }
  25852. declare module BABYLON {
  25853. /** @hidden */
  25854. export var pointCloudVertex: {
  25855. name: string;
  25856. shader: string;
  25857. };
  25858. }
  25859. declare module BABYLON {
  25860. /** @hidden */
  25861. export var logDepthVertex: {
  25862. name: string;
  25863. shader: string;
  25864. };
  25865. }
  25866. declare module BABYLON {
  25867. /** @hidden */
  25868. export var defaultVertexShader: {
  25869. name: string;
  25870. shader: string;
  25871. };
  25872. }
  25873. declare module BABYLON {
  25874. /** @hidden */
  25875. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  25876. MAINUV1: boolean;
  25877. MAINUV2: boolean;
  25878. DIFFUSE: boolean;
  25879. DIFFUSEDIRECTUV: number;
  25880. AMBIENT: boolean;
  25881. AMBIENTDIRECTUV: number;
  25882. OPACITY: boolean;
  25883. OPACITYDIRECTUV: number;
  25884. OPACITYRGB: boolean;
  25885. REFLECTION: boolean;
  25886. EMISSIVE: boolean;
  25887. EMISSIVEDIRECTUV: number;
  25888. SPECULAR: boolean;
  25889. SPECULARDIRECTUV: number;
  25890. BUMP: boolean;
  25891. BUMPDIRECTUV: number;
  25892. PARALLAX: boolean;
  25893. PARALLAXOCCLUSION: boolean;
  25894. SPECULAROVERALPHA: boolean;
  25895. CLIPPLANE: boolean;
  25896. CLIPPLANE2: boolean;
  25897. CLIPPLANE3: boolean;
  25898. CLIPPLANE4: boolean;
  25899. ALPHATEST: boolean;
  25900. DEPTHPREPASS: boolean;
  25901. ALPHAFROMDIFFUSE: boolean;
  25902. POINTSIZE: boolean;
  25903. FOG: boolean;
  25904. SPECULARTERM: boolean;
  25905. DIFFUSEFRESNEL: boolean;
  25906. OPACITYFRESNEL: boolean;
  25907. REFLECTIONFRESNEL: boolean;
  25908. REFRACTIONFRESNEL: boolean;
  25909. EMISSIVEFRESNEL: boolean;
  25910. FRESNEL: boolean;
  25911. NORMAL: boolean;
  25912. UV1: boolean;
  25913. UV2: boolean;
  25914. VERTEXCOLOR: boolean;
  25915. VERTEXALPHA: boolean;
  25916. NUM_BONE_INFLUENCERS: number;
  25917. BonesPerMesh: number;
  25918. BONETEXTURE: boolean;
  25919. INSTANCES: boolean;
  25920. GLOSSINESS: boolean;
  25921. ROUGHNESS: boolean;
  25922. EMISSIVEASILLUMINATION: boolean;
  25923. LINKEMISSIVEWITHDIFFUSE: boolean;
  25924. REFLECTIONFRESNELFROMSPECULAR: boolean;
  25925. LIGHTMAP: boolean;
  25926. LIGHTMAPDIRECTUV: number;
  25927. OBJECTSPACE_NORMALMAP: boolean;
  25928. USELIGHTMAPASSHADOWMAP: boolean;
  25929. REFLECTIONMAP_3D: boolean;
  25930. REFLECTIONMAP_SPHERICAL: boolean;
  25931. REFLECTIONMAP_PLANAR: boolean;
  25932. REFLECTIONMAP_CUBIC: boolean;
  25933. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25934. REFLECTIONMAP_PROJECTION: boolean;
  25935. REFLECTIONMAP_SKYBOX: boolean;
  25936. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  25937. REFLECTIONMAP_EXPLICIT: boolean;
  25938. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25939. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25940. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25941. INVERTCUBICMAP: boolean;
  25942. LOGARITHMICDEPTH: boolean;
  25943. REFRACTION: boolean;
  25944. REFRACTIONMAP_3D: boolean;
  25945. REFLECTIONOVERALPHA: boolean;
  25946. TWOSIDEDLIGHTING: boolean;
  25947. SHADOWFLOAT: boolean;
  25948. MORPHTARGETS: boolean;
  25949. MORPHTARGETS_NORMAL: boolean;
  25950. MORPHTARGETS_TANGENT: boolean;
  25951. MORPHTARGETS_UV: boolean;
  25952. NUM_MORPH_INFLUENCERS: number;
  25953. NONUNIFORMSCALING: boolean;
  25954. PREMULTIPLYALPHA: boolean;
  25955. IMAGEPROCESSING: boolean;
  25956. VIGNETTE: boolean;
  25957. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25958. VIGNETTEBLENDMODEOPAQUE: boolean;
  25959. TONEMAPPING: boolean;
  25960. TONEMAPPING_ACES: boolean;
  25961. CONTRAST: boolean;
  25962. COLORCURVES: boolean;
  25963. COLORGRADING: boolean;
  25964. COLORGRADING3D: boolean;
  25965. SAMPLER3DGREENDEPTH: boolean;
  25966. SAMPLER3DBGRMAP: boolean;
  25967. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25968. MULTIVIEW: boolean;
  25969. /**
  25970. * If the reflection texture on this material is in linear color space
  25971. * @hidden
  25972. */
  25973. IS_REFLECTION_LINEAR: boolean;
  25974. /**
  25975. * If the refraction texture on this material is in linear color space
  25976. * @hidden
  25977. */
  25978. IS_REFRACTION_LINEAR: boolean;
  25979. EXPOSURE: boolean;
  25980. constructor();
  25981. setReflectionMode(modeToEnable: string): void;
  25982. }
  25983. /**
  25984. * This is the default material used in Babylon. It is the best trade off between quality
  25985. * and performances.
  25986. * @see http://doc.babylonjs.com/babylon101/materials
  25987. */
  25988. export class StandardMaterial extends PushMaterial {
  25989. private _diffuseTexture;
  25990. /**
  25991. * The basic texture of the material as viewed under a light.
  25992. */
  25993. diffuseTexture: Nullable<BaseTexture>;
  25994. private _ambientTexture;
  25995. /**
  25996. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  25997. */
  25998. ambientTexture: Nullable<BaseTexture>;
  25999. private _opacityTexture;
  26000. /**
  26001. * Define the transparency of the material from a texture.
  26002. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26003. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26004. */
  26005. opacityTexture: Nullable<BaseTexture>;
  26006. private _reflectionTexture;
  26007. /**
  26008. * Define the texture used to display the reflection.
  26009. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26010. */
  26011. reflectionTexture: Nullable<BaseTexture>;
  26012. private _emissiveTexture;
  26013. /**
  26014. * Define texture of the material as if self lit.
  26015. * This will be mixed in the final result even in the absence of light.
  26016. */
  26017. emissiveTexture: Nullable<BaseTexture>;
  26018. private _specularTexture;
  26019. /**
  26020. * Define how the color and intensity of the highlight given by the light in the material.
  26021. */
  26022. specularTexture: Nullable<BaseTexture>;
  26023. private _bumpTexture;
  26024. /**
  26025. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26026. * 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.
  26027. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26028. */
  26029. bumpTexture: Nullable<BaseTexture>;
  26030. private _lightmapTexture;
  26031. /**
  26032. * Complex lighting can be computationally expensive to compute at runtime.
  26033. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26034. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26035. */
  26036. lightmapTexture: Nullable<BaseTexture>;
  26037. private _refractionTexture;
  26038. /**
  26039. * Define the texture used to display the refraction.
  26040. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26041. */
  26042. refractionTexture: Nullable<BaseTexture>;
  26043. /**
  26044. * The color of the material lit by the environmental background lighting.
  26045. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26046. */
  26047. ambientColor: Color3;
  26048. /**
  26049. * The basic color of the material as viewed under a light.
  26050. */
  26051. diffuseColor: Color3;
  26052. /**
  26053. * Define how the color and intensity of the highlight given by the light in the material.
  26054. */
  26055. specularColor: Color3;
  26056. /**
  26057. * Define the color of the material as if self lit.
  26058. * This will be mixed in the final result even in the absence of light.
  26059. */
  26060. emissiveColor: Color3;
  26061. /**
  26062. * Defines how sharp are the highlights in the material.
  26063. * The bigger the value the sharper giving a more glossy feeling to the result.
  26064. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26065. */
  26066. specularPower: number;
  26067. private _useAlphaFromDiffuseTexture;
  26068. /**
  26069. * Does the transparency come from the diffuse texture alpha channel.
  26070. */
  26071. useAlphaFromDiffuseTexture: boolean;
  26072. private _useEmissiveAsIllumination;
  26073. /**
  26074. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26075. */
  26076. useEmissiveAsIllumination: boolean;
  26077. private _linkEmissiveWithDiffuse;
  26078. /**
  26079. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26080. * the emissive level when the final color is close to one.
  26081. */
  26082. linkEmissiveWithDiffuse: boolean;
  26083. private _useSpecularOverAlpha;
  26084. /**
  26085. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26086. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26087. */
  26088. useSpecularOverAlpha: boolean;
  26089. private _useReflectionOverAlpha;
  26090. /**
  26091. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26092. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26093. */
  26094. useReflectionOverAlpha: boolean;
  26095. private _disableLighting;
  26096. /**
  26097. * Does lights from the scene impacts this material.
  26098. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26099. */
  26100. disableLighting: boolean;
  26101. private _useObjectSpaceNormalMap;
  26102. /**
  26103. * Allows using an object space normal map (instead of tangent space).
  26104. */
  26105. useObjectSpaceNormalMap: boolean;
  26106. private _useParallax;
  26107. /**
  26108. * Is parallax enabled or not.
  26109. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26110. */
  26111. useParallax: boolean;
  26112. private _useParallaxOcclusion;
  26113. /**
  26114. * Is parallax occlusion enabled or not.
  26115. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26116. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26117. */
  26118. useParallaxOcclusion: boolean;
  26119. /**
  26120. * 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.
  26121. */
  26122. parallaxScaleBias: number;
  26123. private _roughness;
  26124. /**
  26125. * Helps to define how blurry the reflections should appears in the material.
  26126. */
  26127. roughness: number;
  26128. /**
  26129. * In case of refraction, define the value of the index of refraction.
  26130. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26131. */
  26132. indexOfRefraction: number;
  26133. /**
  26134. * Invert the refraction texture alongside the y axis.
  26135. * It can be useful with procedural textures or probe for instance.
  26136. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26137. */
  26138. invertRefractionY: boolean;
  26139. /**
  26140. * Defines the alpha limits in alpha test mode.
  26141. */
  26142. alphaCutOff: number;
  26143. private _useLightmapAsShadowmap;
  26144. /**
  26145. * In case of light mapping, define whether the map contains light or shadow informations.
  26146. */
  26147. useLightmapAsShadowmap: boolean;
  26148. private _diffuseFresnelParameters;
  26149. /**
  26150. * Define the diffuse fresnel parameters of the material.
  26151. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26152. */
  26153. diffuseFresnelParameters: FresnelParameters;
  26154. private _opacityFresnelParameters;
  26155. /**
  26156. * Define the opacity fresnel parameters of the material.
  26157. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26158. */
  26159. opacityFresnelParameters: FresnelParameters;
  26160. private _reflectionFresnelParameters;
  26161. /**
  26162. * Define the reflection fresnel parameters of the material.
  26163. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26164. */
  26165. reflectionFresnelParameters: FresnelParameters;
  26166. private _refractionFresnelParameters;
  26167. /**
  26168. * Define the refraction fresnel parameters of the material.
  26169. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26170. */
  26171. refractionFresnelParameters: FresnelParameters;
  26172. private _emissiveFresnelParameters;
  26173. /**
  26174. * Define the emissive fresnel parameters of the material.
  26175. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26176. */
  26177. emissiveFresnelParameters: FresnelParameters;
  26178. private _useReflectionFresnelFromSpecular;
  26179. /**
  26180. * If true automatically deducts the fresnels values from the material specularity.
  26181. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26182. */
  26183. useReflectionFresnelFromSpecular: boolean;
  26184. private _useGlossinessFromSpecularMapAlpha;
  26185. /**
  26186. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26187. */
  26188. useGlossinessFromSpecularMapAlpha: boolean;
  26189. private _maxSimultaneousLights;
  26190. /**
  26191. * Defines the maximum number of lights that can be used in the material
  26192. */
  26193. maxSimultaneousLights: number;
  26194. private _invertNormalMapX;
  26195. /**
  26196. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26197. */
  26198. invertNormalMapX: boolean;
  26199. private _invertNormalMapY;
  26200. /**
  26201. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26202. */
  26203. invertNormalMapY: boolean;
  26204. private _twoSidedLighting;
  26205. /**
  26206. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26207. */
  26208. twoSidedLighting: boolean;
  26209. /**
  26210. * Default configuration related to image processing available in the standard Material.
  26211. */
  26212. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26213. /**
  26214. * Gets the image processing configuration used either in this material.
  26215. */
  26216. /**
  26217. * Sets the Default image processing configuration used either in the this material.
  26218. *
  26219. * If sets to null, the scene one is in use.
  26220. */
  26221. imageProcessingConfiguration: ImageProcessingConfiguration;
  26222. /**
  26223. * Keep track of the image processing observer to allow dispose and replace.
  26224. */
  26225. private _imageProcessingObserver;
  26226. /**
  26227. * Attaches a new image processing configuration to the Standard Material.
  26228. * @param configuration
  26229. */
  26230. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26231. /**
  26232. * Gets wether the color curves effect is enabled.
  26233. */
  26234. /**
  26235. * Sets wether the color curves effect is enabled.
  26236. */
  26237. cameraColorCurvesEnabled: boolean;
  26238. /**
  26239. * Gets wether the color grading effect is enabled.
  26240. */
  26241. /**
  26242. * Gets wether the color grading effect is enabled.
  26243. */
  26244. cameraColorGradingEnabled: boolean;
  26245. /**
  26246. * Gets wether tonemapping is enabled or not.
  26247. */
  26248. /**
  26249. * Sets wether tonemapping is enabled or not
  26250. */
  26251. cameraToneMappingEnabled: boolean;
  26252. /**
  26253. * The camera exposure used on this material.
  26254. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26255. * This corresponds to a photographic exposure.
  26256. */
  26257. /**
  26258. * The camera exposure used on this material.
  26259. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26260. * This corresponds to a photographic exposure.
  26261. */
  26262. cameraExposure: number;
  26263. /**
  26264. * Gets The camera contrast used on this material.
  26265. */
  26266. /**
  26267. * Sets The camera contrast used on this material.
  26268. */
  26269. cameraContrast: number;
  26270. /**
  26271. * Gets the Color Grading 2D Lookup Texture.
  26272. */
  26273. /**
  26274. * Sets the Color Grading 2D Lookup Texture.
  26275. */
  26276. cameraColorGradingTexture: Nullable<BaseTexture>;
  26277. /**
  26278. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26279. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26280. * 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;
  26281. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26282. */
  26283. /**
  26284. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26285. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26286. * 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;
  26287. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26288. */
  26289. cameraColorCurves: Nullable<ColorCurves>;
  26290. /**
  26291. * Custom callback helping to override the default shader used in the material.
  26292. */
  26293. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26294. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26295. protected _worldViewProjectionMatrix: Matrix;
  26296. protected _globalAmbientColor: Color3;
  26297. protected _useLogarithmicDepth: boolean;
  26298. protected _rebuildInParallel: boolean;
  26299. /**
  26300. * Instantiates a new standard material.
  26301. * This is the default material used in Babylon. It is the best trade off between quality
  26302. * and performances.
  26303. * @see http://doc.babylonjs.com/babylon101/materials
  26304. * @param name Define the name of the material in the scene
  26305. * @param scene Define the scene the material belong to
  26306. */
  26307. constructor(name: string, scene: Scene);
  26308. /**
  26309. * Gets a boolean indicating that current material needs to register RTT
  26310. */
  26311. readonly hasRenderTargetTextures: boolean;
  26312. /**
  26313. * Gets the current class name of the material e.g. "StandardMaterial"
  26314. * Mainly use in serialization.
  26315. * @returns the class name
  26316. */
  26317. getClassName(): string;
  26318. /**
  26319. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26320. * You can try switching to logarithmic depth.
  26321. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26322. */
  26323. useLogarithmicDepth: boolean;
  26324. /**
  26325. * Specifies if the material will require alpha blending
  26326. * @returns a boolean specifying if alpha blending is needed
  26327. */
  26328. needAlphaBlending(): boolean;
  26329. /**
  26330. * Specifies if this material should be rendered in alpha test mode
  26331. * @returns a boolean specifying if an alpha test is needed.
  26332. */
  26333. needAlphaTesting(): boolean;
  26334. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26335. /**
  26336. * Get the texture used for alpha test purpose.
  26337. * @returns the diffuse texture in case of the standard material.
  26338. */
  26339. getAlphaTestTexture(): Nullable<BaseTexture>;
  26340. /**
  26341. * Get if the submesh is ready to be used and all its information available.
  26342. * Child classes can use it to update shaders
  26343. * @param mesh defines the mesh to check
  26344. * @param subMesh defines which submesh to check
  26345. * @param useInstances specifies that instances should be used
  26346. * @returns a boolean indicating that the submesh is ready or not
  26347. */
  26348. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26349. /**
  26350. * Builds the material UBO layouts.
  26351. * Used internally during the effect preparation.
  26352. */
  26353. buildUniformLayout(): void;
  26354. /**
  26355. * Unbinds the material from the mesh
  26356. */
  26357. unbind(): void;
  26358. /**
  26359. * Binds the submesh to this material by preparing the effect and shader to draw
  26360. * @param world defines the world transformation matrix
  26361. * @param mesh defines the mesh containing the submesh
  26362. * @param subMesh defines the submesh to bind the material to
  26363. */
  26364. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26365. /**
  26366. * Get the list of animatables in the material.
  26367. * @returns the list of animatables object used in the material
  26368. */
  26369. getAnimatables(): IAnimatable[];
  26370. /**
  26371. * Gets the active textures from the material
  26372. * @returns an array of textures
  26373. */
  26374. getActiveTextures(): BaseTexture[];
  26375. /**
  26376. * Specifies if the material uses a texture
  26377. * @param texture defines the texture to check against the material
  26378. * @returns a boolean specifying if the material uses the texture
  26379. */
  26380. hasTexture(texture: BaseTexture): boolean;
  26381. /**
  26382. * Disposes the material
  26383. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26384. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26385. */
  26386. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26387. /**
  26388. * Makes a duplicate of the material, and gives it a new name
  26389. * @param name defines the new name for the duplicated material
  26390. * @returns the cloned material
  26391. */
  26392. clone(name: string): StandardMaterial;
  26393. /**
  26394. * Serializes this material in a JSON representation
  26395. * @returns the serialized material object
  26396. */
  26397. serialize(): any;
  26398. /**
  26399. * Creates a standard material from parsed material data
  26400. * @param source defines the JSON representation of the material
  26401. * @param scene defines the hosting scene
  26402. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26403. * @returns a new standard material
  26404. */
  26405. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26406. /**
  26407. * Are diffuse textures enabled in the application.
  26408. */
  26409. static DiffuseTextureEnabled: boolean;
  26410. /**
  26411. * Are ambient textures enabled in the application.
  26412. */
  26413. static AmbientTextureEnabled: boolean;
  26414. /**
  26415. * Are opacity textures enabled in the application.
  26416. */
  26417. static OpacityTextureEnabled: boolean;
  26418. /**
  26419. * Are reflection textures enabled in the application.
  26420. */
  26421. static ReflectionTextureEnabled: boolean;
  26422. /**
  26423. * Are emissive textures enabled in the application.
  26424. */
  26425. static EmissiveTextureEnabled: boolean;
  26426. /**
  26427. * Are specular textures enabled in the application.
  26428. */
  26429. static SpecularTextureEnabled: boolean;
  26430. /**
  26431. * Are bump textures enabled in the application.
  26432. */
  26433. static BumpTextureEnabled: boolean;
  26434. /**
  26435. * Are lightmap textures enabled in the application.
  26436. */
  26437. static LightmapTextureEnabled: boolean;
  26438. /**
  26439. * Are refraction textures enabled in the application.
  26440. */
  26441. static RefractionTextureEnabled: boolean;
  26442. /**
  26443. * Are color grading textures enabled in the application.
  26444. */
  26445. static ColorGradingTextureEnabled: boolean;
  26446. /**
  26447. * Are fresnels enabled in the application.
  26448. */
  26449. static FresnelEnabled: boolean;
  26450. }
  26451. }
  26452. declare module BABYLON {
  26453. /**
  26454. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26455. *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.
  26456. * The SPS is also a particle system. It provides some methods to manage the particles.
  26457. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26458. *
  26459. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26460. */
  26461. export class SolidParticleSystem implements IDisposable {
  26462. /**
  26463. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26464. * Example : var p = SPS.particles[i];
  26465. */
  26466. particles: SolidParticle[];
  26467. /**
  26468. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26469. */
  26470. nbParticles: number;
  26471. /**
  26472. * If the particles must ever face the camera (default false). Useful for planar particles.
  26473. */
  26474. billboard: boolean;
  26475. /**
  26476. * Recompute normals when adding a shape
  26477. */
  26478. recomputeNormals: boolean;
  26479. /**
  26480. * This a counter ofr your own usage. It's not set by any SPS functions.
  26481. */
  26482. counter: number;
  26483. /**
  26484. * The SPS name. This name is also given to the underlying mesh.
  26485. */
  26486. name: string;
  26487. /**
  26488. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26489. */
  26490. mesh: Mesh;
  26491. /**
  26492. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26493. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26494. */
  26495. vars: any;
  26496. /**
  26497. * This array is populated when the SPS is set as 'pickable'.
  26498. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26499. * Each element of this array is an object `{idx: int, faceId: int}`.
  26500. * `idx` is the picked particle index in the `SPS.particles` array
  26501. * `faceId` is the picked face index counted within this particle.
  26502. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26503. */
  26504. pickedParticles: {
  26505. idx: number;
  26506. faceId: number;
  26507. }[];
  26508. /**
  26509. * This array is populated when `enableDepthSort` is set to true.
  26510. * Each element of this array is an instance of the class DepthSortedParticle.
  26511. */
  26512. depthSortedParticles: DepthSortedParticle[];
  26513. /**
  26514. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26515. * @hidden
  26516. */
  26517. _bSphereOnly: boolean;
  26518. /**
  26519. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26520. * @hidden
  26521. */
  26522. _bSphereRadiusFactor: number;
  26523. private _scene;
  26524. private _positions;
  26525. private _indices;
  26526. private _normals;
  26527. private _colors;
  26528. private _uvs;
  26529. private _indices32;
  26530. private _positions32;
  26531. private _normals32;
  26532. private _fixedNormal32;
  26533. private _colors32;
  26534. private _uvs32;
  26535. private _index;
  26536. private _updatable;
  26537. private _pickable;
  26538. private _isVisibilityBoxLocked;
  26539. private _alwaysVisible;
  26540. private _depthSort;
  26541. private _expandable;
  26542. private _shapeCounter;
  26543. private _copy;
  26544. private _color;
  26545. private _computeParticleColor;
  26546. private _computeParticleTexture;
  26547. private _computeParticleRotation;
  26548. private _computeParticleVertex;
  26549. private _computeBoundingBox;
  26550. private _depthSortParticles;
  26551. private _camera;
  26552. private _mustUnrotateFixedNormals;
  26553. private _particlesIntersect;
  26554. private _needs32Bits;
  26555. private _isNotBuilt;
  26556. private _lastParticleId;
  26557. private _idxOfId;
  26558. private _multimaterialEnabled;
  26559. private _useModelMaterial;
  26560. private _indicesByMaterial;
  26561. private _materialIndexes;
  26562. private _depthSortFunction;
  26563. private _materialSortFunction;
  26564. private _materials;
  26565. private _multimaterial;
  26566. private _materialIndexesById;
  26567. private _defaultMaterial;
  26568. private _autoUpdateSubMeshes;
  26569. /**
  26570. * Creates a SPS (Solid Particle System) object.
  26571. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26572. * @param scene (Scene) is the scene in which the SPS is added.
  26573. * @param options defines the options of the sps e.g.
  26574. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26575. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26576. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26577. * * 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.
  26578. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26579. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26580. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26581. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26582. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26583. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26584. */
  26585. constructor(name: string, scene: Scene, options?: {
  26586. updatable?: boolean;
  26587. isPickable?: boolean;
  26588. enableDepthSort?: boolean;
  26589. particleIntersection?: boolean;
  26590. boundingSphereOnly?: boolean;
  26591. bSphereRadiusFactor?: number;
  26592. expandable?: boolean;
  26593. useModelMaterial?: boolean;
  26594. enableMultiMaterial?: boolean;
  26595. });
  26596. /**
  26597. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26598. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26599. * @returns the created mesh
  26600. */
  26601. buildMesh(): Mesh;
  26602. /**
  26603. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26604. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26605. * Thus the particles generated from `digest()` have their property `position` set yet.
  26606. * @param mesh ( Mesh ) is the mesh to be digested
  26607. * @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
  26608. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26609. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26610. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26611. * @returns the current SPS
  26612. */
  26613. digest(mesh: Mesh, options?: {
  26614. facetNb?: number;
  26615. number?: number;
  26616. delta?: number;
  26617. storage?: [];
  26618. }): SolidParticleSystem;
  26619. /**
  26620. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26621. * @hidden
  26622. */
  26623. private _unrotateFixedNormals;
  26624. /**
  26625. * Resets the temporary working copy particle
  26626. * @hidden
  26627. */
  26628. private _resetCopy;
  26629. /**
  26630. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26631. * @param p the current index in the positions array to be updated
  26632. * @param ind the current index in the indices array
  26633. * @param shape a Vector3 array, the shape geometry
  26634. * @param positions the positions array to be updated
  26635. * @param meshInd the shape indices array
  26636. * @param indices the indices array to be updated
  26637. * @param meshUV the shape uv array
  26638. * @param uvs the uv array to be updated
  26639. * @param meshCol the shape color array
  26640. * @param colors the color array to be updated
  26641. * @param meshNor the shape normals array
  26642. * @param normals the normals array to be updated
  26643. * @param idx the particle index
  26644. * @param idxInShape the particle index in its shape
  26645. * @param options the addShape() method passed options
  26646. * @model the particle model
  26647. * @hidden
  26648. */
  26649. private _meshBuilder;
  26650. /**
  26651. * Returns a shape Vector3 array from positions float array
  26652. * @param positions float array
  26653. * @returns a vector3 array
  26654. * @hidden
  26655. */
  26656. private _posToShape;
  26657. /**
  26658. * Returns a shapeUV array from a float uvs (array deep copy)
  26659. * @param uvs as a float array
  26660. * @returns a shapeUV array
  26661. * @hidden
  26662. */
  26663. private _uvsToShapeUV;
  26664. /**
  26665. * Adds a new particle object in the particles array
  26666. * @param idx particle index in particles array
  26667. * @param id particle id
  26668. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26669. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26670. * @param model particle ModelShape object
  26671. * @param shapeId model shape identifier
  26672. * @param idxInShape index of the particle in the current model
  26673. * @param bInfo model bounding info object
  26674. * @param storage target storage array, if any
  26675. * @hidden
  26676. */
  26677. private _addParticle;
  26678. /**
  26679. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26680. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26681. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26682. * @param nb (positive integer) the number of particles to be created from this model
  26683. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26684. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26685. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26686. * @returns the number of shapes in the system
  26687. */
  26688. addShape(mesh: Mesh, nb: number, options?: {
  26689. positionFunction?: any;
  26690. vertexFunction?: any;
  26691. storage?: [];
  26692. }): number;
  26693. /**
  26694. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26695. * @hidden
  26696. */
  26697. private _rebuildParticle;
  26698. /**
  26699. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26700. * @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.
  26701. * @returns the SPS.
  26702. */
  26703. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26704. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26705. * Returns an array with the removed particles.
  26706. * 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.
  26707. * The SPS can't be empty so at least one particle needs to remain in place.
  26708. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26709. * @param start index of the first particle to remove
  26710. * @param end index of the last particle to remove (included)
  26711. * @returns an array populated with the removed particles
  26712. */
  26713. removeParticles(start: number, end: number): SolidParticle[];
  26714. /**
  26715. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26716. * @param solidParticleArray an array populated with Solid Particles objects
  26717. * @returns the SPS
  26718. */
  26719. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26720. /**
  26721. * Creates a new particle and modifies the SPS mesh geometry :
  26722. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26723. * - calls _addParticle() to populate the particle array
  26724. * factorized code from addShape() and insertParticlesFromArray()
  26725. * @param idx particle index in the particles array
  26726. * @param i particle index in its shape
  26727. * @param modelShape particle ModelShape object
  26728. * @param shape shape vertex array
  26729. * @param meshInd shape indices array
  26730. * @param meshUV shape uv array
  26731. * @param meshCol shape color array
  26732. * @param meshNor shape normals array
  26733. * @param bbInfo shape bounding info
  26734. * @param storage target particle storage
  26735. * @options addShape() passed options
  26736. * @hidden
  26737. */
  26738. private _insertNewParticle;
  26739. /**
  26740. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26741. * This method calls `updateParticle()` for each particle of the SPS.
  26742. * For an animated SPS, it is usually called within the render loop.
  26743. * 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.
  26744. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26745. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26746. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26747. * @returns the SPS.
  26748. */
  26749. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26750. /**
  26751. * Disposes the SPS.
  26752. */
  26753. dispose(): void;
  26754. /**
  26755. * Returns a SolidParticle object from its identifier : particle.id
  26756. * @param id (integer) the particle Id
  26757. * @returns the searched particle or null if not found in the SPS.
  26758. */
  26759. getParticleById(id: number): Nullable<SolidParticle>;
  26760. /**
  26761. * Returns a new array populated with the particles having the passed shapeId.
  26762. * @param shapeId (integer) the shape identifier
  26763. * @returns a new solid particle array
  26764. */
  26765. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26766. /**
  26767. * Populates the passed array "ref" with the particles having the passed shapeId.
  26768. * @param shapeId the shape identifier
  26769. * @returns the SPS
  26770. * @param ref
  26771. */
  26772. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26773. /**
  26774. * Computes the required SubMeshes according the materials assigned to the particles.
  26775. * @returns the solid particle system.
  26776. * Does nothing if called before the SPS mesh is built.
  26777. */
  26778. computeSubMeshes(): SolidParticleSystem;
  26779. /**
  26780. * Sorts the solid particles by material when MultiMaterial is enabled.
  26781. * Updates the indices32 array.
  26782. * Updates the indicesByMaterial array.
  26783. * Updates the mesh indices array.
  26784. * @returns the SPS
  26785. * @hidden
  26786. */
  26787. private _sortParticlesByMaterial;
  26788. /**
  26789. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  26790. * @hidden
  26791. */
  26792. private _setMaterialIndexesById;
  26793. /**
  26794. * Returns an array with unique values of Materials from the passed array
  26795. * @param array the material array to be checked and filtered
  26796. * @hidden
  26797. */
  26798. private _filterUniqueMaterialId;
  26799. /**
  26800. * Sets a new Standard Material as _defaultMaterial if not already set.
  26801. * @hidden
  26802. */
  26803. private _setDefaultMaterial;
  26804. /**
  26805. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26806. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26807. * @returns the SPS.
  26808. */
  26809. refreshVisibleSize(): SolidParticleSystem;
  26810. /**
  26811. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26812. * @param size the size (float) of the visibility box
  26813. * note : this doesn't lock the SPS mesh bounding box.
  26814. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26815. */
  26816. setVisibilityBox(size: number): void;
  26817. /**
  26818. * Gets whether the SPS as always visible or not
  26819. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26820. */
  26821. /**
  26822. * Sets the SPS as always visible or not
  26823. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26824. */
  26825. isAlwaysVisible: boolean;
  26826. /**
  26827. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26828. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26829. */
  26830. /**
  26831. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26832. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26833. */
  26834. isVisibilityBoxLocked: boolean;
  26835. /**
  26836. * Tells to `setParticles()` to compute the particle rotations or not.
  26837. * Default value : true. The SPS is faster when it's set to false.
  26838. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26839. */
  26840. /**
  26841. * Gets if `setParticles()` computes the particle rotations or not.
  26842. * Default value : true. The SPS is faster when it's set to false.
  26843. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26844. */
  26845. computeParticleRotation: boolean;
  26846. /**
  26847. * Tells to `setParticles()` to compute the particle colors or not.
  26848. * Default value : true. The SPS is faster when it's set to false.
  26849. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26850. */
  26851. /**
  26852. * Gets if `setParticles()` computes the particle colors or not.
  26853. * Default value : true. The SPS is faster when it's set to false.
  26854. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26855. */
  26856. computeParticleColor: boolean;
  26857. /**
  26858. * Gets if `setParticles()` computes the particle textures or not.
  26859. * Default value : true. The SPS is faster when it's set to false.
  26860. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26861. */
  26862. computeParticleTexture: boolean;
  26863. /**
  26864. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26865. * Default value : false. The SPS is faster when it's set to false.
  26866. * Note : the particle custom vertex positions aren't stored values.
  26867. */
  26868. /**
  26869. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26870. * Default value : false. The SPS is faster when it's set to false.
  26871. * Note : the particle custom vertex positions aren't stored values.
  26872. */
  26873. computeParticleVertex: boolean;
  26874. /**
  26875. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26876. */
  26877. /**
  26878. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26879. */
  26880. computeBoundingBox: boolean;
  26881. /**
  26882. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26883. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26884. * Default : `true`
  26885. */
  26886. /**
  26887. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26888. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26889. * Default : `true`
  26890. */
  26891. depthSortParticles: boolean;
  26892. /**
  26893. * Gets if the SPS is created as expandable at construction time.
  26894. * Default : `false`
  26895. */
  26896. readonly expandable: boolean;
  26897. /**
  26898. * Gets if the SPS supports the Multi Materials
  26899. */
  26900. readonly multimaterialEnabled: boolean;
  26901. /**
  26902. * Gets if the SPS uses the model materials for its own multimaterial.
  26903. */
  26904. readonly useModelMaterial: boolean;
  26905. /**
  26906. * The SPS used material array.
  26907. */
  26908. readonly materials: Material[];
  26909. /**
  26910. * Sets the SPS MultiMaterial from the passed materials.
  26911. * Note : the passed array is internally copied and not used then by reference.
  26912. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  26913. */
  26914. setMultiMaterial(materials: Material[]): void;
  26915. /**
  26916. * The SPS computed multimaterial object
  26917. */
  26918. multimaterial: MultiMaterial;
  26919. /**
  26920. * If the subMeshes must be updated on the next call to setParticles()
  26921. */
  26922. autoUpdateSubMeshes: boolean;
  26923. /**
  26924. * This function does nothing. It may be overwritten to set all the particle first values.
  26925. * The SPS doesn't call this function, you may have to call it by your own.
  26926. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26927. */
  26928. initParticles(): void;
  26929. /**
  26930. * This function does nothing. It may be overwritten to recycle a particle.
  26931. * The SPS doesn't call this function, you may have to call it by your own.
  26932. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26933. * @param particle The particle to recycle
  26934. * @returns the recycled particle
  26935. */
  26936. recycleParticle(particle: SolidParticle): SolidParticle;
  26937. /**
  26938. * Updates a particle : this function should be overwritten by the user.
  26939. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26940. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26941. * @example : just set a particle position or velocity and recycle conditions
  26942. * @param particle The particle to update
  26943. * @returns the updated particle
  26944. */
  26945. updateParticle(particle: SolidParticle): SolidParticle;
  26946. /**
  26947. * Updates a vertex of a particle : it can be overwritten by the user.
  26948. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26949. * @param particle the current particle
  26950. * @param vertex the current index of the current particle
  26951. * @param pt the index of the current vertex in the particle shape
  26952. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26953. * @example : just set a vertex particle position
  26954. * @returns the updated vertex
  26955. */
  26956. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26957. /**
  26958. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26959. * This does nothing and may be overwritten by the user.
  26960. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26961. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26962. * @param update the boolean update value actually passed to setParticles()
  26963. */
  26964. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26965. /**
  26966. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26967. * This will be passed three parameters.
  26968. * This does nothing and may be overwritten by the user.
  26969. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26970. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26971. * @param update the boolean update value actually passed to setParticles()
  26972. */
  26973. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26974. }
  26975. }
  26976. declare module BABYLON {
  26977. /**
  26978. * Represents one particle of a solid particle system.
  26979. */
  26980. export class SolidParticle {
  26981. /**
  26982. * particle global index
  26983. */
  26984. idx: number;
  26985. /**
  26986. * particle identifier
  26987. */
  26988. id: number;
  26989. /**
  26990. * The color of the particle
  26991. */
  26992. color: Nullable<Color4>;
  26993. /**
  26994. * The world space position of the particle.
  26995. */
  26996. position: Vector3;
  26997. /**
  26998. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26999. */
  27000. rotation: Vector3;
  27001. /**
  27002. * The world space rotation quaternion of the particle.
  27003. */
  27004. rotationQuaternion: Nullable<Quaternion>;
  27005. /**
  27006. * The scaling of the particle.
  27007. */
  27008. scaling: Vector3;
  27009. /**
  27010. * The uvs of the particle.
  27011. */
  27012. uvs: Vector4;
  27013. /**
  27014. * The current speed of the particle.
  27015. */
  27016. velocity: Vector3;
  27017. /**
  27018. * The pivot point in the particle local space.
  27019. */
  27020. pivot: Vector3;
  27021. /**
  27022. * Must the particle be translated from its pivot point in its local space ?
  27023. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27024. * Default : false
  27025. */
  27026. translateFromPivot: boolean;
  27027. /**
  27028. * Is the particle active or not ?
  27029. */
  27030. alive: boolean;
  27031. /**
  27032. * Is the particle visible or not ?
  27033. */
  27034. isVisible: boolean;
  27035. /**
  27036. * Index of this particle in the global "positions" array (Internal use)
  27037. * @hidden
  27038. */
  27039. _pos: number;
  27040. /**
  27041. * @hidden Index of this particle in the global "indices" array (Internal use)
  27042. */
  27043. _ind: number;
  27044. /**
  27045. * @hidden ModelShape of this particle (Internal use)
  27046. */
  27047. _model: ModelShape;
  27048. /**
  27049. * ModelShape id of this particle
  27050. */
  27051. shapeId: number;
  27052. /**
  27053. * Index of the particle in its shape id
  27054. */
  27055. idxInShape: number;
  27056. /**
  27057. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27058. */
  27059. _modelBoundingInfo: BoundingInfo;
  27060. /**
  27061. * @hidden Particle BoundingInfo object (Internal use)
  27062. */
  27063. _boundingInfo: BoundingInfo;
  27064. /**
  27065. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27066. */
  27067. _sps: SolidParticleSystem;
  27068. /**
  27069. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27070. */
  27071. _stillInvisible: boolean;
  27072. /**
  27073. * @hidden Last computed particle rotation matrix
  27074. */
  27075. _rotationMatrix: number[];
  27076. /**
  27077. * Parent particle Id, if any.
  27078. * Default null.
  27079. */
  27080. parentId: Nullable<number>;
  27081. /**
  27082. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27083. */
  27084. materialIndex: Nullable<number>;
  27085. /**
  27086. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27087. * The possible values are :
  27088. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27089. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27090. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27091. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27092. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27093. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27094. * */
  27095. cullingStrategy: number;
  27096. /**
  27097. * @hidden Internal global position in the SPS.
  27098. */
  27099. _globalPosition: Vector3;
  27100. /**
  27101. * Creates a Solid Particle object.
  27102. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27103. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27104. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27105. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27106. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27107. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27108. * @param shapeId (integer) is the model shape identifier in the SPS.
  27109. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27110. * @param sps defines the sps it is associated to
  27111. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27112. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27113. */
  27114. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27115. /**
  27116. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27117. * @param target the particle target
  27118. * @returns the current particle
  27119. */
  27120. copyToRef(target: SolidParticle): SolidParticle;
  27121. /**
  27122. * Legacy support, changed scale to scaling
  27123. */
  27124. /**
  27125. * Legacy support, changed scale to scaling
  27126. */
  27127. scale: Vector3;
  27128. /**
  27129. * Legacy support, changed quaternion to rotationQuaternion
  27130. */
  27131. /**
  27132. * Legacy support, changed quaternion to rotationQuaternion
  27133. */
  27134. quaternion: Nullable<Quaternion>;
  27135. /**
  27136. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27137. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27138. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27139. * @returns true if it intersects
  27140. */
  27141. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27142. /**
  27143. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27144. * A particle is in the frustum if its bounding box intersects the frustum
  27145. * @param frustumPlanes defines the frustum to test
  27146. * @returns true if the particle is in the frustum planes
  27147. */
  27148. isInFrustum(frustumPlanes: Plane[]): boolean;
  27149. /**
  27150. * get the rotation matrix of the particle
  27151. * @hidden
  27152. */
  27153. getRotationMatrix(m: Matrix): void;
  27154. }
  27155. /**
  27156. * Represents the shape of the model used by one particle of a solid particle system.
  27157. * SPS internal tool, don't use it manually.
  27158. */
  27159. export class ModelShape {
  27160. /**
  27161. * The shape id
  27162. * @hidden
  27163. */
  27164. shapeID: number;
  27165. /**
  27166. * flat array of model positions (internal use)
  27167. * @hidden
  27168. */
  27169. _shape: Vector3[];
  27170. /**
  27171. * flat array of model UVs (internal use)
  27172. * @hidden
  27173. */
  27174. _shapeUV: number[];
  27175. /**
  27176. * color array of the model
  27177. * @hidden
  27178. */
  27179. _shapeColors: number[];
  27180. /**
  27181. * indices array of the model
  27182. * @hidden
  27183. */
  27184. _indices: number[];
  27185. /**
  27186. * normals array of the model
  27187. * @hidden
  27188. */
  27189. _normals: number[];
  27190. /**
  27191. * length of the shape in the model indices array (internal use)
  27192. * @hidden
  27193. */
  27194. _indicesLength: number;
  27195. /**
  27196. * Custom position function (internal use)
  27197. * @hidden
  27198. */
  27199. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27200. /**
  27201. * Custom vertex function (internal use)
  27202. * @hidden
  27203. */
  27204. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27205. /**
  27206. * Model material (internal use)
  27207. * @hidden
  27208. */
  27209. _material: Nullable<Material>;
  27210. /**
  27211. * 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.
  27212. * SPS internal tool, don't use it manually.
  27213. * @hidden
  27214. */
  27215. 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>);
  27216. }
  27217. /**
  27218. * Represents a Depth Sorted Particle in the solid particle system.
  27219. * @hidden
  27220. */
  27221. export class DepthSortedParticle {
  27222. /**
  27223. * Index of the particle in the "indices" array
  27224. */
  27225. ind: number;
  27226. /**
  27227. * Length of the particle shape in the "indices" array
  27228. */
  27229. indicesLength: number;
  27230. /**
  27231. * Squared distance from the particle to the camera
  27232. */
  27233. sqDistance: number;
  27234. /**
  27235. * Material index when used with MultiMaterials
  27236. */
  27237. materialIndex: number;
  27238. /**
  27239. * Creates a new sorted particle
  27240. * @param materialIndex
  27241. */
  27242. constructor(ind: number, indLength: number, materialIndex: number);
  27243. }
  27244. }
  27245. declare module BABYLON {
  27246. /**
  27247. * @hidden
  27248. */
  27249. export class _MeshCollisionData {
  27250. _checkCollisions: boolean;
  27251. _collisionMask: number;
  27252. _collisionGroup: number;
  27253. _collider: Nullable<Collider>;
  27254. _oldPositionForCollisions: Vector3;
  27255. _diffPositionForCollisions: Vector3;
  27256. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27257. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27258. }
  27259. }
  27260. declare module BABYLON {
  27261. /** @hidden */
  27262. class _FacetDataStorage {
  27263. facetPositions: Vector3[];
  27264. facetNormals: Vector3[];
  27265. facetPartitioning: number[][];
  27266. facetNb: number;
  27267. partitioningSubdivisions: number;
  27268. partitioningBBoxRatio: number;
  27269. facetDataEnabled: boolean;
  27270. facetParameters: any;
  27271. bbSize: Vector3;
  27272. subDiv: {
  27273. max: number;
  27274. X: number;
  27275. Y: number;
  27276. Z: number;
  27277. };
  27278. facetDepthSort: boolean;
  27279. facetDepthSortEnabled: boolean;
  27280. depthSortedIndices: IndicesArray;
  27281. depthSortedFacets: {
  27282. ind: number;
  27283. sqDistance: number;
  27284. }[];
  27285. facetDepthSortFunction: (f1: {
  27286. ind: number;
  27287. sqDistance: number;
  27288. }, f2: {
  27289. ind: number;
  27290. sqDistance: number;
  27291. }) => number;
  27292. facetDepthSortFrom: Vector3;
  27293. facetDepthSortOrigin: Vector3;
  27294. invertedMatrix: Matrix;
  27295. }
  27296. /**
  27297. * @hidden
  27298. **/
  27299. class _InternalAbstractMeshDataInfo {
  27300. _hasVertexAlpha: boolean;
  27301. _useVertexColors: boolean;
  27302. _numBoneInfluencers: number;
  27303. _applyFog: boolean;
  27304. _receiveShadows: boolean;
  27305. _facetData: _FacetDataStorage;
  27306. _visibility: number;
  27307. _skeleton: Nullable<Skeleton>;
  27308. _layerMask: number;
  27309. _computeBonesUsingShaders: boolean;
  27310. _isActive: boolean;
  27311. _onlyForInstances: boolean;
  27312. _isActiveIntermediate: boolean;
  27313. _onlyForInstancesIntermediate: boolean;
  27314. _actAsRegularMesh: boolean;
  27315. }
  27316. /**
  27317. * Class used to store all common mesh properties
  27318. */
  27319. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27320. /** No occlusion */
  27321. static OCCLUSION_TYPE_NONE: number;
  27322. /** Occlusion set to optimisitic */
  27323. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27324. /** Occlusion set to strict */
  27325. static OCCLUSION_TYPE_STRICT: number;
  27326. /** Use an accurante occlusion algorithm */
  27327. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27328. /** Use a conservative occlusion algorithm */
  27329. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27330. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27331. * Test order :
  27332. * Is the bounding sphere outside the frustum ?
  27333. * If not, are the bounding box vertices outside the frustum ?
  27334. * It not, then the cullable object is in the frustum.
  27335. */
  27336. static readonly CULLINGSTRATEGY_STANDARD: number;
  27337. /** Culling strategy : Bounding Sphere Only.
  27338. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27339. * It's also less accurate than the standard because some not visible objects can still be selected.
  27340. * Test : is the bounding sphere outside the frustum ?
  27341. * If not, then the cullable object is in the frustum.
  27342. */
  27343. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27344. /** Culling strategy : Optimistic Inclusion.
  27345. * This in an inclusion test first, then the standard exclusion test.
  27346. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27347. * 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.
  27348. * Anyway, it's as accurate as the standard strategy.
  27349. * Test :
  27350. * Is the cullable object bounding sphere center in the frustum ?
  27351. * If not, apply the default culling strategy.
  27352. */
  27353. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27354. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27355. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27356. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27357. * 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.
  27358. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27359. * Test :
  27360. * Is the cullable object bounding sphere center in the frustum ?
  27361. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27362. */
  27363. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27364. /**
  27365. * No billboard
  27366. */
  27367. static readonly BILLBOARDMODE_NONE: number;
  27368. /** Billboard on X axis */
  27369. static readonly BILLBOARDMODE_X: number;
  27370. /** Billboard on Y axis */
  27371. static readonly BILLBOARDMODE_Y: number;
  27372. /** Billboard on Z axis */
  27373. static readonly BILLBOARDMODE_Z: number;
  27374. /** Billboard on all axes */
  27375. static readonly BILLBOARDMODE_ALL: number;
  27376. /** Billboard on using position instead of orientation */
  27377. static readonly BILLBOARDMODE_USE_POSITION: number;
  27378. /** @hidden */
  27379. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27380. /**
  27381. * The culling strategy to use to check whether the mesh must be rendered or not.
  27382. * This value can be changed at any time and will be used on the next render mesh selection.
  27383. * The possible values are :
  27384. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27385. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27386. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27387. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27388. * Please read each static variable documentation to get details about the culling process.
  27389. * */
  27390. cullingStrategy: number;
  27391. /**
  27392. * Gets the number of facets in the mesh
  27393. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27394. */
  27395. readonly facetNb: number;
  27396. /**
  27397. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27398. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27399. */
  27400. partitioningSubdivisions: number;
  27401. /**
  27402. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27403. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27405. */
  27406. partitioningBBoxRatio: number;
  27407. /**
  27408. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27409. * Works only for updatable meshes.
  27410. * Doesn't work with multi-materials
  27411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27412. */
  27413. mustDepthSortFacets: boolean;
  27414. /**
  27415. * The location (Vector3) where the facet depth sort must be computed from.
  27416. * By default, the active camera position.
  27417. * Used only when facet depth sort is enabled
  27418. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27419. */
  27420. facetDepthSortFrom: Vector3;
  27421. /**
  27422. * gets a boolean indicating if facetData is enabled
  27423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27424. */
  27425. readonly isFacetDataEnabled: boolean;
  27426. /** @hidden */
  27427. _updateNonUniformScalingState(value: boolean): boolean;
  27428. /**
  27429. * An event triggered when this mesh collides with another one
  27430. */
  27431. onCollideObservable: Observable<AbstractMesh>;
  27432. /** Set a function to call when this mesh collides with another one */
  27433. onCollide: () => void;
  27434. /**
  27435. * An event triggered when the collision's position changes
  27436. */
  27437. onCollisionPositionChangeObservable: Observable<Vector3>;
  27438. /** Set a function to call when the collision's position changes */
  27439. onCollisionPositionChange: () => void;
  27440. /**
  27441. * An event triggered when material is changed
  27442. */
  27443. onMaterialChangedObservable: Observable<AbstractMesh>;
  27444. /**
  27445. * Gets or sets the orientation for POV movement & rotation
  27446. */
  27447. definedFacingForward: boolean;
  27448. /** @hidden */
  27449. _occlusionQuery: Nullable<WebGLQuery>;
  27450. /** @hidden */
  27451. _renderingGroup: Nullable<RenderingGroup>;
  27452. /**
  27453. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27454. */
  27455. /**
  27456. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27457. */
  27458. visibility: number;
  27459. /** Gets or sets the alpha index used to sort transparent meshes
  27460. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27461. */
  27462. alphaIndex: number;
  27463. /**
  27464. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27465. */
  27466. isVisible: boolean;
  27467. /**
  27468. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27469. */
  27470. isPickable: boolean;
  27471. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27472. showSubMeshesBoundingBox: boolean;
  27473. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27474. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27475. */
  27476. isBlocker: boolean;
  27477. /**
  27478. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27479. */
  27480. enablePointerMoveEvents: boolean;
  27481. /**
  27482. * Specifies the rendering group id for this mesh (0 by default)
  27483. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27484. */
  27485. renderingGroupId: number;
  27486. private _material;
  27487. /** Gets or sets current material */
  27488. material: Nullable<Material>;
  27489. /**
  27490. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27491. * @see http://doc.babylonjs.com/babylon101/shadows
  27492. */
  27493. receiveShadows: boolean;
  27494. /** Defines color to use when rendering outline */
  27495. outlineColor: Color3;
  27496. /** Define width to use when rendering outline */
  27497. outlineWidth: number;
  27498. /** Defines color to use when rendering overlay */
  27499. overlayColor: Color3;
  27500. /** Defines alpha to use when rendering overlay */
  27501. overlayAlpha: number;
  27502. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27503. hasVertexAlpha: boolean;
  27504. /** 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) */
  27505. useVertexColors: boolean;
  27506. /**
  27507. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27508. */
  27509. computeBonesUsingShaders: boolean;
  27510. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27511. numBoneInfluencers: number;
  27512. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27513. applyFog: boolean;
  27514. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27515. useOctreeForRenderingSelection: boolean;
  27516. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27517. useOctreeForPicking: boolean;
  27518. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27519. useOctreeForCollisions: boolean;
  27520. /**
  27521. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27522. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27523. */
  27524. layerMask: number;
  27525. /**
  27526. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27527. */
  27528. alwaysSelectAsActiveMesh: boolean;
  27529. /**
  27530. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27531. */
  27532. doNotSyncBoundingInfo: boolean;
  27533. /**
  27534. * Gets or sets the current action manager
  27535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27536. */
  27537. actionManager: Nullable<AbstractActionManager>;
  27538. private _meshCollisionData;
  27539. /**
  27540. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27541. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27542. */
  27543. ellipsoid: Vector3;
  27544. /**
  27545. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27546. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27547. */
  27548. ellipsoidOffset: Vector3;
  27549. /**
  27550. * Gets or sets a collision mask used to mask collisions (default is -1).
  27551. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27552. */
  27553. collisionMask: number;
  27554. /**
  27555. * Gets or sets the current collision group mask (-1 by default).
  27556. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27557. */
  27558. collisionGroup: number;
  27559. /**
  27560. * Defines edge width used when edgesRenderer is enabled
  27561. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27562. */
  27563. edgesWidth: number;
  27564. /**
  27565. * Defines edge color used when edgesRenderer is enabled
  27566. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27567. */
  27568. edgesColor: Color4;
  27569. /** @hidden */
  27570. _edgesRenderer: Nullable<IEdgesRenderer>;
  27571. /** @hidden */
  27572. _masterMesh: Nullable<AbstractMesh>;
  27573. /** @hidden */
  27574. _boundingInfo: Nullable<BoundingInfo>;
  27575. /** @hidden */
  27576. _renderId: number;
  27577. /**
  27578. * Gets or sets the list of subMeshes
  27579. * @see http://doc.babylonjs.com/how_to/multi_materials
  27580. */
  27581. subMeshes: SubMesh[];
  27582. /** @hidden */
  27583. _intersectionsInProgress: AbstractMesh[];
  27584. /** @hidden */
  27585. _unIndexed: boolean;
  27586. /** @hidden */
  27587. _lightSources: Light[];
  27588. /** Gets the list of lights affecting that mesh */
  27589. readonly lightSources: Light[];
  27590. /** @hidden */
  27591. readonly _positions: Nullable<Vector3[]>;
  27592. /** @hidden */
  27593. _waitingData: {
  27594. lods: Nullable<any>;
  27595. actions: Nullable<any>;
  27596. freezeWorldMatrix: Nullable<boolean>;
  27597. };
  27598. /** @hidden */
  27599. _bonesTransformMatrices: Nullable<Float32Array>;
  27600. /** @hidden */
  27601. _transformMatrixTexture: Nullable<RawTexture>;
  27602. /**
  27603. * Gets or sets a skeleton to apply skining transformations
  27604. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27605. */
  27606. skeleton: Nullable<Skeleton>;
  27607. /**
  27608. * An event triggered when the mesh is rebuilt.
  27609. */
  27610. onRebuildObservable: Observable<AbstractMesh>;
  27611. /**
  27612. * Creates a new AbstractMesh
  27613. * @param name defines the name of the mesh
  27614. * @param scene defines the hosting scene
  27615. */
  27616. constructor(name: string, scene?: Nullable<Scene>);
  27617. /**
  27618. * Returns the string "AbstractMesh"
  27619. * @returns "AbstractMesh"
  27620. */
  27621. getClassName(): string;
  27622. /**
  27623. * Gets a string representation of the current mesh
  27624. * @param fullDetails defines a boolean indicating if full details must be included
  27625. * @returns a string representation of the current mesh
  27626. */
  27627. toString(fullDetails?: boolean): string;
  27628. /**
  27629. * @hidden
  27630. */
  27631. protected _getEffectiveParent(): Nullable<Node>;
  27632. /** @hidden */
  27633. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27634. /** @hidden */
  27635. _rebuild(): void;
  27636. /** @hidden */
  27637. _resyncLightSources(): void;
  27638. /** @hidden */
  27639. _resyncLightSource(light: Light): void;
  27640. /** @hidden */
  27641. _unBindEffect(): void;
  27642. /** @hidden */
  27643. _removeLightSource(light: Light, dispose: boolean): void;
  27644. private _markSubMeshesAsDirty;
  27645. /** @hidden */
  27646. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27647. /** @hidden */
  27648. _markSubMeshesAsAttributesDirty(): void;
  27649. /** @hidden */
  27650. _markSubMeshesAsMiscDirty(): void;
  27651. /**
  27652. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27653. */
  27654. scaling: Vector3;
  27655. /**
  27656. * Returns true if the mesh is blocked. Implemented by child classes
  27657. */
  27658. readonly isBlocked: boolean;
  27659. /**
  27660. * Returns the mesh itself by default. Implemented by child classes
  27661. * @param camera defines the camera to use to pick the right LOD level
  27662. * @returns the currentAbstractMesh
  27663. */
  27664. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27665. /**
  27666. * Returns 0 by default. Implemented by child classes
  27667. * @returns an integer
  27668. */
  27669. getTotalVertices(): number;
  27670. /**
  27671. * Returns a positive integer : the total number of indices in this mesh geometry.
  27672. * @returns the numner of indices or zero if the mesh has no geometry.
  27673. */
  27674. getTotalIndices(): number;
  27675. /**
  27676. * Returns null by default. Implemented by child classes
  27677. * @returns null
  27678. */
  27679. getIndices(): Nullable<IndicesArray>;
  27680. /**
  27681. * Returns the array of the requested vertex data kind. Implemented by child classes
  27682. * @param kind defines the vertex data kind to use
  27683. * @returns null
  27684. */
  27685. getVerticesData(kind: string): Nullable<FloatArray>;
  27686. /**
  27687. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27688. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27689. * Note that a new underlying VertexBuffer object is created each call.
  27690. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27691. * @param kind defines vertex data kind:
  27692. * * VertexBuffer.PositionKind
  27693. * * VertexBuffer.UVKind
  27694. * * VertexBuffer.UV2Kind
  27695. * * VertexBuffer.UV3Kind
  27696. * * VertexBuffer.UV4Kind
  27697. * * VertexBuffer.UV5Kind
  27698. * * VertexBuffer.UV6Kind
  27699. * * VertexBuffer.ColorKind
  27700. * * VertexBuffer.MatricesIndicesKind
  27701. * * VertexBuffer.MatricesIndicesExtraKind
  27702. * * VertexBuffer.MatricesWeightsKind
  27703. * * VertexBuffer.MatricesWeightsExtraKind
  27704. * @param data defines the data source
  27705. * @param updatable defines if the data must be flagged as updatable (or static)
  27706. * @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
  27707. * @returns the current mesh
  27708. */
  27709. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27710. /**
  27711. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27712. * If the mesh has no geometry, it is simply returned as it is.
  27713. * @param kind defines vertex data kind:
  27714. * * VertexBuffer.PositionKind
  27715. * * VertexBuffer.UVKind
  27716. * * VertexBuffer.UV2Kind
  27717. * * VertexBuffer.UV3Kind
  27718. * * VertexBuffer.UV4Kind
  27719. * * VertexBuffer.UV5Kind
  27720. * * VertexBuffer.UV6Kind
  27721. * * VertexBuffer.ColorKind
  27722. * * VertexBuffer.MatricesIndicesKind
  27723. * * VertexBuffer.MatricesIndicesExtraKind
  27724. * * VertexBuffer.MatricesWeightsKind
  27725. * * VertexBuffer.MatricesWeightsExtraKind
  27726. * @param data defines the data source
  27727. * @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
  27728. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27729. * @returns the current mesh
  27730. */
  27731. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27732. /**
  27733. * Sets the mesh indices,
  27734. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27735. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27736. * @param totalVertices Defines the total number of vertices
  27737. * @returns the current mesh
  27738. */
  27739. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27740. /**
  27741. * Gets a boolean indicating if specific vertex data is present
  27742. * @param kind defines the vertex data kind to use
  27743. * @returns true is data kind is present
  27744. */
  27745. isVerticesDataPresent(kind: string): boolean;
  27746. /**
  27747. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27748. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27749. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27750. * @returns a BoundingInfo
  27751. */
  27752. getBoundingInfo(): BoundingInfo;
  27753. /**
  27754. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27755. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27756. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27757. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27758. * @returns the current mesh
  27759. */
  27760. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27761. /**
  27762. * Overwrite the current bounding info
  27763. * @param boundingInfo defines the new bounding info
  27764. * @returns the current mesh
  27765. */
  27766. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27767. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27768. readonly useBones: boolean;
  27769. /** @hidden */
  27770. _preActivate(): void;
  27771. /** @hidden */
  27772. _preActivateForIntermediateRendering(renderId: number): void;
  27773. /** @hidden */
  27774. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27775. /** @hidden */
  27776. _postActivate(): void;
  27777. /** @hidden */
  27778. _freeze(): void;
  27779. /** @hidden */
  27780. _unFreeze(): void;
  27781. /**
  27782. * Gets the current world matrix
  27783. * @returns a Matrix
  27784. */
  27785. getWorldMatrix(): Matrix;
  27786. /** @hidden */
  27787. _getWorldMatrixDeterminant(): number;
  27788. /**
  27789. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27790. */
  27791. readonly isAnInstance: boolean;
  27792. /**
  27793. * Gets a boolean indicating if this mesh has instances
  27794. */
  27795. readonly hasInstances: boolean;
  27796. /**
  27797. * Perform relative position change from the point of view of behind the front of the mesh.
  27798. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27799. * Supports definition of mesh facing forward or backward
  27800. * @param amountRight defines the distance on the right axis
  27801. * @param amountUp defines the distance on the up axis
  27802. * @param amountForward defines the distance on the forward axis
  27803. * @returns the current mesh
  27804. */
  27805. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27806. /**
  27807. * Calculate relative position change from the point of view of behind the front of the mesh.
  27808. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27809. * Supports definition of mesh facing forward or backward
  27810. * @param amountRight defines the distance on the right axis
  27811. * @param amountUp defines the distance on the up axis
  27812. * @param amountForward defines the distance on the forward axis
  27813. * @returns the new displacement vector
  27814. */
  27815. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27816. /**
  27817. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27818. * Supports definition of mesh facing forward or backward
  27819. * @param flipBack defines the flip
  27820. * @param twirlClockwise defines the twirl
  27821. * @param tiltRight defines the tilt
  27822. * @returns the current mesh
  27823. */
  27824. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27825. /**
  27826. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27827. * Supports definition of mesh facing forward or backward.
  27828. * @param flipBack defines the flip
  27829. * @param twirlClockwise defines the twirl
  27830. * @param tiltRight defines the tilt
  27831. * @returns the new rotation vector
  27832. */
  27833. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27834. /**
  27835. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27836. * This means the mesh underlying bounding box and sphere are recomputed.
  27837. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27838. * @returns the current mesh
  27839. */
  27840. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27841. /** @hidden */
  27842. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27843. /** @hidden */
  27844. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27845. /** @hidden */
  27846. _updateBoundingInfo(): AbstractMesh;
  27847. /** @hidden */
  27848. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27849. /** @hidden */
  27850. protected _afterComputeWorldMatrix(): void;
  27851. /** @hidden */
  27852. readonly _effectiveMesh: AbstractMesh;
  27853. /**
  27854. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27855. * A mesh is in the frustum if its bounding box intersects the frustum
  27856. * @param frustumPlanes defines the frustum to test
  27857. * @returns true if the mesh is in the frustum planes
  27858. */
  27859. isInFrustum(frustumPlanes: Plane[]): boolean;
  27860. /**
  27861. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27862. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27863. * @param frustumPlanes defines the frustum to test
  27864. * @returns true if the mesh is completely in the frustum planes
  27865. */
  27866. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27867. /**
  27868. * True if the mesh intersects another mesh or a SolidParticle object
  27869. * @param mesh defines a target mesh or SolidParticle to test
  27870. * @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)
  27871. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27872. * @returns true if there is an intersection
  27873. */
  27874. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27875. /**
  27876. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27877. * @param point defines the point to test
  27878. * @returns true if there is an intersection
  27879. */
  27880. intersectsPoint(point: Vector3): boolean;
  27881. /**
  27882. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27883. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27884. */
  27885. checkCollisions: boolean;
  27886. /**
  27887. * Gets Collider object used to compute collisions (not physics)
  27888. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27889. */
  27890. readonly collider: Nullable<Collider>;
  27891. /**
  27892. * Move the mesh using collision engine
  27893. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27894. * @param displacement defines the requested displacement vector
  27895. * @returns the current mesh
  27896. */
  27897. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27898. private _onCollisionPositionChange;
  27899. /** @hidden */
  27900. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27901. /** @hidden */
  27902. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27903. /** @hidden */
  27904. _checkCollision(collider: Collider): AbstractMesh;
  27905. /** @hidden */
  27906. _generatePointsArray(): boolean;
  27907. /**
  27908. * Checks if the passed Ray intersects with the mesh
  27909. * @param ray defines the ray to use
  27910. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27911. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27912. * @returns the picking info
  27913. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27914. */
  27915. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27916. /**
  27917. * Clones the current mesh
  27918. * @param name defines the mesh name
  27919. * @param newParent defines the new mesh parent
  27920. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27921. * @returns the new mesh
  27922. */
  27923. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27924. /**
  27925. * Disposes all the submeshes of the current meshnp
  27926. * @returns the current mesh
  27927. */
  27928. releaseSubMeshes(): AbstractMesh;
  27929. /**
  27930. * Releases resources associated with this abstract mesh.
  27931. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27932. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27933. */
  27934. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27935. /**
  27936. * Adds the passed mesh as a child to the current mesh
  27937. * @param mesh defines the child mesh
  27938. * @returns the current mesh
  27939. */
  27940. addChild(mesh: AbstractMesh): AbstractMesh;
  27941. /**
  27942. * Removes the passed mesh from the current mesh children list
  27943. * @param mesh defines the child mesh
  27944. * @returns the current mesh
  27945. */
  27946. removeChild(mesh: AbstractMesh): AbstractMesh;
  27947. /** @hidden */
  27948. private _initFacetData;
  27949. /**
  27950. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27951. * This method can be called within the render loop.
  27952. * 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
  27953. * @returns the current mesh
  27954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27955. */
  27956. updateFacetData(): AbstractMesh;
  27957. /**
  27958. * Returns the facetLocalNormals array.
  27959. * The normals are expressed in the mesh local spac
  27960. * @returns an array of Vector3
  27961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27962. */
  27963. getFacetLocalNormals(): Vector3[];
  27964. /**
  27965. * Returns the facetLocalPositions array.
  27966. * The facet positions are expressed in the mesh local space
  27967. * @returns an array of Vector3
  27968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27969. */
  27970. getFacetLocalPositions(): Vector3[];
  27971. /**
  27972. * Returns the facetLocalPartioning array
  27973. * @returns an array of array of numbers
  27974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27975. */
  27976. getFacetLocalPartitioning(): number[][];
  27977. /**
  27978. * Returns the i-th facet position in the world system.
  27979. * This method allocates a new Vector3 per call
  27980. * @param i defines the facet index
  27981. * @returns a new Vector3
  27982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27983. */
  27984. getFacetPosition(i: number): Vector3;
  27985. /**
  27986. * Sets the reference Vector3 with the i-th facet position in the world system
  27987. * @param i defines the facet index
  27988. * @param ref defines the target vector
  27989. * @returns the current mesh
  27990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27991. */
  27992. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27993. /**
  27994. * Returns the i-th facet normal in the world system.
  27995. * This method allocates a new Vector3 per call
  27996. * @param i defines the facet index
  27997. * @returns a new Vector3
  27998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27999. */
  28000. getFacetNormal(i: number): Vector3;
  28001. /**
  28002. * Sets the reference Vector3 with the i-th facet normal in the world system
  28003. * @param i defines the facet index
  28004. * @param ref defines the target vector
  28005. * @returns the current mesh
  28006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28007. */
  28008. getFacetNormalToRef(i: number, ref: Vector3): this;
  28009. /**
  28010. * 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)
  28011. * @param x defines x coordinate
  28012. * @param y defines y coordinate
  28013. * @param z defines z coordinate
  28014. * @returns the array of facet indexes
  28015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28016. */
  28017. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28018. /**
  28019. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28020. * @param projected sets as the (x,y,z) world projection on the facet
  28021. * @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
  28022. * @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
  28023. * @param x defines x coordinate
  28024. * @param y defines y coordinate
  28025. * @param z defines z coordinate
  28026. * @returns the face index if found (or null instead)
  28027. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28028. */
  28029. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28030. /**
  28031. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28032. * @param projected sets as the (x,y,z) local projection on the facet
  28033. * @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
  28034. * @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
  28035. * @param x defines x coordinate
  28036. * @param y defines y coordinate
  28037. * @param z defines z coordinate
  28038. * @returns the face index if found (or null instead)
  28039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28040. */
  28041. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28042. /**
  28043. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28044. * @returns the parameters
  28045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28046. */
  28047. getFacetDataParameters(): any;
  28048. /**
  28049. * Disables the feature FacetData and frees the related memory
  28050. * @returns the current mesh
  28051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28052. */
  28053. disableFacetData(): AbstractMesh;
  28054. /**
  28055. * Updates the AbstractMesh indices array
  28056. * @param indices defines the data source
  28057. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28058. * @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)
  28059. * @returns the current mesh
  28060. */
  28061. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28062. /**
  28063. * Creates new normals data for the mesh
  28064. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28065. * @returns the current mesh
  28066. */
  28067. createNormals(updatable: boolean): AbstractMesh;
  28068. /**
  28069. * Align the mesh with a normal
  28070. * @param normal defines the normal to use
  28071. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28072. * @returns the current mesh
  28073. */
  28074. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28075. /** @hidden */
  28076. _checkOcclusionQuery(): boolean;
  28077. /**
  28078. * Disables the mesh edge rendering mode
  28079. * @returns the currentAbstractMesh
  28080. */
  28081. disableEdgesRendering(): AbstractMesh;
  28082. /**
  28083. * Enables the edge rendering mode on the mesh.
  28084. * This mode makes the mesh edges visible
  28085. * @param epsilon defines the maximal distance between two angles to detect a face
  28086. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28087. * @returns the currentAbstractMesh
  28088. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28089. */
  28090. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28091. }
  28092. }
  28093. declare module BABYLON {
  28094. /**
  28095. * Interface used to define ActionEvent
  28096. */
  28097. export interface IActionEvent {
  28098. /** The mesh or sprite that triggered the action */
  28099. source: any;
  28100. /** The X mouse cursor position at the time of the event */
  28101. pointerX: number;
  28102. /** The Y mouse cursor position at the time of the event */
  28103. pointerY: number;
  28104. /** The mesh that is currently pointed at (can be null) */
  28105. meshUnderPointer: Nullable<AbstractMesh>;
  28106. /** the original (browser) event that triggered the ActionEvent */
  28107. sourceEvent?: any;
  28108. /** additional data for the event */
  28109. additionalData?: any;
  28110. }
  28111. /**
  28112. * ActionEvent is the event being sent when an action is triggered.
  28113. */
  28114. export class ActionEvent implements IActionEvent {
  28115. /** The mesh or sprite that triggered the action */
  28116. source: any;
  28117. /** The X mouse cursor position at the time of the event */
  28118. pointerX: number;
  28119. /** The Y mouse cursor position at the time of the event */
  28120. pointerY: number;
  28121. /** The mesh that is currently pointed at (can be null) */
  28122. meshUnderPointer: Nullable<AbstractMesh>;
  28123. /** the original (browser) event that triggered the ActionEvent */
  28124. sourceEvent?: any;
  28125. /** additional data for the event */
  28126. additionalData?: any;
  28127. /**
  28128. * Creates a new ActionEvent
  28129. * @param source The mesh or sprite that triggered the action
  28130. * @param pointerX The X mouse cursor position at the time of the event
  28131. * @param pointerY The Y mouse cursor position at the time of the event
  28132. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28133. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28134. * @param additionalData additional data for the event
  28135. */
  28136. constructor(
  28137. /** The mesh or sprite that triggered the action */
  28138. source: any,
  28139. /** The X mouse cursor position at the time of the event */
  28140. pointerX: number,
  28141. /** The Y mouse cursor position at the time of the event */
  28142. pointerY: number,
  28143. /** The mesh that is currently pointed at (can be null) */
  28144. meshUnderPointer: Nullable<AbstractMesh>,
  28145. /** the original (browser) event that triggered the ActionEvent */
  28146. sourceEvent?: any,
  28147. /** additional data for the event */
  28148. additionalData?: any);
  28149. /**
  28150. * Helper function to auto-create an ActionEvent from a source mesh.
  28151. * @param source The source mesh that triggered the event
  28152. * @param evt The original (browser) event
  28153. * @param additionalData additional data for the event
  28154. * @returns the new ActionEvent
  28155. */
  28156. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28157. /**
  28158. * Helper function to auto-create an ActionEvent from a source sprite
  28159. * @param source The source sprite that triggered the event
  28160. * @param scene Scene associated with the sprite
  28161. * @param evt The original (browser) event
  28162. * @param additionalData additional data for the event
  28163. * @returns the new ActionEvent
  28164. */
  28165. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28166. /**
  28167. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28168. * @param scene the scene where the event occurred
  28169. * @param evt The original (browser) event
  28170. * @returns the new ActionEvent
  28171. */
  28172. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28173. /**
  28174. * Helper function to auto-create an ActionEvent from a primitive
  28175. * @param prim defines the target primitive
  28176. * @param pointerPos defines the pointer position
  28177. * @param evt The original (browser) event
  28178. * @param additionalData additional data for the event
  28179. * @returns the new ActionEvent
  28180. */
  28181. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28182. }
  28183. }
  28184. declare module BABYLON {
  28185. /**
  28186. * Abstract class used to decouple action Manager from scene and meshes.
  28187. * Do not instantiate.
  28188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28189. */
  28190. export abstract class AbstractActionManager implements IDisposable {
  28191. /** Gets the list of active triggers */
  28192. static Triggers: {
  28193. [key: string]: number;
  28194. };
  28195. /** Gets the cursor to use when hovering items */
  28196. hoverCursor: string;
  28197. /** Gets the list of actions */
  28198. actions: IAction[];
  28199. /**
  28200. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28201. */
  28202. isRecursive: boolean;
  28203. /**
  28204. * Releases all associated resources
  28205. */
  28206. abstract dispose(): void;
  28207. /**
  28208. * Does this action manager has pointer triggers
  28209. */
  28210. abstract readonly hasPointerTriggers: boolean;
  28211. /**
  28212. * Does this action manager has pick triggers
  28213. */
  28214. abstract readonly hasPickTriggers: boolean;
  28215. /**
  28216. * Process a specific trigger
  28217. * @param trigger defines the trigger to process
  28218. * @param evt defines the event details to be processed
  28219. */
  28220. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28221. /**
  28222. * Does this action manager handles actions of any of the given triggers
  28223. * @param triggers defines the triggers to be tested
  28224. * @return a boolean indicating whether one (or more) of the triggers is handled
  28225. */
  28226. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28227. /**
  28228. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28229. * speed.
  28230. * @param triggerA defines the trigger to be tested
  28231. * @param triggerB defines the trigger to be tested
  28232. * @return a boolean indicating whether one (or more) of the triggers is handled
  28233. */
  28234. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28235. /**
  28236. * Does this action manager handles actions of a given trigger
  28237. * @param trigger defines the trigger to be tested
  28238. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28239. * @return whether the trigger is handled
  28240. */
  28241. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28242. /**
  28243. * Serialize this manager to a JSON object
  28244. * @param name defines the property name to store this manager
  28245. * @returns a JSON representation of this manager
  28246. */
  28247. abstract serialize(name: string): any;
  28248. /**
  28249. * Registers an action to this action manager
  28250. * @param action defines the action to be registered
  28251. * @return the action amended (prepared) after registration
  28252. */
  28253. abstract registerAction(action: IAction): Nullable<IAction>;
  28254. /**
  28255. * Unregisters an action to this action manager
  28256. * @param action defines the action to be unregistered
  28257. * @return a boolean indicating whether the action has been unregistered
  28258. */
  28259. abstract unregisterAction(action: IAction): Boolean;
  28260. /**
  28261. * Does exist one action manager with at least one trigger
  28262. **/
  28263. static readonly HasTriggers: boolean;
  28264. /**
  28265. * Does exist one action manager with at least one pick trigger
  28266. **/
  28267. static readonly HasPickTriggers: boolean;
  28268. /**
  28269. * Does exist one action manager that handles actions of a given trigger
  28270. * @param trigger defines the trigger to be tested
  28271. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28272. **/
  28273. static HasSpecificTrigger(trigger: number): boolean;
  28274. }
  28275. }
  28276. declare module BABYLON {
  28277. /**
  28278. * Defines how a node can be built from a string name.
  28279. */
  28280. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28281. /**
  28282. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28283. */
  28284. export class Node implements IBehaviorAware<Node> {
  28285. /** @hidden */
  28286. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28287. private static _NodeConstructors;
  28288. /**
  28289. * Add a new node constructor
  28290. * @param type defines the type name of the node to construct
  28291. * @param constructorFunc defines the constructor function
  28292. */
  28293. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28294. /**
  28295. * Returns a node constructor based on type name
  28296. * @param type defines the type name
  28297. * @param name defines the new node name
  28298. * @param scene defines the hosting scene
  28299. * @param options defines optional options to transmit to constructors
  28300. * @returns the new constructor or null
  28301. */
  28302. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28303. /**
  28304. * Gets or sets the name of the node
  28305. */
  28306. name: string;
  28307. /**
  28308. * Gets or sets the id of the node
  28309. */
  28310. id: string;
  28311. /**
  28312. * Gets or sets the unique id of the node
  28313. */
  28314. uniqueId: number;
  28315. /**
  28316. * Gets or sets a string used to store user defined state for the node
  28317. */
  28318. state: string;
  28319. /**
  28320. * Gets or sets an object used to store user defined information for the node
  28321. */
  28322. metadata: any;
  28323. /**
  28324. * For internal use only. Please do not use.
  28325. */
  28326. reservedDataStore: any;
  28327. /**
  28328. * List of inspectable custom properties (used by the Inspector)
  28329. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28330. */
  28331. inspectableCustomProperties: IInspectable[];
  28332. private _doNotSerialize;
  28333. /**
  28334. * Gets or sets a boolean used to define if the node must be serialized
  28335. */
  28336. doNotSerialize: boolean;
  28337. /** @hidden */
  28338. _isDisposed: boolean;
  28339. /**
  28340. * Gets a list of Animations associated with the node
  28341. */
  28342. animations: Animation[];
  28343. protected _ranges: {
  28344. [name: string]: Nullable<AnimationRange>;
  28345. };
  28346. /**
  28347. * Callback raised when the node is ready to be used
  28348. */
  28349. onReady: Nullable<(node: Node) => void>;
  28350. private _isEnabled;
  28351. private _isParentEnabled;
  28352. private _isReady;
  28353. /** @hidden */
  28354. _currentRenderId: number;
  28355. private _parentUpdateId;
  28356. /** @hidden */
  28357. _childUpdateId: number;
  28358. /** @hidden */
  28359. _waitingParentId: Nullable<string>;
  28360. /** @hidden */
  28361. _scene: Scene;
  28362. /** @hidden */
  28363. _cache: any;
  28364. private _parentNode;
  28365. private _children;
  28366. /** @hidden */
  28367. _worldMatrix: Matrix;
  28368. /** @hidden */
  28369. _worldMatrixDeterminant: number;
  28370. /** @hidden */
  28371. _worldMatrixDeterminantIsDirty: boolean;
  28372. /** @hidden */
  28373. private _sceneRootNodesIndex;
  28374. /**
  28375. * Gets a boolean indicating if the node has been disposed
  28376. * @returns true if the node was disposed
  28377. */
  28378. isDisposed(): boolean;
  28379. /**
  28380. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28381. * @see https://doc.babylonjs.com/how_to/parenting
  28382. */
  28383. parent: Nullable<Node>;
  28384. /** @hidden */
  28385. _addToSceneRootNodes(): void;
  28386. /** @hidden */
  28387. _removeFromSceneRootNodes(): void;
  28388. private _animationPropertiesOverride;
  28389. /**
  28390. * Gets or sets the animation properties override
  28391. */
  28392. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28393. /**
  28394. * Gets a string idenfifying the name of the class
  28395. * @returns "Node" string
  28396. */
  28397. getClassName(): string;
  28398. /** @hidden */
  28399. readonly _isNode: boolean;
  28400. /**
  28401. * An event triggered when the mesh is disposed
  28402. */
  28403. onDisposeObservable: Observable<Node>;
  28404. private _onDisposeObserver;
  28405. /**
  28406. * Sets a callback that will be raised when the node will be disposed
  28407. */
  28408. onDispose: () => void;
  28409. /**
  28410. * Creates a new Node
  28411. * @param name the name and id to be given to this node
  28412. * @param scene the scene this node will be added to
  28413. */
  28414. constructor(name: string, scene?: Nullable<Scene>);
  28415. /**
  28416. * Gets the scene of the node
  28417. * @returns a scene
  28418. */
  28419. getScene(): Scene;
  28420. /**
  28421. * Gets the engine of the node
  28422. * @returns a Engine
  28423. */
  28424. getEngine(): Engine;
  28425. private _behaviors;
  28426. /**
  28427. * Attach a behavior to the node
  28428. * @see http://doc.babylonjs.com/features/behaviour
  28429. * @param behavior defines the behavior to attach
  28430. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28431. * @returns the current Node
  28432. */
  28433. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28434. /**
  28435. * Remove an attached behavior
  28436. * @see http://doc.babylonjs.com/features/behaviour
  28437. * @param behavior defines the behavior to attach
  28438. * @returns the current Node
  28439. */
  28440. removeBehavior(behavior: Behavior<Node>): Node;
  28441. /**
  28442. * Gets the list of attached behaviors
  28443. * @see http://doc.babylonjs.com/features/behaviour
  28444. */
  28445. readonly behaviors: Behavior<Node>[];
  28446. /**
  28447. * Gets an attached behavior by name
  28448. * @param name defines the name of the behavior to look for
  28449. * @see http://doc.babylonjs.com/features/behaviour
  28450. * @returns null if behavior was not found else the requested behavior
  28451. */
  28452. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28453. /**
  28454. * Returns the latest update of the World matrix
  28455. * @returns a Matrix
  28456. */
  28457. getWorldMatrix(): Matrix;
  28458. /** @hidden */
  28459. _getWorldMatrixDeterminant(): number;
  28460. /**
  28461. * Returns directly the latest state of the mesh World matrix.
  28462. * A Matrix is returned.
  28463. */
  28464. readonly worldMatrixFromCache: Matrix;
  28465. /** @hidden */
  28466. _initCache(): void;
  28467. /** @hidden */
  28468. updateCache(force?: boolean): void;
  28469. /** @hidden */
  28470. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28471. /** @hidden */
  28472. _updateCache(ignoreParentClass?: boolean): void;
  28473. /** @hidden */
  28474. _isSynchronized(): boolean;
  28475. /** @hidden */
  28476. _markSyncedWithParent(): void;
  28477. /** @hidden */
  28478. isSynchronizedWithParent(): boolean;
  28479. /** @hidden */
  28480. isSynchronized(): boolean;
  28481. /**
  28482. * Is this node ready to be used/rendered
  28483. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28484. * @return true if the node is ready
  28485. */
  28486. isReady(completeCheck?: boolean): boolean;
  28487. /**
  28488. * Is this node enabled?
  28489. * 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
  28490. * @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
  28491. * @return whether this node (and its parent) is enabled
  28492. */
  28493. isEnabled(checkAncestors?: boolean): boolean;
  28494. /** @hidden */
  28495. protected _syncParentEnabledState(): void;
  28496. /**
  28497. * Set the enabled state of this node
  28498. * @param value defines the new enabled state
  28499. */
  28500. setEnabled(value: boolean): void;
  28501. /**
  28502. * Is this node a descendant of the given node?
  28503. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28504. * @param ancestor defines the parent node to inspect
  28505. * @returns a boolean indicating if this node is a descendant of the given node
  28506. */
  28507. isDescendantOf(ancestor: Node): boolean;
  28508. /** @hidden */
  28509. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28510. /**
  28511. * Will return all nodes that have this node as ascendant
  28512. * @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
  28513. * @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
  28514. * @return all children nodes of all types
  28515. */
  28516. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28517. /**
  28518. * Get all child-meshes of this node
  28519. * @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)
  28520. * @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
  28521. * @returns an array of AbstractMesh
  28522. */
  28523. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28524. /**
  28525. * Get all direct children of this node
  28526. * @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
  28527. * @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)
  28528. * @returns an array of Node
  28529. */
  28530. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28531. /** @hidden */
  28532. _setReady(state: boolean): void;
  28533. /**
  28534. * Get an animation by name
  28535. * @param name defines the name of the animation to look for
  28536. * @returns null if not found else the requested animation
  28537. */
  28538. getAnimationByName(name: string): Nullable<Animation>;
  28539. /**
  28540. * Creates an animation range for this node
  28541. * @param name defines the name of the range
  28542. * @param from defines the starting key
  28543. * @param to defines the end key
  28544. */
  28545. createAnimationRange(name: string, from: number, to: number): void;
  28546. /**
  28547. * Delete a specific animation range
  28548. * @param name defines the name of the range to delete
  28549. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28550. */
  28551. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28552. /**
  28553. * Get an animation range by name
  28554. * @param name defines the name of the animation range to look for
  28555. * @returns null if not found else the requested animation range
  28556. */
  28557. getAnimationRange(name: string): Nullable<AnimationRange>;
  28558. /**
  28559. * Gets the list of all animation ranges defined on this node
  28560. * @returns an array
  28561. */
  28562. getAnimationRanges(): Nullable<AnimationRange>[];
  28563. /**
  28564. * Will start the animation sequence
  28565. * @param name defines the range frames for animation sequence
  28566. * @param loop defines if the animation should loop (false by default)
  28567. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28568. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28569. * @returns the object created for this animation. If range does not exist, it will return null
  28570. */
  28571. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28572. /**
  28573. * Serialize animation ranges into a JSON compatible object
  28574. * @returns serialization object
  28575. */
  28576. serializeAnimationRanges(): any;
  28577. /**
  28578. * Computes the world matrix of the node
  28579. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28580. * @returns the world matrix
  28581. */
  28582. computeWorldMatrix(force?: boolean): Matrix;
  28583. /**
  28584. * Releases resources associated with this node.
  28585. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28586. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28587. */
  28588. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28589. /**
  28590. * Parse animation range data from a serialization object and store them into a given node
  28591. * @param node defines where to store the animation ranges
  28592. * @param parsedNode defines the serialization object to read data from
  28593. * @param scene defines the hosting scene
  28594. */
  28595. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28596. /**
  28597. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28598. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28599. * @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
  28600. * @returns the new bounding vectors
  28601. */
  28602. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28603. min: Vector3;
  28604. max: Vector3;
  28605. };
  28606. }
  28607. }
  28608. declare module BABYLON {
  28609. /**
  28610. * @hidden
  28611. */
  28612. export class _IAnimationState {
  28613. key: number;
  28614. repeatCount: number;
  28615. workValue?: any;
  28616. loopMode?: number;
  28617. offsetValue?: any;
  28618. highLimitValue?: any;
  28619. }
  28620. /**
  28621. * Class used to store any kind of animation
  28622. */
  28623. export class Animation {
  28624. /**Name of the animation */
  28625. name: string;
  28626. /**Property to animate */
  28627. targetProperty: string;
  28628. /**The frames per second of the animation */
  28629. framePerSecond: number;
  28630. /**The data type of the animation */
  28631. dataType: number;
  28632. /**The loop mode of the animation */
  28633. loopMode?: number | undefined;
  28634. /**Specifies if blending should be enabled */
  28635. enableBlending?: boolean | undefined;
  28636. /**
  28637. * Use matrix interpolation instead of using direct key value when animating matrices
  28638. */
  28639. static AllowMatricesInterpolation: boolean;
  28640. /**
  28641. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28642. */
  28643. static AllowMatrixDecomposeForInterpolation: boolean;
  28644. /**
  28645. * Stores the key frames of the animation
  28646. */
  28647. private _keys;
  28648. /**
  28649. * Stores the easing function of the animation
  28650. */
  28651. private _easingFunction;
  28652. /**
  28653. * @hidden Internal use only
  28654. */
  28655. _runtimeAnimations: RuntimeAnimation[];
  28656. /**
  28657. * The set of event that will be linked to this animation
  28658. */
  28659. private _events;
  28660. /**
  28661. * Stores an array of target property paths
  28662. */
  28663. targetPropertyPath: string[];
  28664. /**
  28665. * Stores the blending speed of the animation
  28666. */
  28667. blendingSpeed: number;
  28668. /**
  28669. * Stores the animation ranges for the animation
  28670. */
  28671. private _ranges;
  28672. /**
  28673. * @hidden Internal use
  28674. */
  28675. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28676. /**
  28677. * Sets up an animation
  28678. * @param property The property to animate
  28679. * @param animationType The animation type to apply
  28680. * @param framePerSecond The frames per second of the animation
  28681. * @param easingFunction The easing function used in the animation
  28682. * @returns The created animation
  28683. */
  28684. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28685. /**
  28686. * Create and start an animation on a node
  28687. * @param name defines the name of the global animation that will be run on all nodes
  28688. * @param node defines the root node where the animation will take place
  28689. * @param targetProperty defines property to animate
  28690. * @param framePerSecond defines the number of frame per second yo use
  28691. * @param totalFrame defines the number of frames in total
  28692. * @param from defines the initial value
  28693. * @param to defines the final value
  28694. * @param loopMode defines which loop mode you want to use (off by default)
  28695. * @param easingFunction defines the easing function to use (linear by default)
  28696. * @param onAnimationEnd defines the callback to call when animation end
  28697. * @returns the animatable created for this animation
  28698. */
  28699. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28700. /**
  28701. * Create and start an animation on a node and its descendants
  28702. * @param name defines the name of the global animation that will be run on all nodes
  28703. * @param node defines the root node where the animation will take place
  28704. * @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
  28705. * @param targetProperty defines property to animate
  28706. * @param framePerSecond defines the number of frame per second to use
  28707. * @param totalFrame defines the number of frames in total
  28708. * @param from defines the initial value
  28709. * @param to defines the final value
  28710. * @param loopMode defines which loop mode you want to use (off by default)
  28711. * @param easingFunction defines the easing function to use (linear by default)
  28712. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28713. * @returns the list of animatables created for all nodes
  28714. * @example https://www.babylonjs-playground.com/#MH0VLI
  28715. */
  28716. 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[]>;
  28717. /**
  28718. * Creates a new animation, merges it with the existing animations and starts it
  28719. * @param name Name of the animation
  28720. * @param node Node which contains the scene that begins the animations
  28721. * @param targetProperty Specifies which property to animate
  28722. * @param framePerSecond The frames per second of the animation
  28723. * @param totalFrame The total number of frames
  28724. * @param from The frame at the beginning of the animation
  28725. * @param to The frame at the end of the animation
  28726. * @param loopMode Specifies the loop mode of the animation
  28727. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28728. * @param onAnimationEnd Callback to run once the animation is complete
  28729. * @returns Nullable animation
  28730. */
  28731. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28732. /**
  28733. * Transition property of an host to the target Value
  28734. * @param property The property to transition
  28735. * @param targetValue The target Value of the property
  28736. * @param host The object where the property to animate belongs
  28737. * @param scene Scene used to run the animation
  28738. * @param frameRate Framerate (in frame/s) to use
  28739. * @param transition The transition type we want to use
  28740. * @param duration The duration of the animation, in milliseconds
  28741. * @param onAnimationEnd Callback trigger at the end of the animation
  28742. * @returns Nullable animation
  28743. */
  28744. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28745. /**
  28746. * Return the array of runtime animations currently using this animation
  28747. */
  28748. readonly runtimeAnimations: RuntimeAnimation[];
  28749. /**
  28750. * Specifies if any of the runtime animations are currently running
  28751. */
  28752. readonly hasRunningRuntimeAnimations: boolean;
  28753. /**
  28754. * Initializes the animation
  28755. * @param name Name of the animation
  28756. * @param targetProperty Property to animate
  28757. * @param framePerSecond The frames per second of the animation
  28758. * @param dataType The data type of the animation
  28759. * @param loopMode The loop mode of the animation
  28760. * @param enableBlending Specifies if blending should be enabled
  28761. */
  28762. constructor(
  28763. /**Name of the animation */
  28764. name: string,
  28765. /**Property to animate */
  28766. targetProperty: string,
  28767. /**The frames per second of the animation */
  28768. framePerSecond: number,
  28769. /**The data type of the animation */
  28770. dataType: number,
  28771. /**The loop mode of the animation */
  28772. loopMode?: number | undefined,
  28773. /**Specifies if blending should be enabled */
  28774. enableBlending?: boolean | undefined);
  28775. /**
  28776. * Converts the animation to a string
  28777. * @param fullDetails support for multiple levels of logging within scene loading
  28778. * @returns String form of the animation
  28779. */
  28780. toString(fullDetails?: boolean): string;
  28781. /**
  28782. * Add an event to this animation
  28783. * @param event Event to add
  28784. */
  28785. addEvent(event: AnimationEvent): void;
  28786. /**
  28787. * Remove all events found at the given frame
  28788. * @param frame The frame to remove events from
  28789. */
  28790. removeEvents(frame: number): void;
  28791. /**
  28792. * Retrieves all the events from the animation
  28793. * @returns Events from the animation
  28794. */
  28795. getEvents(): AnimationEvent[];
  28796. /**
  28797. * Creates an animation range
  28798. * @param name Name of the animation range
  28799. * @param from Starting frame of the animation range
  28800. * @param to Ending frame of the animation
  28801. */
  28802. createRange(name: string, from: number, to: number): void;
  28803. /**
  28804. * Deletes an animation range by name
  28805. * @param name Name of the animation range to delete
  28806. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28807. */
  28808. deleteRange(name: string, deleteFrames?: boolean): void;
  28809. /**
  28810. * Gets the animation range by name, or null if not defined
  28811. * @param name Name of the animation range
  28812. * @returns Nullable animation range
  28813. */
  28814. getRange(name: string): Nullable<AnimationRange>;
  28815. /**
  28816. * Gets the key frames from the animation
  28817. * @returns The key frames of the animation
  28818. */
  28819. getKeys(): Array<IAnimationKey>;
  28820. /**
  28821. * Gets the highest frame rate of the animation
  28822. * @returns Highest frame rate of the animation
  28823. */
  28824. getHighestFrame(): number;
  28825. /**
  28826. * Gets the easing function of the animation
  28827. * @returns Easing function of the animation
  28828. */
  28829. getEasingFunction(): IEasingFunction;
  28830. /**
  28831. * Sets the easing function of the animation
  28832. * @param easingFunction A custom mathematical formula for animation
  28833. */
  28834. setEasingFunction(easingFunction: EasingFunction): void;
  28835. /**
  28836. * Interpolates a scalar linearly
  28837. * @param startValue Start value of the animation curve
  28838. * @param endValue End value of the animation curve
  28839. * @param gradient Scalar amount to interpolate
  28840. * @returns Interpolated scalar value
  28841. */
  28842. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28843. /**
  28844. * Interpolates a scalar cubically
  28845. * @param startValue Start value of the animation curve
  28846. * @param outTangent End tangent of the animation
  28847. * @param endValue End value of the animation curve
  28848. * @param inTangent Start tangent of the animation curve
  28849. * @param gradient Scalar amount to interpolate
  28850. * @returns Interpolated scalar value
  28851. */
  28852. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28853. /**
  28854. * Interpolates a quaternion using a spherical linear interpolation
  28855. * @param startValue Start value of the animation curve
  28856. * @param endValue End value of the animation curve
  28857. * @param gradient Scalar amount to interpolate
  28858. * @returns Interpolated quaternion value
  28859. */
  28860. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28861. /**
  28862. * Interpolates a quaternion cubically
  28863. * @param startValue Start value of the animation curve
  28864. * @param outTangent End tangent of the animation curve
  28865. * @param endValue End value of the animation curve
  28866. * @param inTangent Start tangent of the animation curve
  28867. * @param gradient Scalar amount to interpolate
  28868. * @returns Interpolated quaternion value
  28869. */
  28870. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28871. /**
  28872. * Interpolates a Vector3 linearl
  28873. * @param startValue Start value of the animation curve
  28874. * @param endValue End value of the animation curve
  28875. * @param gradient Scalar amount to interpolate
  28876. * @returns Interpolated scalar value
  28877. */
  28878. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28879. /**
  28880. * Interpolates a Vector3 cubically
  28881. * @param startValue Start value of the animation curve
  28882. * @param outTangent End tangent of the animation
  28883. * @param endValue End value of the animation curve
  28884. * @param inTangent Start tangent of the animation curve
  28885. * @param gradient Scalar amount to interpolate
  28886. * @returns InterpolatedVector3 value
  28887. */
  28888. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28889. /**
  28890. * Interpolates a Vector2 linearly
  28891. * @param startValue Start value of the animation curve
  28892. * @param endValue End value of the animation curve
  28893. * @param gradient Scalar amount to interpolate
  28894. * @returns Interpolated Vector2 value
  28895. */
  28896. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28897. /**
  28898. * Interpolates a Vector2 cubically
  28899. * @param startValue Start value of the animation curve
  28900. * @param outTangent End tangent of the animation
  28901. * @param endValue End value of the animation curve
  28902. * @param inTangent Start tangent of the animation curve
  28903. * @param gradient Scalar amount to interpolate
  28904. * @returns Interpolated Vector2 value
  28905. */
  28906. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28907. /**
  28908. * Interpolates a size linearly
  28909. * @param startValue Start value of the animation curve
  28910. * @param endValue End value of the animation curve
  28911. * @param gradient Scalar amount to interpolate
  28912. * @returns Interpolated Size value
  28913. */
  28914. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28915. /**
  28916. * Interpolates a Color3 linearly
  28917. * @param startValue Start value of the animation curve
  28918. * @param endValue End value of the animation curve
  28919. * @param gradient Scalar amount to interpolate
  28920. * @returns Interpolated Color3 value
  28921. */
  28922. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28923. /**
  28924. * Interpolates a Color4 linearly
  28925. * @param startValue Start value of the animation curve
  28926. * @param endValue End value of the animation curve
  28927. * @param gradient Scalar amount to interpolate
  28928. * @returns Interpolated Color3 value
  28929. */
  28930. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28931. /**
  28932. * @hidden Internal use only
  28933. */
  28934. _getKeyValue(value: any): any;
  28935. /**
  28936. * @hidden Internal use only
  28937. */
  28938. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28939. /**
  28940. * Defines the function to use to interpolate matrices
  28941. * @param startValue defines the start matrix
  28942. * @param endValue defines the end matrix
  28943. * @param gradient defines the gradient between both matrices
  28944. * @param result defines an optional target matrix where to store the interpolation
  28945. * @returns the interpolated matrix
  28946. */
  28947. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28948. /**
  28949. * Makes a copy of the animation
  28950. * @returns Cloned animation
  28951. */
  28952. clone(): Animation;
  28953. /**
  28954. * Sets the key frames of the animation
  28955. * @param values The animation key frames to set
  28956. */
  28957. setKeys(values: Array<IAnimationKey>): void;
  28958. /**
  28959. * Serializes the animation to an object
  28960. * @returns Serialized object
  28961. */
  28962. serialize(): any;
  28963. /**
  28964. * Float animation type
  28965. */
  28966. static readonly ANIMATIONTYPE_FLOAT: number;
  28967. /**
  28968. * Vector3 animation type
  28969. */
  28970. static readonly ANIMATIONTYPE_VECTOR3: number;
  28971. /**
  28972. * Quaternion animation type
  28973. */
  28974. static readonly ANIMATIONTYPE_QUATERNION: number;
  28975. /**
  28976. * Matrix animation type
  28977. */
  28978. static readonly ANIMATIONTYPE_MATRIX: number;
  28979. /**
  28980. * Color3 animation type
  28981. */
  28982. static readonly ANIMATIONTYPE_COLOR3: number;
  28983. /**
  28984. * Color3 animation type
  28985. */
  28986. static readonly ANIMATIONTYPE_COLOR4: number;
  28987. /**
  28988. * Vector2 animation type
  28989. */
  28990. static readonly ANIMATIONTYPE_VECTOR2: number;
  28991. /**
  28992. * Size animation type
  28993. */
  28994. static readonly ANIMATIONTYPE_SIZE: number;
  28995. /**
  28996. * Relative Loop Mode
  28997. */
  28998. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28999. /**
  29000. * Cycle Loop Mode
  29001. */
  29002. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29003. /**
  29004. * Constant Loop Mode
  29005. */
  29006. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29007. /** @hidden */
  29008. static _UniversalLerp(left: any, right: any, amount: number): any;
  29009. /**
  29010. * Parses an animation object and creates an animation
  29011. * @param parsedAnimation Parsed animation object
  29012. * @returns Animation object
  29013. */
  29014. static Parse(parsedAnimation: any): Animation;
  29015. /**
  29016. * Appends the serialized animations from the source animations
  29017. * @param source Source containing the animations
  29018. * @param destination Target to store the animations
  29019. */
  29020. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29021. }
  29022. }
  29023. declare module BABYLON {
  29024. /**
  29025. * Interface containing an array of animations
  29026. */
  29027. export interface IAnimatable {
  29028. /**
  29029. * Array of animations
  29030. */
  29031. animations: Nullable<Array<Animation>>;
  29032. }
  29033. }
  29034. declare module BABYLON {
  29035. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29036. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29037. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29038. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29039. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29040. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29041. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29042. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29043. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29044. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29045. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29046. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29047. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29048. /**
  29049. * Decorator used to define property that can be serialized as reference to a camera
  29050. * @param sourceName defines the name of the property to decorate
  29051. */
  29052. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29053. /**
  29054. * Class used to help serialization objects
  29055. */
  29056. export class SerializationHelper {
  29057. /** @hidden */
  29058. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29059. /** @hidden */
  29060. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29061. /** @hidden */
  29062. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29063. /** @hidden */
  29064. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29065. /**
  29066. * Appends the serialized animations from the source animations
  29067. * @param source Source containing the animations
  29068. * @param destination Target to store the animations
  29069. */
  29070. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29071. /**
  29072. * Static function used to serialized a specific entity
  29073. * @param entity defines the entity to serialize
  29074. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29075. * @returns a JSON compatible object representing the serialization of the entity
  29076. */
  29077. static Serialize<T>(entity: T, serializationObject?: any): any;
  29078. /**
  29079. * Creates a new entity from a serialization data object
  29080. * @param creationFunction defines a function used to instanciated the new entity
  29081. * @param source defines the source serialization data
  29082. * @param scene defines the hosting scene
  29083. * @param rootUrl defines the root url for resources
  29084. * @returns a new entity
  29085. */
  29086. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29087. /**
  29088. * Clones an object
  29089. * @param creationFunction defines the function used to instanciate the new object
  29090. * @param source defines the source object
  29091. * @returns the cloned object
  29092. */
  29093. static Clone<T>(creationFunction: () => T, source: T): T;
  29094. /**
  29095. * Instanciates a new object based on a source one (some data will be shared between both object)
  29096. * @param creationFunction defines the function used to instanciate the new object
  29097. * @param source defines the source object
  29098. * @returns the new object
  29099. */
  29100. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29101. }
  29102. }
  29103. declare module BABYLON {
  29104. /**
  29105. * Class used to manipulate GUIDs
  29106. */
  29107. export class GUID {
  29108. /**
  29109. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29110. * Be aware Math.random() could cause collisions, but:
  29111. * "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"
  29112. * @returns a pseudo random id
  29113. */
  29114. static RandomId(): string;
  29115. }
  29116. }
  29117. declare module BABYLON {
  29118. /**
  29119. * Base class of all the textures in babylon.
  29120. * It groups all the common properties the materials, post process, lights... might need
  29121. * in order to make a correct use of the texture.
  29122. */
  29123. export class BaseTexture implements IAnimatable {
  29124. /**
  29125. * Default anisotropic filtering level for the application.
  29126. * It is set to 4 as a good tradeoff between perf and quality.
  29127. */
  29128. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29129. /**
  29130. * Gets or sets the unique id of the texture
  29131. */
  29132. uniqueId: number;
  29133. /**
  29134. * Define the name of the texture.
  29135. */
  29136. name: string;
  29137. /**
  29138. * Gets or sets an object used to store user defined information.
  29139. */
  29140. metadata: any;
  29141. /**
  29142. * For internal use only. Please do not use.
  29143. */
  29144. reservedDataStore: any;
  29145. private _hasAlpha;
  29146. /**
  29147. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29148. */
  29149. hasAlpha: boolean;
  29150. /**
  29151. * Defines if the alpha value should be determined via the rgb values.
  29152. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29153. */
  29154. getAlphaFromRGB: boolean;
  29155. /**
  29156. * Intensity or strength of the texture.
  29157. * It is commonly used by materials to fine tune the intensity of the texture
  29158. */
  29159. level: number;
  29160. /**
  29161. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29162. * This is part of the texture as textures usually maps to one uv set.
  29163. */
  29164. coordinatesIndex: number;
  29165. private _coordinatesMode;
  29166. /**
  29167. * How a texture is mapped.
  29168. *
  29169. * | Value | Type | Description |
  29170. * | ----- | ----------------------------------- | ----------- |
  29171. * | 0 | EXPLICIT_MODE | |
  29172. * | 1 | SPHERICAL_MODE | |
  29173. * | 2 | PLANAR_MODE | |
  29174. * | 3 | CUBIC_MODE | |
  29175. * | 4 | PROJECTION_MODE | |
  29176. * | 5 | SKYBOX_MODE | |
  29177. * | 6 | INVCUBIC_MODE | |
  29178. * | 7 | EQUIRECTANGULAR_MODE | |
  29179. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29180. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29181. */
  29182. coordinatesMode: number;
  29183. /**
  29184. * | Value | Type | Description |
  29185. * | ----- | ------------------ | ----------- |
  29186. * | 0 | CLAMP_ADDRESSMODE | |
  29187. * | 1 | WRAP_ADDRESSMODE | |
  29188. * | 2 | MIRROR_ADDRESSMODE | |
  29189. */
  29190. wrapU: number;
  29191. /**
  29192. * | Value | Type | Description |
  29193. * | ----- | ------------------ | ----------- |
  29194. * | 0 | CLAMP_ADDRESSMODE | |
  29195. * | 1 | WRAP_ADDRESSMODE | |
  29196. * | 2 | MIRROR_ADDRESSMODE | |
  29197. */
  29198. wrapV: number;
  29199. /**
  29200. * | Value | Type | Description |
  29201. * | ----- | ------------------ | ----------- |
  29202. * | 0 | CLAMP_ADDRESSMODE | |
  29203. * | 1 | WRAP_ADDRESSMODE | |
  29204. * | 2 | MIRROR_ADDRESSMODE | |
  29205. */
  29206. wrapR: number;
  29207. /**
  29208. * With compliant hardware and browser (supporting anisotropic filtering)
  29209. * this defines the level of anisotropic filtering in the texture.
  29210. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29211. */
  29212. anisotropicFilteringLevel: number;
  29213. /**
  29214. * Define if the texture is a cube texture or if false a 2d texture.
  29215. */
  29216. isCube: boolean;
  29217. /**
  29218. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29219. */
  29220. is3D: boolean;
  29221. /**
  29222. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29223. */
  29224. is2DArray: boolean;
  29225. /**
  29226. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29227. * HDR texture are usually stored in linear space.
  29228. * This only impacts the PBR and Background materials
  29229. */
  29230. gammaSpace: boolean;
  29231. /**
  29232. * Gets or sets whether or not the texture contains RGBD data.
  29233. */
  29234. isRGBD: boolean;
  29235. /**
  29236. * Is Z inverted in the texture (useful in a cube texture).
  29237. */
  29238. invertZ: boolean;
  29239. /**
  29240. * Are mip maps generated for this texture or not.
  29241. */
  29242. readonly noMipmap: boolean;
  29243. /**
  29244. * @hidden
  29245. */
  29246. lodLevelInAlpha: boolean;
  29247. /**
  29248. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29249. */
  29250. lodGenerationOffset: number;
  29251. /**
  29252. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29253. */
  29254. lodGenerationScale: number;
  29255. /**
  29256. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29257. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29258. * average roughness values.
  29259. */
  29260. linearSpecularLOD: boolean;
  29261. /**
  29262. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29263. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29264. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29265. */
  29266. irradianceTexture: Nullable<BaseTexture>;
  29267. /**
  29268. * Define if the texture is a render target.
  29269. */
  29270. isRenderTarget: boolean;
  29271. /**
  29272. * Define the unique id of the texture in the scene.
  29273. */
  29274. readonly uid: string;
  29275. /**
  29276. * Return a string representation of the texture.
  29277. * @returns the texture as a string
  29278. */
  29279. toString(): string;
  29280. /**
  29281. * Get the class name of the texture.
  29282. * @returns "BaseTexture"
  29283. */
  29284. getClassName(): string;
  29285. /**
  29286. * Define the list of animation attached to the texture.
  29287. */
  29288. animations: Animation[];
  29289. /**
  29290. * An event triggered when the texture is disposed.
  29291. */
  29292. onDisposeObservable: Observable<BaseTexture>;
  29293. private _onDisposeObserver;
  29294. /**
  29295. * Callback triggered when the texture has been disposed.
  29296. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29297. */
  29298. onDispose: () => void;
  29299. /**
  29300. * Define the current state of the loading sequence when in delayed load mode.
  29301. */
  29302. delayLoadState: number;
  29303. private _scene;
  29304. /** @hidden */
  29305. _texture: Nullable<InternalTexture>;
  29306. private _uid;
  29307. /**
  29308. * Define if the texture is preventinga material to render or not.
  29309. * If not and the texture is not ready, the engine will use a default black texture instead.
  29310. */
  29311. readonly isBlocking: boolean;
  29312. /**
  29313. * Instantiates a new BaseTexture.
  29314. * Base class of all the textures in babylon.
  29315. * It groups all the common properties the materials, post process, lights... might need
  29316. * in order to make a correct use of the texture.
  29317. * @param scene Define the scene the texture blongs to
  29318. */
  29319. constructor(scene: Nullable<Scene>);
  29320. /**
  29321. * Get the scene the texture belongs to.
  29322. * @returns the scene or null if undefined
  29323. */
  29324. getScene(): Nullable<Scene>;
  29325. /**
  29326. * Get the texture transform matrix used to offset tile the texture for istance.
  29327. * @returns the transformation matrix
  29328. */
  29329. getTextureMatrix(): Matrix;
  29330. /**
  29331. * Get the texture reflection matrix used to rotate/transform the reflection.
  29332. * @returns the reflection matrix
  29333. */
  29334. getReflectionTextureMatrix(): Matrix;
  29335. /**
  29336. * Get the underlying lower level texture from Babylon.
  29337. * @returns the insternal texture
  29338. */
  29339. getInternalTexture(): Nullable<InternalTexture>;
  29340. /**
  29341. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29342. * @returns true if ready or not blocking
  29343. */
  29344. isReadyOrNotBlocking(): boolean;
  29345. /**
  29346. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29347. * @returns true if fully ready
  29348. */
  29349. isReady(): boolean;
  29350. private _cachedSize;
  29351. /**
  29352. * Get the size of the texture.
  29353. * @returns the texture size.
  29354. */
  29355. getSize(): ISize;
  29356. /**
  29357. * Get the base size of the texture.
  29358. * It can be different from the size if the texture has been resized for POT for instance
  29359. * @returns the base size
  29360. */
  29361. getBaseSize(): ISize;
  29362. /**
  29363. * Update the sampling mode of the texture.
  29364. * Default is Trilinear mode.
  29365. *
  29366. * | Value | Type | Description |
  29367. * | ----- | ------------------ | ----------- |
  29368. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29369. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29370. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29371. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29372. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29373. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29374. * | 7 | NEAREST_LINEAR | |
  29375. * | 8 | NEAREST_NEAREST | |
  29376. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29377. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29378. * | 11 | LINEAR_LINEAR | |
  29379. * | 12 | LINEAR_NEAREST | |
  29380. *
  29381. * > _mag_: magnification filter (close to the viewer)
  29382. * > _min_: minification filter (far from the viewer)
  29383. * > _mip_: filter used between mip map levels
  29384. *@param samplingMode Define the new sampling mode of the texture
  29385. */
  29386. updateSamplingMode(samplingMode: number): void;
  29387. /**
  29388. * Scales the texture if is `canRescale()`
  29389. * @param ratio the resize factor we want to use to rescale
  29390. */
  29391. scale(ratio: number): void;
  29392. /**
  29393. * Get if the texture can rescale.
  29394. */
  29395. readonly canRescale: boolean;
  29396. /** @hidden */
  29397. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29398. /** @hidden */
  29399. _rebuild(): void;
  29400. /**
  29401. * Triggers the load sequence in delayed load mode.
  29402. */
  29403. delayLoad(): void;
  29404. /**
  29405. * Clones the texture.
  29406. * @returns the cloned texture
  29407. */
  29408. clone(): Nullable<BaseTexture>;
  29409. /**
  29410. * Get the texture underlying type (INT, FLOAT...)
  29411. */
  29412. readonly textureType: number;
  29413. /**
  29414. * Get the texture underlying format (RGB, RGBA...)
  29415. */
  29416. readonly textureFormat: number;
  29417. /**
  29418. * Indicates that textures need to be re-calculated for all materials
  29419. */
  29420. protected _markAllSubMeshesAsTexturesDirty(): void;
  29421. /**
  29422. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29423. * This will returns an RGBA array buffer containing either in values (0-255) or
  29424. * float values (0-1) depending of the underlying buffer type.
  29425. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29426. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29427. * @param buffer defines a user defined buffer to fill with data (can be null)
  29428. * @returns The Array buffer containing the pixels data.
  29429. */
  29430. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29431. /**
  29432. * Release and destroy the underlying lower level texture aka internalTexture.
  29433. */
  29434. releaseInternalTexture(): void;
  29435. /** @hidden */
  29436. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29437. /** @hidden */
  29438. readonly _lodTextureMid: Nullable<BaseTexture>;
  29439. /** @hidden */
  29440. readonly _lodTextureLow: Nullable<BaseTexture>;
  29441. /**
  29442. * Dispose the texture and release its associated resources.
  29443. */
  29444. dispose(): void;
  29445. /**
  29446. * Serialize the texture into a JSON representation that can be parsed later on.
  29447. * @returns the JSON representation of the texture
  29448. */
  29449. serialize(): any;
  29450. /**
  29451. * Helper function to be called back once a list of texture contains only ready textures.
  29452. * @param textures Define the list of textures to wait for
  29453. * @param callback Define the callback triggered once the entire list will be ready
  29454. */
  29455. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29456. }
  29457. }
  29458. declare module BABYLON {
  29459. /**
  29460. * Options to be used when creating an effect.
  29461. */
  29462. export interface IEffectCreationOptions {
  29463. /**
  29464. * Atrributes that will be used in the shader.
  29465. */
  29466. attributes: string[];
  29467. /**
  29468. * Uniform varible names that will be set in the shader.
  29469. */
  29470. uniformsNames: string[];
  29471. /**
  29472. * Uniform buffer variable names that will be set in the shader.
  29473. */
  29474. uniformBuffersNames: string[];
  29475. /**
  29476. * Sampler texture variable names that will be set in the shader.
  29477. */
  29478. samplers: string[];
  29479. /**
  29480. * Define statements that will be set in the shader.
  29481. */
  29482. defines: any;
  29483. /**
  29484. * Possible fallbacks for this effect to improve performance when needed.
  29485. */
  29486. fallbacks: Nullable<IEffectFallbacks>;
  29487. /**
  29488. * Callback that will be called when the shader is compiled.
  29489. */
  29490. onCompiled: Nullable<(effect: Effect) => void>;
  29491. /**
  29492. * Callback that will be called if an error occurs during shader compilation.
  29493. */
  29494. onError: Nullable<(effect: Effect, errors: string) => void>;
  29495. /**
  29496. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29497. */
  29498. indexParameters?: any;
  29499. /**
  29500. * Max number of lights that can be used in the shader.
  29501. */
  29502. maxSimultaneousLights?: number;
  29503. /**
  29504. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29505. */
  29506. transformFeedbackVaryings?: Nullable<string[]>;
  29507. }
  29508. /**
  29509. * Effect containing vertex and fragment shader that can be executed on an object.
  29510. */
  29511. export class Effect implements IDisposable {
  29512. /**
  29513. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29514. */
  29515. static ShadersRepository: string;
  29516. /**
  29517. * Name of the effect.
  29518. */
  29519. name: any;
  29520. /**
  29521. * String container all the define statements that should be set on the shader.
  29522. */
  29523. defines: string;
  29524. /**
  29525. * Callback that will be called when the shader is compiled.
  29526. */
  29527. onCompiled: Nullable<(effect: Effect) => void>;
  29528. /**
  29529. * Callback that will be called if an error occurs during shader compilation.
  29530. */
  29531. onError: Nullable<(effect: Effect, errors: string) => void>;
  29532. /**
  29533. * Callback that will be called when effect is bound.
  29534. */
  29535. onBind: Nullable<(effect: Effect) => void>;
  29536. /**
  29537. * Unique ID of the effect.
  29538. */
  29539. uniqueId: number;
  29540. /**
  29541. * Observable that will be called when the shader is compiled.
  29542. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29543. */
  29544. onCompileObservable: Observable<Effect>;
  29545. /**
  29546. * Observable that will be called if an error occurs during shader compilation.
  29547. */
  29548. onErrorObservable: Observable<Effect>;
  29549. /** @hidden */
  29550. _onBindObservable: Nullable<Observable<Effect>>;
  29551. /**
  29552. * Observable that will be called when effect is bound.
  29553. */
  29554. readonly onBindObservable: Observable<Effect>;
  29555. /** @hidden */
  29556. _bonesComputationForcedToCPU: boolean;
  29557. private static _uniqueIdSeed;
  29558. private _engine;
  29559. private _uniformBuffersNames;
  29560. private _uniformsNames;
  29561. private _samplerList;
  29562. private _samplers;
  29563. private _isReady;
  29564. private _compilationError;
  29565. private _allFallbacksProcessed;
  29566. private _attributesNames;
  29567. private _attributes;
  29568. private _attributeLocationByName;
  29569. private _uniforms;
  29570. /**
  29571. * Key for the effect.
  29572. * @hidden
  29573. */
  29574. _key: string;
  29575. private _indexParameters;
  29576. private _fallbacks;
  29577. private _vertexSourceCode;
  29578. private _fragmentSourceCode;
  29579. private _vertexSourceCodeOverride;
  29580. private _fragmentSourceCodeOverride;
  29581. private _transformFeedbackVaryings;
  29582. /**
  29583. * Compiled shader to webGL program.
  29584. * @hidden
  29585. */
  29586. _pipelineContext: Nullable<IPipelineContext>;
  29587. private _valueCache;
  29588. private static _baseCache;
  29589. /**
  29590. * Instantiates an effect.
  29591. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29592. * @param baseName Name of the effect.
  29593. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29594. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29595. * @param samplers List of sampler variables that will be passed to the shader.
  29596. * @param engine Engine to be used to render the effect
  29597. * @param defines Define statements to be added to the shader.
  29598. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29599. * @param onCompiled Callback that will be called when the shader is compiled.
  29600. * @param onError Callback that will be called if an error occurs during shader compilation.
  29601. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29602. */
  29603. 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);
  29604. private _useFinalCode;
  29605. /**
  29606. * Unique key for this effect
  29607. */
  29608. readonly key: string;
  29609. /**
  29610. * If the effect has been compiled and prepared.
  29611. * @returns if the effect is compiled and prepared.
  29612. */
  29613. isReady(): boolean;
  29614. private _isReadyInternal;
  29615. /**
  29616. * The engine the effect was initialized with.
  29617. * @returns the engine.
  29618. */
  29619. getEngine(): Engine;
  29620. /**
  29621. * The pipeline context for this effect
  29622. * @returns the associated pipeline context
  29623. */
  29624. getPipelineContext(): Nullable<IPipelineContext>;
  29625. /**
  29626. * The set of names of attribute variables for the shader.
  29627. * @returns An array of attribute names.
  29628. */
  29629. getAttributesNames(): string[];
  29630. /**
  29631. * Returns the attribute at the given index.
  29632. * @param index The index of the attribute.
  29633. * @returns The location of the attribute.
  29634. */
  29635. getAttributeLocation(index: number): number;
  29636. /**
  29637. * Returns the attribute based on the name of the variable.
  29638. * @param name of the attribute to look up.
  29639. * @returns the attribute location.
  29640. */
  29641. getAttributeLocationByName(name: string): number;
  29642. /**
  29643. * The number of attributes.
  29644. * @returns the numnber of attributes.
  29645. */
  29646. getAttributesCount(): number;
  29647. /**
  29648. * Gets the index of a uniform variable.
  29649. * @param uniformName of the uniform to look up.
  29650. * @returns the index.
  29651. */
  29652. getUniformIndex(uniformName: string): number;
  29653. /**
  29654. * Returns the attribute based on the name of the variable.
  29655. * @param uniformName of the uniform to look up.
  29656. * @returns the location of the uniform.
  29657. */
  29658. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29659. /**
  29660. * Returns an array of sampler variable names
  29661. * @returns The array of sampler variable neames.
  29662. */
  29663. getSamplers(): string[];
  29664. /**
  29665. * The error from the last compilation.
  29666. * @returns the error string.
  29667. */
  29668. getCompilationError(): string;
  29669. /**
  29670. * Gets a boolean indicating that all fallbacks were used during compilation
  29671. * @returns true if all fallbacks were used
  29672. */
  29673. allFallbacksProcessed(): boolean;
  29674. /**
  29675. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29676. * @param func The callback to be used.
  29677. */
  29678. executeWhenCompiled(func: (effect: Effect) => void): void;
  29679. private _checkIsReady;
  29680. private _loadShader;
  29681. /**
  29682. * Recompiles the webGL program
  29683. * @param vertexSourceCode The source code for the vertex shader.
  29684. * @param fragmentSourceCode The source code for the fragment shader.
  29685. * @param onCompiled Callback called when completed.
  29686. * @param onError Callback called on error.
  29687. * @hidden
  29688. */
  29689. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29690. /**
  29691. * Prepares the effect
  29692. * @hidden
  29693. */
  29694. _prepareEffect(): void;
  29695. private _processCompilationErrors;
  29696. /**
  29697. * Checks if the effect is supported. (Must be called after compilation)
  29698. */
  29699. readonly isSupported: boolean;
  29700. /**
  29701. * Binds a texture to the engine to be used as output of the shader.
  29702. * @param channel Name of the output variable.
  29703. * @param texture Texture to bind.
  29704. * @hidden
  29705. */
  29706. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  29707. /**
  29708. * Sets a texture on the engine to be used in the shader.
  29709. * @param channel Name of the sampler variable.
  29710. * @param texture Texture to set.
  29711. */
  29712. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29713. /**
  29714. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29715. * @param channel Name of the sampler variable.
  29716. * @param texture Texture to set.
  29717. */
  29718. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29719. /**
  29720. * Sets an array of textures on the engine to be used in the shader.
  29721. * @param channel Name of the variable.
  29722. * @param textures Textures to set.
  29723. */
  29724. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29725. /**
  29726. * 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)
  29727. * @param channel Name of the sampler variable.
  29728. * @param postProcess Post process to get the input texture from.
  29729. */
  29730. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29731. /**
  29732. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29733. * 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)
  29734. * @param channel Name of the sampler variable.
  29735. * @param postProcess Post process to get the output texture from.
  29736. */
  29737. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29738. /** @hidden */
  29739. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29740. /** @hidden */
  29741. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29742. /** @hidden */
  29743. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29744. /** @hidden */
  29745. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29746. /**
  29747. * Binds a buffer to a uniform.
  29748. * @param buffer Buffer to bind.
  29749. * @param name Name of the uniform variable to bind to.
  29750. */
  29751. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29752. /**
  29753. * Binds block to a uniform.
  29754. * @param blockName Name of the block to bind.
  29755. * @param index Index to bind.
  29756. */
  29757. bindUniformBlock(blockName: string, index: number): void;
  29758. /**
  29759. * Sets an interger value on a uniform variable.
  29760. * @param uniformName Name of the variable.
  29761. * @param value Value to be set.
  29762. * @returns this effect.
  29763. */
  29764. setInt(uniformName: string, value: number): Effect;
  29765. /**
  29766. * Sets an int array on a uniform variable.
  29767. * @param uniformName Name of the variable.
  29768. * @param array array to be set.
  29769. * @returns this effect.
  29770. */
  29771. setIntArray(uniformName: string, array: Int32Array): Effect;
  29772. /**
  29773. * 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)
  29774. * @param uniformName Name of the variable.
  29775. * @param array array to be set.
  29776. * @returns this effect.
  29777. */
  29778. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29779. /**
  29780. * 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)
  29781. * @param uniformName Name of the variable.
  29782. * @param array array to be set.
  29783. * @returns this effect.
  29784. */
  29785. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29786. /**
  29787. * 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)
  29788. * @param uniformName Name of the variable.
  29789. * @param array array to be set.
  29790. * @returns this effect.
  29791. */
  29792. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29793. /**
  29794. * Sets an float array on a uniform variable.
  29795. * @param uniformName Name of the variable.
  29796. * @param array array to be set.
  29797. * @returns this effect.
  29798. */
  29799. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29800. /**
  29801. * 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)
  29802. * @param uniformName Name of the variable.
  29803. * @param array array to be set.
  29804. * @returns this effect.
  29805. */
  29806. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29807. /**
  29808. * 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)
  29809. * @param uniformName Name of the variable.
  29810. * @param array array to be set.
  29811. * @returns this effect.
  29812. */
  29813. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29814. /**
  29815. * 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)
  29816. * @param uniformName Name of the variable.
  29817. * @param array array to be set.
  29818. * @returns this effect.
  29819. */
  29820. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29821. /**
  29822. * Sets an array on a uniform variable.
  29823. * @param uniformName Name of the variable.
  29824. * @param array array to be set.
  29825. * @returns this effect.
  29826. */
  29827. setArray(uniformName: string, array: number[]): Effect;
  29828. /**
  29829. * 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)
  29830. * @param uniformName Name of the variable.
  29831. * @param array array to be set.
  29832. * @returns this effect.
  29833. */
  29834. setArray2(uniformName: string, array: number[]): Effect;
  29835. /**
  29836. * 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)
  29837. * @param uniformName Name of the variable.
  29838. * @param array array to be set.
  29839. * @returns this effect.
  29840. */
  29841. setArray3(uniformName: string, array: number[]): Effect;
  29842. /**
  29843. * 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)
  29844. * @param uniformName Name of the variable.
  29845. * @param array array to be set.
  29846. * @returns this effect.
  29847. */
  29848. setArray4(uniformName: string, array: number[]): Effect;
  29849. /**
  29850. * Sets matrices on a uniform variable.
  29851. * @param uniformName Name of the variable.
  29852. * @param matrices matrices to be set.
  29853. * @returns this effect.
  29854. */
  29855. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29856. /**
  29857. * Sets matrix on a uniform variable.
  29858. * @param uniformName Name of the variable.
  29859. * @param matrix matrix to be set.
  29860. * @returns this effect.
  29861. */
  29862. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29863. /**
  29864. * 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)
  29865. * @param uniformName Name of the variable.
  29866. * @param matrix matrix to be set.
  29867. * @returns this effect.
  29868. */
  29869. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29870. /**
  29871. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29872. * @param uniformName Name of the variable.
  29873. * @param matrix matrix to be set.
  29874. * @returns this effect.
  29875. */
  29876. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29877. /**
  29878. * Sets a float on a uniform variable.
  29879. * @param uniformName Name of the variable.
  29880. * @param value value to be set.
  29881. * @returns this effect.
  29882. */
  29883. setFloat(uniformName: string, value: number): Effect;
  29884. /**
  29885. * Sets a boolean on a uniform variable.
  29886. * @param uniformName Name of the variable.
  29887. * @param bool value to be set.
  29888. * @returns this effect.
  29889. */
  29890. setBool(uniformName: string, bool: boolean): Effect;
  29891. /**
  29892. * Sets a Vector2 on a uniform variable.
  29893. * @param uniformName Name of the variable.
  29894. * @param vector2 vector2 to be set.
  29895. * @returns this effect.
  29896. */
  29897. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29898. /**
  29899. * Sets a float2 on a uniform variable.
  29900. * @param uniformName Name of the variable.
  29901. * @param x First float in float2.
  29902. * @param y Second float in float2.
  29903. * @returns this effect.
  29904. */
  29905. setFloat2(uniformName: string, x: number, y: number): Effect;
  29906. /**
  29907. * Sets a Vector3 on a uniform variable.
  29908. * @param uniformName Name of the variable.
  29909. * @param vector3 Value to be set.
  29910. * @returns this effect.
  29911. */
  29912. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29913. /**
  29914. * Sets a float3 on a uniform variable.
  29915. * @param uniformName Name of the variable.
  29916. * @param x First float in float3.
  29917. * @param y Second float in float3.
  29918. * @param z Third float in float3.
  29919. * @returns this effect.
  29920. */
  29921. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29922. /**
  29923. * Sets a Vector4 on a uniform variable.
  29924. * @param uniformName Name of the variable.
  29925. * @param vector4 Value to be set.
  29926. * @returns this effect.
  29927. */
  29928. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29929. /**
  29930. * Sets a float4 on a uniform variable.
  29931. * @param uniformName Name of the variable.
  29932. * @param x First float in float4.
  29933. * @param y Second float in float4.
  29934. * @param z Third float in float4.
  29935. * @param w Fourth float in float4.
  29936. * @returns this effect.
  29937. */
  29938. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29939. /**
  29940. * Sets a Color3 on a uniform variable.
  29941. * @param uniformName Name of the variable.
  29942. * @param color3 Value to be set.
  29943. * @returns this effect.
  29944. */
  29945. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29946. /**
  29947. * Sets a Color4 on a uniform variable.
  29948. * @param uniformName Name of the variable.
  29949. * @param color3 Value to be set.
  29950. * @param alpha Alpha value to be set.
  29951. * @returns this effect.
  29952. */
  29953. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29954. /**
  29955. * Sets a Color4 on a uniform variable
  29956. * @param uniformName defines the name of the variable
  29957. * @param color4 defines the value to be set
  29958. * @returns this effect.
  29959. */
  29960. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29961. /** Release all associated resources */
  29962. dispose(): void;
  29963. /**
  29964. * This function will add a new shader to the shader store
  29965. * @param name the name of the shader
  29966. * @param pixelShader optional pixel shader content
  29967. * @param vertexShader optional vertex shader content
  29968. */
  29969. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29970. /**
  29971. * Store of each shader (The can be looked up using effect.key)
  29972. */
  29973. static ShadersStore: {
  29974. [key: string]: string;
  29975. };
  29976. /**
  29977. * Store of each included file for a shader (The can be looked up using effect.key)
  29978. */
  29979. static IncludesShadersStore: {
  29980. [key: string]: string;
  29981. };
  29982. /**
  29983. * Resets the cache of effects.
  29984. */
  29985. static ResetCache(): void;
  29986. }
  29987. }
  29988. declare module BABYLON {
  29989. /**
  29990. * Interface used to describe the capabilities of the engine relatively to the current browser
  29991. */
  29992. export interface EngineCapabilities {
  29993. /** Maximum textures units per fragment shader */
  29994. maxTexturesImageUnits: number;
  29995. /** Maximum texture units per vertex shader */
  29996. maxVertexTextureImageUnits: number;
  29997. /** Maximum textures units in the entire pipeline */
  29998. maxCombinedTexturesImageUnits: number;
  29999. /** Maximum texture size */
  30000. maxTextureSize: number;
  30001. /** Maximum texture samples */
  30002. maxSamples?: number;
  30003. /** Maximum cube texture size */
  30004. maxCubemapTextureSize: number;
  30005. /** Maximum render texture size */
  30006. maxRenderTextureSize: number;
  30007. /** Maximum number of vertex attributes */
  30008. maxVertexAttribs: number;
  30009. /** Maximum number of varyings */
  30010. maxVaryingVectors: number;
  30011. /** Maximum number of uniforms per vertex shader */
  30012. maxVertexUniformVectors: number;
  30013. /** Maximum number of uniforms per fragment shader */
  30014. maxFragmentUniformVectors: number;
  30015. /** Defines if standard derivates (dx/dy) are supported */
  30016. standardDerivatives: boolean;
  30017. /** Defines if s3tc texture compression is supported */
  30018. s3tc?: WEBGL_compressed_texture_s3tc;
  30019. /** Defines if pvrtc texture compression is supported */
  30020. pvrtc: any;
  30021. /** Defines if etc1 texture compression is supported */
  30022. etc1: any;
  30023. /** Defines if etc2 texture compression is supported */
  30024. etc2: any;
  30025. /** Defines if astc texture compression is supported */
  30026. astc: any;
  30027. /** Defines if float textures are supported */
  30028. textureFloat: boolean;
  30029. /** Defines if vertex array objects are supported */
  30030. vertexArrayObject: boolean;
  30031. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30032. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30033. /** Gets the maximum level of anisotropy supported */
  30034. maxAnisotropy: number;
  30035. /** Defines if instancing is supported */
  30036. instancedArrays: boolean;
  30037. /** Defines if 32 bits indices are supported */
  30038. uintIndices: boolean;
  30039. /** Defines if high precision shaders are supported */
  30040. highPrecisionShaderSupported: boolean;
  30041. /** Defines if depth reading in the fragment shader is supported */
  30042. fragmentDepthSupported: boolean;
  30043. /** Defines if float texture linear filtering is supported*/
  30044. textureFloatLinearFiltering: boolean;
  30045. /** Defines if rendering to float textures is supported */
  30046. textureFloatRender: boolean;
  30047. /** Defines if half float textures are supported*/
  30048. textureHalfFloat: boolean;
  30049. /** Defines if half float texture linear filtering is supported*/
  30050. textureHalfFloatLinearFiltering: boolean;
  30051. /** Defines if rendering to half float textures is supported */
  30052. textureHalfFloatRender: boolean;
  30053. /** Defines if textureLOD shader command is supported */
  30054. textureLOD: boolean;
  30055. /** Defines if draw buffers extension is supported */
  30056. drawBuffersExtension: boolean;
  30057. /** Defines if depth textures are supported */
  30058. depthTextureExtension: boolean;
  30059. /** Defines if float color buffer are supported */
  30060. colorBufferFloat: boolean;
  30061. /** Gets disjoint timer query extension (null if not supported) */
  30062. timerQuery?: EXT_disjoint_timer_query;
  30063. /** Defines if timestamp can be used with timer query */
  30064. canUseTimestampForTimerQuery: boolean;
  30065. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30066. multiview?: any;
  30067. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30068. oculusMultiview?: any;
  30069. /** Function used to let the system compiles shaders in background */
  30070. parallelShaderCompile?: {
  30071. COMPLETION_STATUS_KHR: number;
  30072. };
  30073. /** Max number of texture samples for MSAA */
  30074. maxMSAASamples: number;
  30075. /** Defines if the blend min max extension is supported */
  30076. blendMinMax: boolean;
  30077. }
  30078. }
  30079. declare module BABYLON {
  30080. /**
  30081. * @hidden
  30082. **/
  30083. export class DepthCullingState {
  30084. private _isDepthTestDirty;
  30085. private _isDepthMaskDirty;
  30086. private _isDepthFuncDirty;
  30087. private _isCullFaceDirty;
  30088. private _isCullDirty;
  30089. private _isZOffsetDirty;
  30090. private _isFrontFaceDirty;
  30091. private _depthTest;
  30092. private _depthMask;
  30093. private _depthFunc;
  30094. private _cull;
  30095. private _cullFace;
  30096. private _zOffset;
  30097. private _frontFace;
  30098. /**
  30099. * Initializes the state.
  30100. */
  30101. constructor();
  30102. readonly isDirty: boolean;
  30103. zOffset: number;
  30104. cullFace: Nullable<number>;
  30105. cull: Nullable<boolean>;
  30106. depthFunc: Nullable<number>;
  30107. depthMask: boolean;
  30108. depthTest: boolean;
  30109. frontFace: Nullable<number>;
  30110. reset(): void;
  30111. apply(gl: WebGLRenderingContext): void;
  30112. }
  30113. }
  30114. declare module BABYLON {
  30115. /**
  30116. * @hidden
  30117. **/
  30118. export class StencilState {
  30119. /** 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 */
  30120. static readonly ALWAYS: number;
  30121. /** Passed to stencilOperation to specify that stencil value must be kept */
  30122. static readonly KEEP: number;
  30123. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30124. static readonly REPLACE: number;
  30125. private _isStencilTestDirty;
  30126. private _isStencilMaskDirty;
  30127. private _isStencilFuncDirty;
  30128. private _isStencilOpDirty;
  30129. private _stencilTest;
  30130. private _stencilMask;
  30131. private _stencilFunc;
  30132. private _stencilFuncRef;
  30133. private _stencilFuncMask;
  30134. private _stencilOpStencilFail;
  30135. private _stencilOpDepthFail;
  30136. private _stencilOpStencilDepthPass;
  30137. readonly isDirty: boolean;
  30138. stencilFunc: number;
  30139. stencilFuncRef: number;
  30140. stencilFuncMask: number;
  30141. stencilOpStencilFail: number;
  30142. stencilOpDepthFail: number;
  30143. stencilOpStencilDepthPass: number;
  30144. stencilMask: number;
  30145. stencilTest: boolean;
  30146. constructor();
  30147. reset(): void;
  30148. apply(gl: WebGLRenderingContext): void;
  30149. }
  30150. }
  30151. declare module BABYLON {
  30152. /**
  30153. * @hidden
  30154. **/
  30155. export class AlphaState {
  30156. private _isAlphaBlendDirty;
  30157. private _isBlendFunctionParametersDirty;
  30158. private _isBlendEquationParametersDirty;
  30159. private _isBlendConstantsDirty;
  30160. private _alphaBlend;
  30161. private _blendFunctionParameters;
  30162. private _blendEquationParameters;
  30163. private _blendConstants;
  30164. /**
  30165. * Initializes the state.
  30166. */
  30167. constructor();
  30168. readonly isDirty: boolean;
  30169. alphaBlend: boolean;
  30170. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30171. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30172. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30173. reset(): void;
  30174. apply(gl: WebGLRenderingContext): void;
  30175. }
  30176. }
  30177. declare module BABYLON {
  30178. /** @hidden */
  30179. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30180. attributeProcessor(attribute: string): string;
  30181. varyingProcessor(varying: string, isFragment: boolean): string;
  30182. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30183. }
  30184. }
  30185. declare module BABYLON {
  30186. /**
  30187. * Interface for attribute information associated with buffer instanciation
  30188. */
  30189. export interface InstancingAttributeInfo {
  30190. /**
  30191. * Name of the GLSL attribute
  30192. * if attribute index is not specified, this is used to retrieve the index from the effect
  30193. */
  30194. attributeName: string;
  30195. /**
  30196. * Index/offset of the attribute in the vertex shader
  30197. * if not specified, this will be computes from the name.
  30198. */
  30199. index?: number;
  30200. /**
  30201. * size of the attribute, 1, 2, 3 or 4
  30202. */
  30203. attributeSize: number;
  30204. /**
  30205. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30206. */
  30207. offset: number;
  30208. /**
  30209. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30210. * default to 1
  30211. */
  30212. divisor?: number;
  30213. /**
  30214. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30215. * default is FLOAT
  30216. */
  30217. attributeType?: number;
  30218. /**
  30219. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30220. */
  30221. normalized?: boolean;
  30222. }
  30223. }
  30224. declare module BABYLON {
  30225. interface ThinEngine {
  30226. /**
  30227. * Update a video texture
  30228. * @param texture defines the texture to update
  30229. * @param video defines the video element to use
  30230. * @param invertY defines if data must be stored with Y axis inverted
  30231. */
  30232. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30233. }
  30234. }
  30235. declare module BABYLON {
  30236. /**
  30237. * Settings for finer control over video usage
  30238. */
  30239. export interface VideoTextureSettings {
  30240. /**
  30241. * Applies `autoplay` to video, if specified
  30242. */
  30243. autoPlay?: boolean;
  30244. /**
  30245. * Applies `loop` to video, if specified
  30246. */
  30247. loop?: boolean;
  30248. /**
  30249. * Automatically updates internal texture from video at every frame in the render loop
  30250. */
  30251. autoUpdateTexture: boolean;
  30252. /**
  30253. * Image src displayed during the video loading or until the user interacts with the video.
  30254. */
  30255. poster?: string;
  30256. }
  30257. /**
  30258. * If you want to display a video in your scene, this is the special texture for that.
  30259. * This special texture works similar to other textures, with the exception of a few parameters.
  30260. * @see https://doc.babylonjs.com/how_to/video_texture
  30261. */
  30262. export class VideoTexture extends Texture {
  30263. /**
  30264. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30265. */
  30266. readonly autoUpdateTexture: boolean;
  30267. /**
  30268. * The video instance used by the texture internally
  30269. */
  30270. readonly video: HTMLVideoElement;
  30271. private _onUserActionRequestedObservable;
  30272. /**
  30273. * Event triggerd when a dom action is required by the user to play the video.
  30274. * This happens due to recent changes in browser policies preventing video to auto start.
  30275. */
  30276. readonly onUserActionRequestedObservable: Observable<Texture>;
  30277. private _generateMipMaps;
  30278. private _engine;
  30279. private _stillImageCaptured;
  30280. private _displayingPosterTexture;
  30281. private _settings;
  30282. private _createInternalTextureOnEvent;
  30283. private _frameId;
  30284. /**
  30285. * Creates a video texture.
  30286. * If you want to display a video in your scene, this is the special texture for that.
  30287. * This special texture works similar to other textures, with the exception of a few parameters.
  30288. * @see https://doc.babylonjs.com/how_to/video_texture
  30289. * @param name optional name, will detect from video source, if not defined
  30290. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30291. * @param scene is obviously the current scene.
  30292. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30293. * @param invertY is false by default but can be used to invert video on Y axis
  30294. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30295. * @param settings allows finer control over video usage
  30296. */
  30297. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30298. private _getName;
  30299. private _getVideo;
  30300. private _createInternalTexture;
  30301. private reset;
  30302. /**
  30303. * @hidden Internal method to initiate `update`.
  30304. */
  30305. _rebuild(): void;
  30306. /**
  30307. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30308. */
  30309. update(): void;
  30310. /**
  30311. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30312. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30313. */
  30314. updateTexture(isVisible: boolean): void;
  30315. protected _updateInternalTexture: () => void;
  30316. /**
  30317. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30318. * @param url New url.
  30319. */
  30320. updateURL(url: string): void;
  30321. /**
  30322. * Dispose the texture and release its associated resources.
  30323. */
  30324. dispose(): void;
  30325. /**
  30326. * Creates a video texture straight from a stream.
  30327. * @param scene Define the scene the texture should be created in
  30328. * @param stream Define the stream the texture should be created from
  30329. * @returns The created video texture as a promise
  30330. */
  30331. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30332. /**
  30333. * Creates a video texture straight from your WebCam video feed.
  30334. * @param scene Define the scene the texture should be created in
  30335. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30336. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30337. * @returns The created video texture as a promise
  30338. */
  30339. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30340. minWidth: number;
  30341. maxWidth: number;
  30342. minHeight: number;
  30343. maxHeight: number;
  30344. deviceId: string;
  30345. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30346. /**
  30347. * Creates a video texture straight from your WebCam video feed.
  30348. * @param scene Define the scene the texture should be created in
  30349. * @param onReady Define a callback to triggered once the texture will be ready
  30350. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30351. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30352. */
  30353. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30354. minWidth: number;
  30355. maxWidth: number;
  30356. minHeight: number;
  30357. maxHeight: number;
  30358. deviceId: string;
  30359. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30360. }
  30361. }
  30362. declare module BABYLON {
  30363. /**
  30364. * Defines the interface used by objects working like Scene
  30365. * @hidden
  30366. */
  30367. interface ISceneLike {
  30368. _addPendingData(data: any): void;
  30369. _removePendingData(data: any): void;
  30370. offlineProvider: IOfflineProvider;
  30371. }
  30372. /** Interface defining initialization parameters for Engine class */
  30373. export interface EngineOptions extends WebGLContextAttributes {
  30374. /**
  30375. * Defines if the engine should no exceed a specified device ratio
  30376. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30377. */
  30378. limitDeviceRatio?: number;
  30379. /**
  30380. * Defines if webvr should be enabled automatically
  30381. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30382. */
  30383. autoEnableWebVR?: boolean;
  30384. /**
  30385. * Defines if webgl2 should be turned off even if supported
  30386. * @see http://doc.babylonjs.com/features/webgl2
  30387. */
  30388. disableWebGL2Support?: boolean;
  30389. /**
  30390. * Defines if webaudio should be initialized as well
  30391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30392. */
  30393. audioEngine?: boolean;
  30394. /**
  30395. * Defines if animations should run using a deterministic lock step
  30396. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30397. */
  30398. deterministicLockstep?: boolean;
  30399. /** Defines the maximum steps to use with deterministic lock step mode */
  30400. lockstepMaxSteps?: number;
  30401. /** Defines the seconds between each deterministic lock step */
  30402. timeStep?: number;
  30403. /**
  30404. * Defines that engine should ignore context lost events
  30405. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30406. */
  30407. doNotHandleContextLost?: boolean;
  30408. /**
  30409. * Defines that engine should ignore modifying touch action attribute and style
  30410. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30411. */
  30412. doNotHandleTouchAction?: boolean;
  30413. /**
  30414. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30415. */
  30416. useHighPrecisionFloats?: boolean;
  30417. }
  30418. /**
  30419. * The base engine class (root of all engines)
  30420. */
  30421. export class ThinEngine {
  30422. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30423. static ExceptionList: ({
  30424. key: string;
  30425. capture: string;
  30426. captureConstraint: number;
  30427. targets: string[];
  30428. } | {
  30429. key: string;
  30430. capture: null;
  30431. captureConstraint: null;
  30432. targets: string[];
  30433. })[];
  30434. /** @hidden */
  30435. static _TextureLoaders: IInternalTextureLoader[];
  30436. /**
  30437. * Returns the current npm package of the sdk
  30438. */
  30439. static readonly NpmPackage: string;
  30440. /**
  30441. * Returns the current version of the framework
  30442. */
  30443. static readonly Version: string;
  30444. /**
  30445. * Returns a string describing the current engine
  30446. */
  30447. readonly description: string;
  30448. /**
  30449. * Gets or sets the epsilon value used by collision engine
  30450. */
  30451. static CollisionsEpsilon: number;
  30452. /**
  30453. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30454. */
  30455. static ShadersRepository: string;
  30456. /**
  30457. * Gets or sets the textures that the engine should not attempt to load as compressed
  30458. */
  30459. protected _excludedCompressedTextures: string[];
  30460. /**
  30461. * Filters the compressed texture formats to only include
  30462. * files that are not included in the skippable list
  30463. *
  30464. * @param url the current extension
  30465. * @param textureFormatInUse the current compressed texture format
  30466. * @returns "format" string
  30467. */
  30468. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30469. /** @hidden */
  30470. _shaderProcessor: IShaderProcessor;
  30471. /**
  30472. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30473. */
  30474. forcePOTTextures: boolean;
  30475. /**
  30476. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30477. */
  30478. isFullscreen: boolean;
  30479. /**
  30480. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30481. */
  30482. cullBackFaces: boolean;
  30483. /**
  30484. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30485. */
  30486. renderEvenInBackground: boolean;
  30487. /**
  30488. * Gets or sets a boolean indicating that cache can be kept between frames
  30489. */
  30490. preventCacheWipeBetweenFrames: boolean;
  30491. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30492. validateShaderPrograms: boolean;
  30493. /**
  30494. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30495. * This can provide greater z depth for distant objects.
  30496. */
  30497. useReverseDepthBuffer: boolean;
  30498. /**
  30499. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30500. */
  30501. disableUniformBuffers: boolean;
  30502. /** @hidden */
  30503. _uniformBuffers: UniformBuffer[];
  30504. /**
  30505. * Gets a boolean indicating that the engine supports uniform buffers
  30506. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30507. */
  30508. readonly supportsUniformBuffers: boolean;
  30509. /** @hidden */
  30510. _gl: WebGLRenderingContext;
  30511. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30512. protected _windowIsBackground: boolean;
  30513. protected _webGLVersion: number;
  30514. protected _creationOptions: EngineOptions;
  30515. protected _highPrecisionShadersAllowed: boolean;
  30516. /** @hidden */
  30517. readonly _shouldUseHighPrecisionShader: boolean;
  30518. /**
  30519. * Gets a boolean indicating that only power of 2 textures are supported
  30520. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30521. */
  30522. readonly needPOTTextures: boolean;
  30523. /** @hidden */
  30524. _badOS: boolean;
  30525. /** @hidden */
  30526. _badDesktopOS: boolean;
  30527. private _hardwareScalingLevel;
  30528. /** @hidden */
  30529. _caps: EngineCapabilities;
  30530. private _isStencilEnable;
  30531. private _glVersion;
  30532. private _glRenderer;
  30533. private _glVendor;
  30534. /** @hidden */
  30535. _videoTextureSupported: boolean;
  30536. protected _renderingQueueLaunched: boolean;
  30537. protected _activeRenderLoops: (() => void)[];
  30538. /**
  30539. * Observable signaled when a context lost event is raised
  30540. */
  30541. onContextLostObservable: Observable<ThinEngine>;
  30542. /**
  30543. * Observable signaled when a context restored event is raised
  30544. */
  30545. onContextRestoredObservable: Observable<ThinEngine>;
  30546. private _onContextLost;
  30547. private _onContextRestored;
  30548. protected _contextWasLost: boolean;
  30549. /** @hidden */
  30550. _doNotHandleContextLost: boolean;
  30551. /**
  30552. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30554. */
  30555. doNotHandleContextLost: boolean;
  30556. /**
  30557. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30558. */
  30559. disableVertexArrayObjects: boolean;
  30560. /** @hidden */
  30561. protected _colorWrite: boolean;
  30562. /** @hidden */
  30563. protected _colorWriteChanged: boolean;
  30564. /** @hidden */
  30565. protected _depthCullingState: DepthCullingState;
  30566. /** @hidden */
  30567. protected _stencilState: StencilState;
  30568. /** @hidden */
  30569. _alphaState: AlphaState;
  30570. /** @hidden */
  30571. _alphaMode: number;
  30572. /** @hidden */
  30573. _alphaEquation: number;
  30574. /** @hidden */
  30575. _internalTexturesCache: InternalTexture[];
  30576. /** @hidden */
  30577. protected _activeChannel: number;
  30578. private _currentTextureChannel;
  30579. /** @hidden */
  30580. protected _boundTexturesCache: {
  30581. [key: string]: Nullable<InternalTexture>;
  30582. };
  30583. /** @hidden */
  30584. protected _currentEffect: Nullable<Effect>;
  30585. /** @hidden */
  30586. protected _currentProgram: Nullable<WebGLProgram>;
  30587. private _compiledEffects;
  30588. private _vertexAttribArraysEnabled;
  30589. /** @hidden */
  30590. protected _cachedViewport: Nullable<IViewportLike>;
  30591. private _cachedVertexArrayObject;
  30592. /** @hidden */
  30593. protected _cachedVertexBuffers: any;
  30594. /** @hidden */
  30595. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30596. /** @hidden */
  30597. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30598. /** @hidden */
  30599. _currentRenderTarget: Nullable<InternalTexture>;
  30600. private _uintIndicesCurrentlySet;
  30601. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30602. /** @hidden */
  30603. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30604. private _currentBufferPointers;
  30605. private _currentInstanceLocations;
  30606. private _currentInstanceBuffers;
  30607. private _textureUnits;
  30608. /** @hidden */
  30609. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30610. /** @hidden */
  30611. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30612. /** @hidden */
  30613. _boundRenderFunction: any;
  30614. private _vaoRecordInProgress;
  30615. private _mustWipeVertexAttributes;
  30616. private _emptyTexture;
  30617. private _emptyCubeTexture;
  30618. private _emptyTexture3D;
  30619. private _emptyTexture2DArray;
  30620. /** @hidden */
  30621. _frameHandler: number;
  30622. private _nextFreeTextureSlots;
  30623. private _maxSimultaneousTextures;
  30624. private _activeRequests;
  30625. protected _texturesSupported: string[];
  30626. /** @hidden */
  30627. _textureFormatInUse: Nullable<string>;
  30628. protected readonly _supportsHardwareTextureRescaling: boolean;
  30629. /**
  30630. * Gets the list of texture formats supported
  30631. */
  30632. readonly texturesSupported: Array<string>;
  30633. /**
  30634. * Gets the list of texture formats in use
  30635. */
  30636. readonly textureFormatInUse: Nullable<string>;
  30637. /**
  30638. * Gets the current viewport
  30639. */
  30640. readonly currentViewport: Nullable<IViewportLike>;
  30641. /**
  30642. * Gets the default empty texture
  30643. */
  30644. readonly emptyTexture: InternalTexture;
  30645. /**
  30646. * Gets the default empty 3D texture
  30647. */
  30648. readonly emptyTexture3D: InternalTexture;
  30649. /**
  30650. * Gets the default empty 2D array texture
  30651. */
  30652. readonly emptyTexture2DArray: InternalTexture;
  30653. /**
  30654. * Gets the default empty cube texture
  30655. */
  30656. readonly emptyCubeTexture: InternalTexture;
  30657. /**
  30658. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30659. */
  30660. readonly premultipliedAlpha: boolean;
  30661. /**
  30662. * Observable event triggered before each texture is initialized
  30663. */
  30664. onBeforeTextureInitObservable: Observable<Texture>;
  30665. /**
  30666. * Creates a new engine
  30667. * @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
  30668. * @param antialias defines enable antialiasing (default: false)
  30669. * @param options defines further options to be sent to the getContext() function
  30670. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30671. */
  30672. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30673. private _rebuildInternalTextures;
  30674. private _rebuildEffects;
  30675. /**
  30676. * Gets a boolean indicating if all created effects are ready
  30677. * @returns true if all effects are ready
  30678. */
  30679. areAllEffectsReady(): boolean;
  30680. protected _rebuildBuffers(): void;
  30681. private _initGLContext;
  30682. /**
  30683. * Gets version of the current webGL context
  30684. */
  30685. readonly webGLVersion: number;
  30686. /**
  30687. * Gets a string idenfifying the name of the class
  30688. * @returns "Engine" string
  30689. */
  30690. getClassName(): string;
  30691. /**
  30692. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30693. */
  30694. readonly isStencilEnable: boolean;
  30695. /** @hidden */
  30696. _prepareWorkingCanvas(): void;
  30697. /**
  30698. * Reset the texture cache to empty state
  30699. */
  30700. resetTextureCache(): void;
  30701. /**
  30702. * Gets an object containing information about the current webGL context
  30703. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30704. */
  30705. getGlInfo(): {
  30706. vendor: string;
  30707. renderer: string;
  30708. version: string;
  30709. };
  30710. /**
  30711. * Defines the hardware scaling level.
  30712. * By default the hardware scaling level is computed from the window device ratio.
  30713. * 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.
  30714. * @param level defines the level to use
  30715. */
  30716. setHardwareScalingLevel(level: number): void;
  30717. /**
  30718. * Gets the current hardware scaling level.
  30719. * By default the hardware scaling level is computed from the window device ratio.
  30720. * 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.
  30721. * @returns a number indicating the current hardware scaling level
  30722. */
  30723. getHardwareScalingLevel(): number;
  30724. /**
  30725. * Gets the list of loaded textures
  30726. * @returns an array containing all loaded textures
  30727. */
  30728. getLoadedTexturesCache(): InternalTexture[];
  30729. /**
  30730. * Gets the object containing all engine capabilities
  30731. * @returns the EngineCapabilities object
  30732. */
  30733. getCaps(): EngineCapabilities;
  30734. /**
  30735. * stop executing a render loop function and remove it from the execution array
  30736. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30737. */
  30738. stopRenderLoop(renderFunction?: () => void): void;
  30739. /** @hidden */
  30740. _renderLoop(): void;
  30741. /**
  30742. * Gets the HTML canvas attached with the current webGL context
  30743. * @returns a HTML canvas
  30744. */
  30745. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30746. /**
  30747. * Gets host window
  30748. * @returns the host window object
  30749. */
  30750. getHostWindow(): Nullable<Window>;
  30751. /**
  30752. * Gets the current render width
  30753. * @param useScreen defines if screen size must be used (or the current render target if any)
  30754. * @returns a number defining the current render width
  30755. */
  30756. getRenderWidth(useScreen?: boolean): number;
  30757. /**
  30758. * Gets the current render height
  30759. * @param useScreen defines if screen size must be used (or the current render target if any)
  30760. * @returns a number defining the current render height
  30761. */
  30762. getRenderHeight(useScreen?: boolean): number;
  30763. /**
  30764. * Can be used to override the current requestAnimationFrame requester.
  30765. * @hidden
  30766. */
  30767. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30768. /**
  30769. * Register and execute a render loop. The engine can have more than one render function
  30770. * @param renderFunction defines the function to continuously execute
  30771. */
  30772. runRenderLoop(renderFunction: () => void): void;
  30773. /**
  30774. * Clear the current render buffer or the current render target (if any is set up)
  30775. * @param color defines the color to use
  30776. * @param backBuffer defines if the back buffer must be cleared
  30777. * @param depth defines if the depth buffer must be cleared
  30778. * @param stencil defines if the stencil buffer must be cleared
  30779. */
  30780. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30781. private _viewportCached;
  30782. /** @hidden */
  30783. _viewport(x: number, y: number, width: number, height: number): void;
  30784. /**
  30785. * Set the WebGL's viewport
  30786. * @param viewport defines the viewport element to be used
  30787. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30788. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30789. */
  30790. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30791. /**
  30792. * Begin a new frame
  30793. */
  30794. beginFrame(): void;
  30795. /**
  30796. * Enf the current frame
  30797. */
  30798. endFrame(): void;
  30799. /**
  30800. * Resize the view according to the canvas' size
  30801. */
  30802. resize(): void;
  30803. /**
  30804. * Force a specific size of the canvas
  30805. * @param width defines the new canvas' width
  30806. * @param height defines the new canvas' height
  30807. */
  30808. setSize(width: number, height: number): void;
  30809. /**
  30810. * Binds the frame buffer to the specified texture.
  30811. * @param texture The texture to render to or null for the default canvas
  30812. * @param faceIndex The face of the texture to render to in case of cube texture
  30813. * @param requiredWidth The width of the target to render to
  30814. * @param requiredHeight The height of the target to render to
  30815. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30816. * @param depthStencilTexture The depth stencil texture to use to render
  30817. * @param lodLevel defines le lod level to bind to the frame buffer
  30818. */
  30819. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30820. /** @hidden */
  30821. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30822. /**
  30823. * Unbind the current render target texture from the webGL context
  30824. * @param texture defines the render target texture to unbind
  30825. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30826. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30827. */
  30828. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30829. /**
  30830. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30831. */
  30832. flushFramebuffer(): void;
  30833. /**
  30834. * Unbind the current render target and bind the default framebuffer
  30835. */
  30836. restoreDefaultFramebuffer(): void;
  30837. /** @hidden */
  30838. protected _resetVertexBufferBinding(): void;
  30839. /**
  30840. * Creates a vertex buffer
  30841. * @param data the data for the vertex buffer
  30842. * @returns the new WebGL static buffer
  30843. */
  30844. createVertexBuffer(data: DataArray): DataBuffer;
  30845. private _createVertexBuffer;
  30846. /**
  30847. * Creates a dynamic vertex buffer
  30848. * @param data the data for the dynamic vertex buffer
  30849. * @returns the new WebGL dynamic buffer
  30850. */
  30851. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30852. protected _resetIndexBufferBinding(): void;
  30853. /**
  30854. * Creates a new index buffer
  30855. * @param indices defines the content of the index buffer
  30856. * @param updatable defines if the index buffer must be updatable
  30857. * @returns a new webGL buffer
  30858. */
  30859. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30860. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30861. /**
  30862. * Bind a webGL buffer to the webGL context
  30863. * @param buffer defines the buffer to bind
  30864. */
  30865. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30866. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30867. private bindBuffer;
  30868. /**
  30869. * update the bound buffer with the given data
  30870. * @param data defines the data to update
  30871. */
  30872. updateArrayBuffer(data: Float32Array): void;
  30873. private _vertexAttribPointer;
  30874. private _bindIndexBufferWithCache;
  30875. private _bindVertexBuffersAttributes;
  30876. /**
  30877. * Records a vertex array object
  30878. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30879. * @param vertexBuffers defines the list of vertex buffers to store
  30880. * @param indexBuffer defines the index buffer to store
  30881. * @param effect defines the effect to store
  30882. * @returns the new vertex array object
  30883. */
  30884. recordVertexArrayObject(vertexBuffers: {
  30885. [key: string]: VertexBuffer;
  30886. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30887. /**
  30888. * Bind a specific vertex array object
  30889. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30890. * @param vertexArrayObject defines the vertex array object to bind
  30891. * @param indexBuffer defines the index buffer to bind
  30892. */
  30893. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30894. /**
  30895. * Bind webGl buffers directly to the webGL context
  30896. * @param vertexBuffer defines the vertex buffer to bind
  30897. * @param indexBuffer defines the index buffer to bind
  30898. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30899. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30900. * @param effect defines the effect associated with the vertex buffer
  30901. */
  30902. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30903. private _unbindVertexArrayObject;
  30904. /**
  30905. * Bind a list of vertex buffers to the webGL context
  30906. * @param vertexBuffers defines the list of vertex buffers to bind
  30907. * @param indexBuffer defines the index buffer to bind
  30908. * @param effect defines the effect associated with the vertex buffers
  30909. */
  30910. bindBuffers(vertexBuffers: {
  30911. [key: string]: Nullable<VertexBuffer>;
  30912. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30913. /**
  30914. * Unbind all instance attributes
  30915. */
  30916. unbindInstanceAttributes(): void;
  30917. /**
  30918. * Release and free the memory of a vertex array object
  30919. * @param vao defines the vertex array object to delete
  30920. */
  30921. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30922. /** @hidden */
  30923. _releaseBuffer(buffer: DataBuffer): boolean;
  30924. protected _deleteBuffer(buffer: DataBuffer): void;
  30925. /**
  30926. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30927. * @param instancesBuffer defines the webGL buffer to update and bind
  30928. * @param data defines the data to store in the buffer
  30929. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30930. */
  30931. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30932. /**
  30933. * Bind the content of a webGL buffer used with instanciation
  30934. * @param instancesBuffer defines the webGL buffer to bind
  30935. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  30936. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  30937. */
  30938. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  30939. /**
  30940. * Disable the instance attribute corresponding to the name in parameter
  30941. * @param name defines the name of the attribute to disable
  30942. */
  30943. disableInstanceAttributeByName(name: string): void;
  30944. /**
  30945. * Disable the instance attribute corresponding to the location in parameter
  30946. * @param attributeLocation defines the attribute location of the attribute to disable
  30947. */
  30948. disableInstanceAttribute(attributeLocation: number): void;
  30949. /**
  30950. * Disable the attribute corresponding to the location in parameter
  30951. * @param attributeLocation defines the attribute location of the attribute to disable
  30952. */
  30953. disableAttributeByIndex(attributeLocation: number): void;
  30954. /**
  30955. * Send a draw order
  30956. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30957. * @param indexStart defines the starting index
  30958. * @param indexCount defines the number of index to draw
  30959. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30960. */
  30961. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30962. /**
  30963. * Draw a list of points
  30964. * @param verticesStart defines the index of first vertex to draw
  30965. * @param verticesCount defines the count of vertices to draw
  30966. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30967. */
  30968. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30969. /**
  30970. * Draw a list of unindexed primitives
  30971. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30972. * @param verticesStart defines the index of first vertex to draw
  30973. * @param verticesCount defines the count of vertices to draw
  30974. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30975. */
  30976. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30977. /**
  30978. * Draw a list of indexed primitives
  30979. * @param fillMode defines the primitive to use
  30980. * @param indexStart defines the starting index
  30981. * @param indexCount defines the number of index to draw
  30982. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30983. */
  30984. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30985. /**
  30986. * Draw a list of unindexed primitives
  30987. * @param fillMode defines the primitive to use
  30988. * @param verticesStart defines the index of first vertex to draw
  30989. * @param verticesCount defines the count of vertices to draw
  30990. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30991. */
  30992. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30993. private _drawMode;
  30994. /** @hidden */
  30995. protected _reportDrawCall(): void;
  30996. /** @hidden */
  30997. _releaseEffect(effect: Effect): void;
  30998. /** @hidden */
  30999. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31000. /**
  31001. * Create a new effect (used to store vertex/fragment shaders)
  31002. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31003. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31004. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31005. * @param samplers defines an array of string used to represent textures
  31006. * @param defines defines the string containing the defines to use to compile the shaders
  31007. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31008. * @param onCompiled defines a function to call when the effect creation is successful
  31009. * @param onError defines a function to call when the effect creation has failed
  31010. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31011. * @returns the new Effect
  31012. */
  31013. 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;
  31014. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31015. private _compileShader;
  31016. private _compileRawShader;
  31017. /**
  31018. * Directly creates a webGL program
  31019. * @param pipelineContext defines the pipeline context to attach to
  31020. * @param vertexCode defines the vertex shader code to use
  31021. * @param fragmentCode defines the fragment shader code to use
  31022. * @param context defines the webGL context to use (if not set, the current one will be used)
  31023. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31024. * @returns the new webGL program
  31025. */
  31026. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31027. /**
  31028. * Creates a webGL program
  31029. * @param pipelineContext defines the pipeline context to attach to
  31030. * @param vertexCode defines the vertex shader code to use
  31031. * @param fragmentCode defines the fragment shader code to use
  31032. * @param defines defines the string containing the defines to use to compile the shaders
  31033. * @param context defines the webGL context to use (if not set, the current one will be used)
  31034. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31035. * @returns the new webGL program
  31036. */
  31037. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31038. /**
  31039. * Creates a new pipeline context
  31040. * @returns the new pipeline
  31041. */
  31042. createPipelineContext(): IPipelineContext;
  31043. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31044. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31045. /** @hidden */
  31046. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31047. /** @hidden */
  31048. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31049. /** @hidden */
  31050. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31051. /**
  31052. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31053. * @param pipelineContext defines the pipeline context to use
  31054. * @param uniformsNames defines the list of uniform names
  31055. * @returns an array of webGL uniform locations
  31056. */
  31057. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31058. /**
  31059. * Gets the lsit of active attributes for a given webGL program
  31060. * @param pipelineContext defines the pipeline context to use
  31061. * @param attributesNames defines the list of attribute names to get
  31062. * @returns an array of indices indicating the offset of each attribute
  31063. */
  31064. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31065. /**
  31066. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31067. * @param effect defines the effect to activate
  31068. */
  31069. enableEffect(effect: Nullable<Effect>): void;
  31070. /**
  31071. * Set the value of an uniform to a number (int)
  31072. * @param uniform defines the webGL uniform location where to store the value
  31073. * @param value defines the int number to store
  31074. */
  31075. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31076. /**
  31077. * Set the value of an uniform to an array of int32
  31078. * @param uniform defines the webGL uniform location where to store the value
  31079. * @param array defines the array of int32 to store
  31080. */
  31081. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31082. /**
  31083. * Set the value of an uniform to an array of int32 (stored as vec2)
  31084. * @param uniform defines the webGL uniform location where to store the value
  31085. * @param array defines the array of int32 to store
  31086. */
  31087. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31088. /**
  31089. * Set the value of an uniform to an array of int32 (stored as vec3)
  31090. * @param uniform defines the webGL uniform location where to store the value
  31091. * @param array defines the array of int32 to store
  31092. */
  31093. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31094. /**
  31095. * Set the value of an uniform to an array of int32 (stored as vec4)
  31096. * @param uniform defines the webGL uniform location where to store the value
  31097. * @param array defines the array of int32 to store
  31098. */
  31099. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31100. /**
  31101. * Set the value of an uniform to an array of number
  31102. * @param uniform defines the webGL uniform location where to store the value
  31103. * @param array defines the array of number to store
  31104. */
  31105. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31106. /**
  31107. * Set the value of an uniform to an array of number (stored as vec2)
  31108. * @param uniform defines the webGL uniform location where to store the value
  31109. * @param array defines the array of number to store
  31110. */
  31111. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31112. /**
  31113. * Set the value of an uniform to an array of number (stored as vec3)
  31114. * @param uniform defines the webGL uniform location where to store the value
  31115. * @param array defines the array of number to store
  31116. */
  31117. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31118. /**
  31119. * Set the value of an uniform to an array of number (stored as vec4)
  31120. * @param uniform defines the webGL uniform location where to store the value
  31121. * @param array defines the array of number to store
  31122. */
  31123. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31124. /**
  31125. * Set the value of an uniform to an array of float32 (stored as matrices)
  31126. * @param uniform defines the webGL uniform location where to store the value
  31127. * @param matrices defines the array of float32 to store
  31128. */
  31129. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31130. /**
  31131. * Set the value of an uniform to a matrix (3x3)
  31132. * @param uniform defines the webGL uniform location where to store the value
  31133. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31134. */
  31135. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31136. /**
  31137. * Set the value of an uniform to a matrix (2x2)
  31138. * @param uniform defines the webGL uniform location where to store the value
  31139. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31140. */
  31141. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31142. /**
  31143. * Set the value of an uniform to a number (float)
  31144. * @param uniform defines the webGL uniform location where to store the value
  31145. * @param value defines the float number to store
  31146. */
  31147. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31148. /**
  31149. * Set the value of an uniform to a vec2
  31150. * @param uniform defines the webGL uniform location where to store the value
  31151. * @param x defines the 1st component of the value
  31152. * @param y defines the 2nd component of the value
  31153. */
  31154. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31155. /**
  31156. * Set the value of an uniform to a vec3
  31157. * @param uniform defines the webGL uniform location where to store the value
  31158. * @param x defines the 1st component of the value
  31159. * @param y defines the 2nd component of the value
  31160. * @param z defines the 3rd component of the value
  31161. */
  31162. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31163. /**
  31164. * Set the value of an uniform to a vec4
  31165. * @param uniform defines the webGL uniform location where to store the value
  31166. * @param x defines the 1st component of the value
  31167. * @param y defines the 2nd component of the value
  31168. * @param z defines the 3rd component of the value
  31169. * @param w defines the 4th component of the value
  31170. */
  31171. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31172. /**
  31173. * Apply all cached states (depth, culling, stencil and alpha)
  31174. */
  31175. applyStates(): void;
  31176. /**
  31177. * Enable or disable color writing
  31178. * @param enable defines the state to set
  31179. */
  31180. setColorWrite(enable: boolean): void;
  31181. /**
  31182. * Gets a boolean indicating if color writing is enabled
  31183. * @returns the current color writing state
  31184. */
  31185. getColorWrite(): boolean;
  31186. /**
  31187. * Gets the depth culling state manager
  31188. */
  31189. readonly depthCullingState: DepthCullingState;
  31190. /**
  31191. * Gets the alpha state manager
  31192. */
  31193. readonly alphaState: AlphaState;
  31194. /**
  31195. * Gets the stencil state manager
  31196. */
  31197. readonly stencilState: StencilState;
  31198. /**
  31199. * Clears the list of texture accessible through engine.
  31200. * This can help preventing texture load conflict due to name collision.
  31201. */
  31202. clearInternalTexturesCache(): void;
  31203. /**
  31204. * Force the entire cache to be cleared
  31205. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31206. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31207. */
  31208. wipeCaches(bruteForce?: boolean): void;
  31209. /** @hidden */
  31210. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31211. min: number;
  31212. mag: number;
  31213. };
  31214. /** @hidden */
  31215. _createTexture(): WebGLTexture;
  31216. /**
  31217. * Usually called from Texture.ts.
  31218. * Passed information to create a WebGLTexture
  31219. * @param urlArg defines a value which contains one of the following:
  31220. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31221. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31222. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31223. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31224. * @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)
  31225. * @param scene needed for loading to the correct scene
  31226. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31227. * @param onLoad optional callback to be called upon successful completion
  31228. * @param onError optional callback to be called upon failure
  31229. * @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
  31230. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31231. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31232. * @param forcedExtension defines the extension to use to pick the right loader
  31233. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31234. * @param mimeType defines an optional mime type
  31235. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31236. */
  31237. 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;
  31238. /**
  31239. * @hidden
  31240. */
  31241. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31242. /**
  31243. * Creates a raw texture
  31244. * @param data defines the data to store in the texture
  31245. * @param width defines the width of the texture
  31246. * @param height defines the height of the texture
  31247. * @param format defines the format of the data
  31248. * @param generateMipMaps defines if the engine should generate the mip levels
  31249. * @param invertY defines if data must be stored with Y axis inverted
  31250. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31251. * @param compression defines the compression used (null by default)
  31252. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31253. * @returns the raw texture inside an InternalTexture
  31254. */
  31255. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31256. /**
  31257. * Creates a new raw cube texture
  31258. * @param data defines the array of data to use to create each face
  31259. * @param size defines the size of the textures
  31260. * @param format defines the format of the data
  31261. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31262. * @param generateMipMaps defines if the engine should generate the mip levels
  31263. * @param invertY defines if data must be stored with Y axis inverted
  31264. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31265. * @param compression defines the compression used (null by default)
  31266. * @returns the cube texture as an InternalTexture
  31267. */
  31268. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31269. /**
  31270. * Creates a new raw 3D texture
  31271. * @param data defines the data used to create the texture
  31272. * @param width defines the width of the texture
  31273. * @param height defines the height of the texture
  31274. * @param depth defines the depth of the texture
  31275. * @param format defines the format of the texture
  31276. * @param generateMipMaps defines if the engine must generate mip levels
  31277. * @param invertY defines if data must be stored with Y axis inverted
  31278. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31279. * @param compression defines the compressed used (can be null)
  31280. * @param textureType defines the compressed used (can be null)
  31281. * @returns a new raw 3D texture (stored in an InternalTexture)
  31282. */
  31283. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31284. /**
  31285. * Creates a new raw 2D array texture
  31286. * @param data defines the data used to create the texture
  31287. * @param width defines the width of the texture
  31288. * @param height defines the height of the texture
  31289. * @param depth defines the number of layers of the texture
  31290. * @param format defines the format of the texture
  31291. * @param generateMipMaps defines if the engine must generate mip levels
  31292. * @param invertY defines if data must be stored with Y axis inverted
  31293. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31294. * @param compression defines the compressed used (can be null)
  31295. * @param textureType defines the compressed used (can be null)
  31296. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31297. */
  31298. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31299. private _unpackFlipYCached;
  31300. /**
  31301. * In case you are sharing the context with other applications, it might
  31302. * be interested to not cache the unpack flip y state to ensure a consistent
  31303. * value would be set.
  31304. */
  31305. enableUnpackFlipYCached: boolean;
  31306. /** @hidden */
  31307. _unpackFlipY(value: boolean): void;
  31308. /** @hidden */
  31309. _getUnpackAlignement(): number;
  31310. private _getTextureTarget;
  31311. /**
  31312. * Update the sampling mode of a given texture
  31313. * @param samplingMode defines the required sampling mode
  31314. * @param texture defines the texture to update
  31315. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31316. */
  31317. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31318. /**
  31319. * Update the sampling mode of a given texture
  31320. * @param texture defines the texture to update
  31321. * @param wrapU defines the texture wrap mode of the u coordinates
  31322. * @param wrapV defines the texture wrap mode of the v coordinates
  31323. * @param wrapR defines the texture wrap mode of the r coordinates
  31324. */
  31325. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31326. /** @hidden */
  31327. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31328. width: number;
  31329. height: number;
  31330. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31331. /** @hidden */
  31332. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31333. /** @hidden */
  31334. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31335. /** @hidden */
  31336. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31337. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31338. private _prepareWebGLTexture;
  31339. /** @hidden */
  31340. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31341. private _getDepthStencilBuffer;
  31342. /** @hidden */
  31343. _releaseFramebufferObjects(texture: InternalTexture): void;
  31344. /** @hidden */
  31345. _releaseTexture(texture: InternalTexture): void;
  31346. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31347. protected _setProgram(program: WebGLProgram): void;
  31348. protected _boundUniforms: {
  31349. [key: number]: WebGLUniformLocation;
  31350. };
  31351. /**
  31352. * Binds an effect to the webGL context
  31353. * @param effect defines the effect to bind
  31354. */
  31355. bindSamplers(effect: Effect): void;
  31356. private _activateCurrentTexture;
  31357. /** @hidden */
  31358. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31359. /** @hidden */
  31360. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31361. /**
  31362. * Unbind all textures from the webGL context
  31363. */
  31364. unbindAllTextures(): void;
  31365. /**
  31366. * Sets a texture to the according uniform.
  31367. * @param channel The texture channel
  31368. * @param uniform The uniform to set
  31369. * @param texture The texture to apply
  31370. */
  31371. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31372. private _bindSamplerUniformToChannel;
  31373. private _getTextureWrapMode;
  31374. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31375. /**
  31376. * Sets an array of texture to the webGL context
  31377. * @param channel defines the channel where the texture array must be set
  31378. * @param uniform defines the associated uniform location
  31379. * @param textures defines the array of textures to bind
  31380. */
  31381. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31382. /** @hidden */
  31383. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31384. private _setTextureParameterFloat;
  31385. private _setTextureParameterInteger;
  31386. /**
  31387. * Unbind all vertex attributes from the webGL context
  31388. */
  31389. unbindAllAttributes(): void;
  31390. /**
  31391. * 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
  31392. */
  31393. releaseEffects(): void;
  31394. /**
  31395. * Dispose and release all associated resources
  31396. */
  31397. dispose(): void;
  31398. /**
  31399. * Attach a new callback raised when context lost event is fired
  31400. * @param callback defines the callback to call
  31401. */
  31402. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31403. /**
  31404. * Attach a new callback raised when context restored event is fired
  31405. * @param callback defines the callback to call
  31406. */
  31407. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31408. /**
  31409. * Get the current error code of the webGL context
  31410. * @returns the error code
  31411. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31412. */
  31413. getError(): number;
  31414. private _canRenderToFloatFramebuffer;
  31415. private _canRenderToHalfFloatFramebuffer;
  31416. private _canRenderToFramebuffer;
  31417. /** @hidden */
  31418. _getWebGLTextureType(type: number): number;
  31419. /** @hidden */
  31420. _getInternalFormat(format: number): number;
  31421. /** @hidden */
  31422. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31423. /** @hidden */
  31424. _getRGBAMultiSampleBufferFormat(type: number): number;
  31425. /** @hidden */
  31426. _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;
  31427. /**
  31428. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31429. * @param x defines the x coordinate of the rectangle where pixels must be read
  31430. * @param y defines the y coordinate of the rectangle where pixels must be read
  31431. * @param width defines the width of the rectangle where pixels must be read
  31432. * @param height defines the height of the rectangle where pixels must be read
  31433. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31434. * @returns a Uint8Array containing RGBA colors
  31435. */
  31436. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31437. private static _isSupported;
  31438. /**
  31439. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31440. * @returns true if the engine can be created
  31441. * @ignorenaming
  31442. */
  31443. static isSupported(): boolean;
  31444. /**
  31445. * Find the next highest power of two.
  31446. * @param x Number to start search from.
  31447. * @return Next highest power of two.
  31448. */
  31449. static CeilingPOT(x: number): number;
  31450. /**
  31451. * Find the next lowest power of two.
  31452. * @param x Number to start search from.
  31453. * @return Next lowest power of two.
  31454. */
  31455. static FloorPOT(x: number): number;
  31456. /**
  31457. * Find the nearest power of two.
  31458. * @param x Number to start search from.
  31459. * @return Next nearest power of two.
  31460. */
  31461. static NearestPOT(x: number): number;
  31462. /**
  31463. * Get the closest exponent of two
  31464. * @param value defines the value to approximate
  31465. * @param max defines the maximum value to return
  31466. * @param mode defines how to define the closest value
  31467. * @returns closest exponent of two of the given value
  31468. */
  31469. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31470. /**
  31471. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31472. * @param func - the function to be called
  31473. * @param requester - the object that will request the next frame. Falls back to window.
  31474. * @returns frame number
  31475. */
  31476. static QueueNewFrame(func: () => void, requester?: any): number;
  31477. /**
  31478. * Gets host document
  31479. * @returns the host document object
  31480. */
  31481. getHostDocument(): Nullable<Document>;
  31482. }
  31483. }
  31484. declare module BABYLON {
  31485. /**
  31486. * Class representing spherical harmonics coefficients to the 3rd degree
  31487. */
  31488. export class SphericalHarmonics {
  31489. /**
  31490. * Defines whether or not the harmonics have been prescaled for rendering.
  31491. */
  31492. preScaled: boolean;
  31493. /**
  31494. * The l0,0 coefficients of the spherical harmonics
  31495. */
  31496. l00: Vector3;
  31497. /**
  31498. * The l1,-1 coefficients of the spherical harmonics
  31499. */
  31500. l1_1: Vector3;
  31501. /**
  31502. * The l1,0 coefficients of the spherical harmonics
  31503. */
  31504. l10: Vector3;
  31505. /**
  31506. * The l1,1 coefficients of the spherical harmonics
  31507. */
  31508. l11: Vector3;
  31509. /**
  31510. * The l2,-2 coefficients of the spherical harmonics
  31511. */
  31512. l2_2: Vector3;
  31513. /**
  31514. * The l2,-1 coefficients of the spherical harmonics
  31515. */
  31516. l2_1: Vector3;
  31517. /**
  31518. * The l2,0 coefficients of the spherical harmonics
  31519. */
  31520. l20: Vector3;
  31521. /**
  31522. * The l2,1 coefficients of the spherical harmonics
  31523. */
  31524. l21: Vector3;
  31525. /**
  31526. * The l2,2 coefficients of the spherical harmonics
  31527. */
  31528. l22: Vector3;
  31529. /**
  31530. * Adds a light to the spherical harmonics
  31531. * @param direction the direction of the light
  31532. * @param color the color of the light
  31533. * @param deltaSolidAngle the delta solid angle of the light
  31534. */
  31535. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31536. /**
  31537. * Scales the spherical harmonics by the given amount
  31538. * @param scale the amount to scale
  31539. */
  31540. scaleInPlace(scale: number): void;
  31541. /**
  31542. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31543. *
  31544. * ```
  31545. * E_lm = A_l * L_lm
  31546. * ```
  31547. *
  31548. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31549. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31550. * the scaling factors are given in equation 9.
  31551. */
  31552. convertIncidentRadianceToIrradiance(): void;
  31553. /**
  31554. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31555. *
  31556. * ```
  31557. * L = (1/pi) * E * rho
  31558. * ```
  31559. *
  31560. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31561. */
  31562. convertIrradianceToLambertianRadiance(): void;
  31563. /**
  31564. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31565. * required operations at run time.
  31566. *
  31567. * This is simply done by scaling back the SH with Ylm constants parameter.
  31568. * The trigonometric part being applied by the shader at run time.
  31569. */
  31570. preScaleForRendering(): void;
  31571. /**
  31572. * Constructs a spherical harmonics from an array.
  31573. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31574. * @returns the spherical harmonics
  31575. */
  31576. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31577. /**
  31578. * Gets the spherical harmonics from polynomial
  31579. * @param polynomial the spherical polynomial
  31580. * @returns the spherical harmonics
  31581. */
  31582. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31583. }
  31584. /**
  31585. * Class representing spherical polynomial coefficients to the 3rd degree
  31586. */
  31587. export class SphericalPolynomial {
  31588. private _harmonics;
  31589. /**
  31590. * The spherical harmonics used to create the polynomials.
  31591. */
  31592. readonly preScaledHarmonics: SphericalHarmonics;
  31593. /**
  31594. * The x coefficients of the spherical polynomial
  31595. */
  31596. x: Vector3;
  31597. /**
  31598. * The y coefficients of the spherical polynomial
  31599. */
  31600. y: Vector3;
  31601. /**
  31602. * The z coefficients of the spherical polynomial
  31603. */
  31604. z: Vector3;
  31605. /**
  31606. * The xx coefficients of the spherical polynomial
  31607. */
  31608. xx: Vector3;
  31609. /**
  31610. * The yy coefficients of the spherical polynomial
  31611. */
  31612. yy: Vector3;
  31613. /**
  31614. * The zz coefficients of the spherical polynomial
  31615. */
  31616. zz: Vector3;
  31617. /**
  31618. * The xy coefficients of the spherical polynomial
  31619. */
  31620. xy: Vector3;
  31621. /**
  31622. * The yz coefficients of the spherical polynomial
  31623. */
  31624. yz: Vector3;
  31625. /**
  31626. * The zx coefficients of the spherical polynomial
  31627. */
  31628. zx: Vector3;
  31629. /**
  31630. * Adds an ambient color to the spherical polynomial
  31631. * @param color the color to add
  31632. */
  31633. addAmbient(color: Color3): void;
  31634. /**
  31635. * Scales the spherical polynomial by the given amount
  31636. * @param scale the amount to scale
  31637. */
  31638. scaleInPlace(scale: number): void;
  31639. /**
  31640. * Gets the spherical polynomial from harmonics
  31641. * @param harmonics the spherical harmonics
  31642. * @returns the spherical polynomial
  31643. */
  31644. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31645. /**
  31646. * Constructs a spherical polynomial from an array.
  31647. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31648. * @returns the spherical polynomial
  31649. */
  31650. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31651. }
  31652. }
  31653. declare module BABYLON {
  31654. /**
  31655. * Defines the source of the internal texture
  31656. */
  31657. export enum InternalTextureSource {
  31658. /**
  31659. * The source of the texture data is unknown
  31660. */
  31661. Unknown = 0,
  31662. /**
  31663. * Texture data comes from an URL
  31664. */
  31665. Url = 1,
  31666. /**
  31667. * Texture data is only used for temporary storage
  31668. */
  31669. Temp = 2,
  31670. /**
  31671. * Texture data comes from raw data (ArrayBuffer)
  31672. */
  31673. Raw = 3,
  31674. /**
  31675. * Texture content is dynamic (video or dynamic texture)
  31676. */
  31677. Dynamic = 4,
  31678. /**
  31679. * Texture content is generated by rendering to it
  31680. */
  31681. RenderTarget = 5,
  31682. /**
  31683. * Texture content is part of a multi render target process
  31684. */
  31685. MultiRenderTarget = 6,
  31686. /**
  31687. * Texture data comes from a cube data file
  31688. */
  31689. Cube = 7,
  31690. /**
  31691. * Texture data comes from a raw cube data
  31692. */
  31693. CubeRaw = 8,
  31694. /**
  31695. * Texture data come from a prefiltered cube data file
  31696. */
  31697. CubePrefiltered = 9,
  31698. /**
  31699. * Texture content is raw 3D data
  31700. */
  31701. Raw3D = 10,
  31702. /**
  31703. * Texture content is raw 2D array data
  31704. */
  31705. Raw2DArray = 11,
  31706. /**
  31707. * Texture content is a depth texture
  31708. */
  31709. Depth = 12,
  31710. /**
  31711. * Texture data comes from a raw cube data encoded with RGBD
  31712. */
  31713. CubeRawRGBD = 13
  31714. }
  31715. /**
  31716. * Class used to store data associated with WebGL texture data for the engine
  31717. * This class should not be used directly
  31718. */
  31719. export class InternalTexture {
  31720. /** @hidden */
  31721. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31722. /**
  31723. * Defines if the texture is ready
  31724. */
  31725. isReady: boolean;
  31726. /**
  31727. * Defines if the texture is a cube texture
  31728. */
  31729. isCube: boolean;
  31730. /**
  31731. * Defines if the texture contains 3D data
  31732. */
  31733. is3D: boolean;
  31734. /**
  31735. * Defines if the texture contains 2D array data
  31736. */
  31737. is2DArray: boolean;
  31738. /**
  31739. * Defines if the texture contains multiview data
  31740. */
  31741. isMultiview: boolean;
  31742. /**
  31743. * Gets the URL used to load this texture
  31744. */
  31745. url: string;
  31746. /**
  31747. * Gets the sampling mode of the texture
  31748. */
  31749. samplingMode: number;
  31750. /**
  31751. * Gets a boolean indicating if the texture needs mipmaps generation
  31752. */
  31753. generateMipMaps: boolean;
  31754. /**
  31755. * Gets the number of samples used by the texture (WebGL2+ only)
  31756. */
  31757. samples: number;
  31758. /**
  31759. * Gets the type of the texture (int, float...)
  31760. */
  31761. type: number;
  31762. /**
  31763. * Gets the format of the texture (RGB, RGBA...)
  31764. */
  31765. format: number;
  31766. /**
  31767. * Observable called when the texture is loaded
  31768. */
  31769. onLoadedObservable: Observable<InternalTexture>;
  31770. /**
  31771. * Gets the width of the texture
  31772. */
  31773. width: number;
  31774. /**
  31775. * Gets the height of the texture
  31776. */
  31777. height: number;
  31778. /**
  31779. * Gets the depth of the texture
  31780. */
  31781. depth: number;
  31782. /**
  31783. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31784. */
  31785. baseWidth: number;
  31786. /**
  31787. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31788. */
  31789. baseHeight: number;
  31790. /**
  31791. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31792. */
  31793. baseDepth: number;
  31794. /**
  31795. * Gets a boolean indicating if the texture is inverted on Y axis
  31796. */
  31797. invertY: boolean;
  31798. /** @hidden */
  31799. _invertVScale: boolean;
  31800. /** @hidden */
  31801. _associatedChannel: number;
  31802. /** @hidden */
  31803. _source: InternalTextureSource;
  31804. /** @hidden */
  31805. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31806. /** @hidden */
  31807. _bufferView: Nullable<ArrayBufferView>;
  31808. /** @hidden */
  31809. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31810. /** @hidden */
  31811. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31812. /** @hidden */
  31813. _size: number;
  31814. /** @hidden */
  31815. _extension: string;
  31816. /** @hidden */
  31817. _files: Nullable<string[]>;
  31818. /** @hidden */
  31819. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31820. /** @hidden */
  31821. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31822. /** @hidden */
  31823. _framebuffer: Nullable<WebGLFramebuffer>;
  31824. /** @hidden */
  31825. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31826. /** @hidden */
  31827. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31828. /** @hidden */
  31829. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31830. /** @hidden */
  31831. _attachments: Nullable<number[]>;
  31832. /** @hidden */
  31833. _cachedCoordinatesMode: Nullable<number>;
  31834. /** @hidden */
  31835. _cachedWrapU: Nullable<number>;
  31836. /** @hidden */
  31837. _cachedWrapV: Nullable<number>;
  31838. /** @hidden */
  31839. _cachedWrapR: Nullable<number>;
  31840. /** @hidden */
  31841. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31842. /** @hidden */
  31843. _isDisabled: boolean;
  31844. /** @hidden */
  31845. _compression: Nullable<string>;
  31846. /** @hidden */
  31847. _generateStencilBuffer: boolean;
  31848. /** @hidden */
  31849. _generateDepthBuffer: boolean;
  31850. /** @hidden */
  31851. _comparisonFunction: number;
  31852. /** @hidden */
  31853. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31854. /** @hidden */
  31855. _lodGenerationScale: number;
  31856. /** @hidden */
  31857. _lodGenerationOffset: number;
  31858. /** @hidden */
  31859. _colorTextureArray: Nullable<WebGLTexture>;
  31860. /** @hidden */
  31861. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31862. /** @hidden */
  31863. _lodTextureHigh: Nullable<BaseTexture>;
  31864. /** @hidden */
  31865. _lodTextureMid: Nullable<BaseTexture>;
  31866. /** @hidden */
  31867. _lodTextureLow: Nullable<BaseTexture>;
  31868. /** @hidden */
  31869. _isRGBD: boolean;
  31870. /** @hidden */
  31871. _linearSpecularLOD: boolean;
  31872. /** @hidden */
  31873. _irradianceTexture: Nullable<BaseTexture>;
  31874. /** @hidden */
  31875. _webGLTexture: Nullable<WebGLTexture>;
  31876. /** @hidden */
  31877. _references: number;
  31878. private _engine;
  31879. /**
  31880. * Gets the Engine the texture belongs to.
  31881. * @returns The babylon engine
  31882. */
  31883. getEngine(): ThinEngine;
  31884. /**
  31885. * Gets the data source type of the texture
  31886. */
  31887. readonly source: InternalTextureSource;
  31888. /**
  31889. * Creates a new InternalTexture
  31890. * @param engine defines the engine to use
  31891. * @param source defines the type of data that will be used
  31892. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31893. */
  31894. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31895. /**
  31896. * Increments the number of references (ie. the number of Texture that point to it)
  31897. */
  31898. incrementReferences(): void;
  31899. /**
  31900. * Change the size of the texture (not the size of the content)
  31901. * @param width defines the new width
  31902. * @param height defines the new height
  31903. * @param depth defines the new depth (1 by default)
  31904. */
  31905. updateSize(width: int, height: int, depth?: int): void;
  31906. /** @hidden */
  31907. _rebuild(): void;
  31908. /** @hidden */
  31909. _swapAndDie(target: InternalTexture): void;
  31910. /**
  31911. * Dispose the current allocated resources
  31912. */
  31913. dispose(): void;
  31914. }
  31915. }
  31916. declare module BABYLON {
  31917. /**
  31918. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31920. */
  31921. export class Analyser {
  31922. /**
  31923. * Gets or sets the smoothing
  31924. * @ignorenaming
  31925. */
  31926. SMOOTHING: number;
  31927. /**
  31928. * Gets or sets the FFT table size
  31929. * @ignorenaming
  31930. */
  31931. FFT_SIZE: number;
  31932. /**
  31933. * Gets or sets the bar graph amplitude
  31934. * @ignorenaming
  31935. */
  31936. BARGRAPHAMPLITUDE: number;
  31937. /**
  31938. * Gets or sets the position of the debug canvas
  31939. * @ignorenaming
  31940. */
  31941. DEBUGCANVASPOS: {
  31942. x: number;
  31943. y: number;
  31944. };
  31945. /**
  31946. * Gets or sets the debug canvas size
  31947. * @ignorenaming
  31948. */
  31949. DEBUGCANVASSIZE: {
  31950. width: number;
  31951. height: number;
  31952. };
  31953. private _byteFreqs;
  31954. private _byteTime;
  31955. private _floatFreqs;
  31956. private _webAudioAnalyser;
  31957. private _debugCanvas;
  31958. private _debugCanvasContext;
  31959. private _scene;
  31960. private _registerFunc;
  31961. private _audioEngine;
  31962. /**
  31963. * Creates a new analyser
  31964. * @param scene defines hosting scene
  31965. */
  31966. constructor(scene: Scene);
  31967. /**
  31968. * Get the number of data values you will have to play with for the visualization
  31969. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31970. * @returns a number
  31971. */
  31972. getFrequencyBinCount(): number;
  31973. /**
  31974. * Gets the current frequency data as a byte array
  31975. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31976. * @returns a Uint8Array
  31977. */
  31978. getByteFrequencyData(): Uint8Array;
  31979. /**
  31980. * Gets the current waveform as a byte array
  31981. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31982. * @returns a Uint8Array
  31983. */
  31984. getByteTimeDomainData(): Uint8Array;
  31985. /**
  31986. * Gets the current frequency data as a float array
  31987. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31988. * @returns a Float32Array
  31989. */
  31990. getFloatFrequencyData(): Float32Array;
  31991. /**
  31992. * Renders the debug canvas
  31993. */
  31994. drawDebugCanvas(): void;
  31995. /**
  31996. * Stops rendering the debug canvas and removes it
  31997. */
  31998. stopDebugCanvas(): void;
  31999. /**
  32000. * Connects two audio nodes
  32001. * @param inputAudioNode defines first node to connect
  32002. * @param outputAudioNode defines second node to connect
  32003. */
  32004. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32005. /**
  32006. * Releases all associated resources
  32007. */
  32008. dispose(): void;
  32009. }
  32010. }
  32011. declare module BABYLON {
  32012. /**
  32013. * This represents an audio engine and it is responsible
  32014. * to play, synchronize and analyse sounds throughout the application.
  32015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32016. */
  32017. export interface IAudioEngine extends IDisposable {
  32018. /**
  32019. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32020. */
  32021. readonly canUseWebAudio: boolean;
  32022. /**
  32023. * Gets the current AudioContext if available.
  32024. */
  32025. readonly audioContext: Nullable<AudioContext>;
  32026. /**
  32027. * The master gain node defines the global audio volume of your audio engine.
  32028. */
  32029. readonly masterGain: GainNode;
  32030. /**
  32031. * Gets whether or not mp3 are supported by your browser.
  32032. */
  32033. readonly isMP3supported: boolean;
  32034. /**
  32035. * Gets whether or not ogg are supported by your browser.
  32036. */
  32037. readonly isOGGsupported: boolean;
  32038. /**
  32039. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32040. * @ignoreNaming
  32041. */
  32042. WarnedWebAudioUnsupported: boolean;
  32043. /**
  32044. * Defines if the audio engine relies on a custom unlocked button.
  32045. * In this case, the embedded button will not be displayed.
  32046. */
  32047. useCustomUnlockedButton: boolean;
  32048. /**
  32049. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32050. */
  32051. readonly unlocked: boolean;
  32052. /**
  32053. * Event raised when audio has been unlocked on the browser.
  32054. */
  32055. onAudioUnlockedObservable: Observable<AudioEngine>;
  32056. /**
  32057. * Event raised when audio has been locked on the browser.
  32058. */
  32059. onAudioLockedObservable: Observable<AudioEngine>;
  32060. /**
  32061. * Flags the audio engine in Locked state.
  32062. * This happens due to new browser policies preventing audio to autoplay.
  32063. */
  32064. lock(): void;
  32065. /**
  32066. * Unlocks the audio engine once a user action has been done on the dom.
  32067. * This is helpful to resume play once browser policies have been satisfied.
  32068. */
  32069. unlock(): void;
  32070. }
  32071. /**
  32072. * This represents the default audio engine used in babylon.
  32073. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32075. */
  32076. export class AudioEngine implements IAudioEngine {
  32077. private _audioContext;
  32078. private _audioContextInitialized;
  32079. private _muteButton;
  32080. private _hostElement;
  32081. /**
  32082. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32083. */
  32084. canUseWebAudio: boolean;
  32085. /**
  32086. * The master gain node defines the global audio volume of your audio engine.
  32087. */
  32088. masterGain: GainNode;
  32089. /**
  32090. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32091. * @ignoreNaming
  32092. */
  32093. WarnedWebAudioUnsupported: boolean;
  32094. /**
  32095. * Gets whether or not mp3 are supported by your browser.
  32096. */
  32097. isMP3supported: boolean;
  32098. /**
  32099. * Gets whether or not ogg are supported by your browser.
  32100. */
  32101. isOGGsupported: boolean;
  32102. /**
  32103. * Gets whether audio has been unlocked on the device.
  32104. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32105. * a user interaction has happened.
  32106. */
  32107. unlocked: boolean;
  32108. /**
  32109. * Defines if the audio engine relies on a custom unlocked button.
  32110. * In this case, the embedded button will not be displayed.
  32111. */
  32112. useCustomUnlockedButton: boolean;
  32113. /**
  32114. * Event raised when audio has been unlocked on the browser.
  32115. */
  32116. onAudioUnlockedObservable: Observable<AudioEngine>;
  32117. /**
  32118. * Event raised when audio has been locked on the browser.
  32119. */
  32120. onAudioLockedObservable: Observable<AudioEngine>;
  32121. /**
  32122. * Gets the current AudioContext if available.
  32123. */
  32124. readonly audioContext: Nullable<AudioContext>;
  32125. private _connectedAnalyser;
  32126. /**
  32127. * Instantiates a new audio engine.
  32128. *
  32129. * There should be only one per page as some browsers restrict the number
  32130. * of audio contexts you can create.
  32131. * @param hostElement defines the host element where to display the mute icon if necessary
  32132. */
  32133. constructor(hostElement?: Nullable<HTMLElement>);
  32134. /**
  32135. * Flags the audio engine in Locked state.
  32136. * This happens due to new browser policies preventing audio to autoplay.
  32137. */
  32138. lock(): void;
  32139. /**
  32140. * Unlocks the audio engine once a user action has been done on the dom.
  32141. * This is helpful to resume play once browser policies have been satisfied.
  32142. */
  32143. unlock(): void;
  32144. private _resumeAudioContext;
  32145. private _initializeAudioContext;
  32146. private _tryToRun;
  32147. private _triggerRunningState;
  32148. private _triggerSuspendedState;
  32149. private _displayMuteButton;
  32150. private _moveButtonToTopLeft;
  32151. private _onResize;
  32152. private _hideMuteButton;
  32153. /**
  32154. * Destroy and release the resources associated with the audio ccontext.
  32155. */
  32156. dispose(): void;
  32157. /**
  32158. * Gets the global volume sets on the master gain.
  32159. * @returns the global volume if set or -1 otherwise
  32160. */
  32161. getGlobalVolume(): number;
  32162. /**
  32163. * Sets the global volume of your experience (sets on the master gain).
  32164. * @param newVolume Defines the new global volume of the application
  32165. */
  32166. setGlobalVolume(newVolume: number): void;
  32167. /**
  32168. * Connect the audio engine to an audio analyser allowing some amazing
  32169. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32171. * @param analyser The analyser to connect to the engine
  32172. */
  32173. connectToAnalyser(analyser: Analyser): void;
  32174. }
  32175. }
  32176. declare module BABYLON {
  32177. /**
  32178. * Interface used to present a loading screen while loading a scene
  32179. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32180. */
  32181. export interface ILoadingScreen {
  32182. /**
  32183. * Function called to display the loading screen
  32184. */
  32185. displayLoadingUI: () => void;
  32186. /**
  32187. * Function called to hide the loading screen
  32188. */
  32189. hideLoadingUI: () => void;
  32190. /**
  32191. * Gets or sets the color to use for the background
  32192. */
  32193. loadingUIBackgroundColor: string;
  32194. /**
  32195. * Gets or sets the text to display while loading
  32196. */
  32197. loadingUIText: string;
  32198. }
  32199. /**
  32200. * Class used for the default loading screen
  32201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32202. */
  32203. export class DefaultLoadingScreen implements ILoadingScreen {
  32204. private _renderingCanvas;
  32205. private _loadingText;
  32206. private _loadingDivBackgroundColor;
  32207. private _loadingDiv;
  32208. private _loadingTextDiv;
  32209. /** Gets or sets the logo url to use for the default loading screen */
  32210. static DefaultLogoUrl: string;
  32211. /** Gets or sets the spinner url to use for the default loading screen */
  32212. static DefaultSpinnerUrl: string;
  32213. /**
  32214. * Creates a new default loading screen
  32215. * @param _renderingCanvas defines the canvas used to render the scene
  32216. * @param _loadingText defines the default text to display
  32217. * @param _loadingDivBackgroundColor defines the default background color
  32218. */
  32219. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32220. /**
  32221. * Function called to display the loading screen
  32222. */
  32223. displayLoadingUI(): void;
  32224. /**
  32225. * Function called to hide the loading screen
  32226. */
  32227. hideLoadingUI(): void;
  32228. /**
  32229. * Gets or sets the text to display while loading
  32230. */
  32231. loadingUIText: string;
  32232. /**
  32233. * Gets or sets the color to use for the background
  32234. */
  32235. loadingUIBackgroundColor: string;
  32236. private _resizeLoadingUI;
  32237. }
  32238. }
  32239. declare module BABYLON {
  32240. /**
  32241. * Interface for any object that can request an animation frame
  32242. */
  32243. export interface ICustomAnimationFrameRequester {
  32244. /**
  32245. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32246. */
  32247. renderFunction?: Function;
  32248. /**
  32249. * Called to request the next frame to render to
  32250. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32251. */
  32252. requestAnimationFrame: Function;
  32253. /**
  32254. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32255. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32256. */
  32257. requestID?: number;
  32258. }
  32259. }
  32260. declare module BABYLON {
  32261. /**
  32262. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32263. */
  32264. export class PerformanceMonitor {
  32265. private _enabled;
  32266. private _rollingFrameTime;
  32267. private _lastFrameTimeMs;
  32268. /**
  32269. * constructor
  32270. * @param frameSampleSize The number of samples required to saturate the sliding window
  32271. */
  32272. constructor(frameSampleSize?: number);
  32273. /**
  32274. * Samples current frame
  32275. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32276. */
  32277. sampleFrame(timeMs?: number): void;
  32278. /**
  32279. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32280. */
  32281. readonly averageFrameTime: number;
  32282. /**
  32283. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32284. */
  32285. readonly averageFrameTimeVariance: number;
  32286. /**
  32287. * Returns the frame time of the most recent frame
  32288. */
  32289. readonly instantaneousFrameTime: number;
  32290. /**
  32291. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32292. */
  32293. readonly averageFPS: number;
  32294. /**
  32295. * Returns the average framerate in frames per second using the most recent frame time
  32296. */
  32297. readonly instantaneousFPS: number;
  32298. /**
  32299. * Returns true if enough samples have been taken to completely fill the sliding window
  32300. */
  32301. readonly isSaturated: boolean;
  32302. /**
  32303. * Enables contributions to the sliding window sample set
  32304. */
  32305. enable(): void;
  32306. /**
  32307. * Disables contributions to the sliding window sample set
  32308. * Samples will not be interpolated over the disabled period
  32309. */
  32310. disable(): void;
  32311. /**
  32312. * Returns true if sampling is enabled
  32313. */
  32314. readonly isEnabled: boolean;
  32315. /**
  32316. * Resets performance monitor
  32317. */
  32318. reset(): void;
  32319. }
  32320. /**
  32321. * RollingAverage
  32322. *
  32323. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32324. */
  32325. export class RollingAverage {
  32326. /**
  32327. * Current average
  32328. */
  32329. average: number;
  32330. /**
  32331. * Current variance
  32332. */
  32333. variance: number;
  32334. protected _samples: Array<number>;
  32335. protected _sampleCount: number;
  32336. protected _pos: number;
  32337. protected _m2: number;
  32338. /**
  32339. * constructor
  32340. * @param length The number of samples required to saturate the sliding window
  32341. */
  32342. constructor(length: number);
  32343. /**
  32344. * Adds a sample to the sample set
  32345. * @param v The sample value
  32346. */
  32347. add(v: number): void;
  32348. /**
  32349. * Returns previously added values or null if outside of history or outside the sliding window domain
  32350. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32351. * @return Value previously recorded with add() or null if outside of range
  32352. */
  32353. history(i: number): number;
  32354. /**
  32355. * Returns true if enough samples have been taken to completely fill the sliding window
  32356. * @return true if sample-set saturated
  32357. */
  32358. isSaturated(): boolean;
  32359. /**
  32360. * Resets the rolling average (equivalent to 0 samples taken so far)
  32361. */
  32362. reset(): void;
  32363. /**
  32364. * Wraps a value around the sample range boundaries
  32365. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32366. * @return Wrapped position in sample range
  32367. */
  32368. protected _wrapPosition(i: number): number;
  32369. }
  32370. }
  32371. declare module BABYLON {
  32372. /**
  32373. * This class is used to track a performance counter which is number based.
  32374. * The user has access to many properties which give statistics of different nature.
  32375. *
  32376. * The implementer can track two kinds of Performance Counter: time and count.
  32377. * 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.
  32378. * 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.
  32379. */
  32380. export class PerfCounter {
  32381. /**
  32382. * Gets or sets a global boolean to turn on and off all the counters
  32383. */
  32384. static Enabled: boolean;
  32385. /**
  32386. * Returns the smallest value ever
  32387. */
  32388. readonly min: number;
  32389. /**
  32390. * Returns the biggest value ever
  32391. */
  32392. readonly max: number;
  32393. /**
  32394. * Returns the average value since the performance counter is running
  32395. */
  32396. readonly average: number;
  32397. /**
  32398. * Returns the average value of the last second the counter was monitored
  32399. */
  32400. readonly lastSecAverage: number;
  32401. /**
  32402. * Returns the current value
  32403. */
  32404. readonly current: number;
  32405. /**
  32406. * Gets the accumulated total
  32407. */
  32408. readonly total: number;
  32409. /**
  32410. * Gets the total value count
  32411. */
  32412. readonly count: number;
  32413. /**
  32414. * Creates a new counter
  32415. */
  32416. constructor();
  32417. /**
  32418. * Call this method to start monitoring a new frame.
  32419. * 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.
  32420. */
  32421. fetchNewFrame(): void;
  32422. /**
  32423. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32424. * @param newCount the count value to add to the monitored count
  32425. * @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.
  32426. */
  32427. addCount(newCount: number, fetchResult: boolean): void;
  32428. /**
  32429. * Start monitoring this performance counter
  32430. */
  32431. beginMonitoring(): void;
  32432. /**
  32433. * Compute the time lapsed since the previous beginMonitoring() call.
  32434. * @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
  32435. */
  32436. endMonitoring(newFrame?: boolean): void;
  32437. private _fetchResult;
  32438. private _startMonitoringTime;
  32439. private _min;
  32440. private _max;
  32441. private _average;
  32442. private _current;
  32443. private _totalValueCount;
  32444. private _totalAccumulated;
  32445. private _lastSecAverage;
  32446. private _lastSecAccumulated;
  32447. private _lastSecTime;
  32448. private _lastSecValueCount;
  32449. }
  32450. }
  32451. declare module BABYLON {
  32452. interface ThinEngine {
  32453. /**
  32454. * Sets alpha constants used by some alpha blending modes
  32455. * @param r defines the red component
  32456. * @param g defines the green component
  32457. * @param b defines the blue component
  32458. * @param a defines the alpha component
  32459. */
  32460. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32461. /**
  32462. * Sets the current alpha mode
  32463. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32464. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32465. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32466. */
  32467. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32468. /**
  32469. * Gets the current alpha mode
  32470. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32471. * @returns the current alpha mode
  32472. */
  32473. getAlphaMode(): number;
  32474. /**
  32475. * Sets the current alpha equation
  32476. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32477. */
  32478. setAlphaEquation(equation: number): void;
  32479. /**
  32480. * Gets the current alpha equation.
  32481. * @returns the current alpha equation
  32482. */
  32483. getAlphaEquation(): number;
  32484. }
  32485. }
  32486. declare module BABYLON {
  32487. /**
  32488. * Defines the interface used by display changed events
  32489. */
  32490. export interface IDisplayChangedEventArgs {
  32491. /** Gets the vrDisplay object (if any) */
  32492. vrDisplay: Nullable<any>;
  32493. /** Gets a boolean indicating if webVR is supported */
  32494. vrSupported: boolean;
  32495. }
  32496. /**
  32497. * Defines the interface used by objects containing a viewport (like a camera)
  32498. */
  32499. interface IViewportOwnerLike {
  32500. /**
  32501. * Gets or sets the viewport
  32502. */
  32503. viewport: IViewportLike;
  32504. }
  32505. /**
  32506. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32507. */
  32508. export class Engine extends ThinEngine {
  32509. /** Defines that alpha blending is disabled */
  32510. static readonly ALPHA_DISABLE: number;
  32511. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32512. static readonly ALPHA_ADD: number;
  32513. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32514. static readonly ALPHA_COMBINE: number;
  32515. /** Defines that alpha blending to DEST - SRC * DEST */
  32516. static readonly ALPHA_SUBTRACT: number;
  32517. /** Defines that alpha blending to SRC * DEST */
  32518. static readonly ALPHA_MULTIPLY: number;
  32519. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32520. static readonly ALPHA_MAXIMIZED: number;
  32521. /** Defines that alpha blending to SRC + DEST */
  32522. static readonly ALPHA_ONEONE: number;
  32523. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32524. static readonly ALPHA_PREMULTIPLIED: number;
  32525. /**
  32526. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32527. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32528. */
  32529. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32530. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32531. static readonly ALPHA_INTERPOLATE: number;
  32532. /**
  32533. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32534. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32535. */
  32536. static readonly ALPHA_SCREENMODE: number;
  32537. /** Defines that the ressource is not delayed*/
  32538. static readonly DELAYLOADSTATE_NONE: number;
  32539. /** Defines that the ressource was successfully delay loaded */
  32540. static readonly DELAYLOADSTATE_LOADED: number;
  32541. /** Defines that the ressource is currently delay loading */
  32542. static readonly DELAYLOADSTATE_LOADING: number;
  32543. /** Defines that the ressource is delayed and has not started loading */
  32544. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32545. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32546. static readonly NEVER: number;
  32547. /** 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 */
  32548. static readonly ALWAYS: number;
  32549. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32550. static readonly LESS: number;
  32551. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32552. static readonly EQUAL: number;
  32553. /** 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 */
  32554. static readonly LEQUAL: number;
  32555. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32556. static readonly GREATER: number;
  32557. /** 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 */
  32558. static readonly GEQUAL: number;
  32559. /** 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 */
  32560. static readonly NOTEQUAL: number;
  32561. /** Passed to stencilOperation to specify that stencil value must be kept */
  32562. static readonly KEEP: number;
  32563. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32564. static readonly REPLACE: number;
  32565. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32566. static readonly INCR: number;
  32567. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32568. static readonly DECR: number;
  32569. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32570. static readonly INVERT: number;
  32571. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32572. static readonly INCR_WRAP: number;
  32573. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32574. static readonly DECR_WRAP: number;
  32575. /** Texture is not repeating outside of 0..1 UVs */
  32576. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32577. /** Texture is repeating outside of 0..1 UVs */
  32578. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32579. /** Texture is repeating and mirrored */
  32580. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32581. /** ALPHA */
  32582. static readonly TEXTUREFORMAT_ALPHA: number;
  32583. /** LUMINANCE */
  32584. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32585. /** LUMINANCE_ALPHA */
  32586. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32587. /** RGB */
  32588. static readonly TEXTUREFORMAT_RGB: number;
  32589. /** RGBA */
  32590. static readonly TEXTUREFORMAT_RGBA: number;
  32591. /** RED */
  32592. static readonly TEXTUREFORMAT_RED: number;
  32593. /** RED (2nd reference) */
  32594. static readonly TEXTUREFORMAT_R: number;
  32595. /** RG */
  32596. static readonly TEXTUREFORMAT_RG: number;
  32597. /** RED_INTEGER */
  32598. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32599. /** RED_INTEGER (2nd reference) */
  32600. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32601. /** RG_INTEGER */
  32602. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32603. /** RGB_INTEGER */
  32604. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32605. /** RGBA_INTEGER */
  32606. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32607. /** UNSIGNED_BYTE */
  32608. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32609. /** UNSIGNED_BYTE (2nd reference) */
  32610. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32611. /** FLOAT */
  32612. static readonly TEXTURETYPE_FLOAT: number;
  32613. /** HALF_FLOAT */
  32614. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32615. /** BYTE */
  32616. static readonly TEXTURETYPE_BYTE: number;
  32617. /** SHORT */
  32618. static readonly TEXTURETYPE_SHORT: number;
  32619. /** UNSIGNED_SHORT */
  32620. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32621. /** INT */
  32622. static readonly TEXTURETYPE_INT: number;
  32623. /** UNSIGNED_INT */
  32624. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32625. /** UNSIGNED_SHORT_4_4_4_4 */
  32626. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32627. /** UNSIGNED_SHORT_5_5_5_1 */
  32628. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32629. /** UNSIGNED_SHORT_5_6_5 */
  32630. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32631. /** UNSIGNED_INT_2_10_10_10_REV */
  32632. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32633. /** UNSIGNED_INT_24_8 */
  32634. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32635. /** UNSIGNED_INT_10F_11F_11F_REV */
  32636. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32637. /** UNSIGNED_INT_5_9_9_9_REV */
  32638. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32639. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32640. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32641. /** nearest is mag = nearest and min = nearest and mip = linear */
  32642. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32643. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32644. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32645. /** Trilinear is mag = linear and min = linear and mip = linear */
  32646. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32647. /** nearest is mag = nearest and min = nearest and mip = linear */
  32648. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32649. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32650. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32651. /** Trilinear is mag = linear and min = linear and mip = linear */
  32652. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32653. /** mag = nearest and min = nearest and mip = nearest */
  32654. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32655. /** mag = nearest and min = linear and mip = nearest */
  32656. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32657. /** mag = nearest and min = linear and mip = linear */
  32658. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32659. /** mag = nearest and min = linear and mip = none */
  32660. static readonly TEXTURE_NEAREST_LINEAR: number;
  32661. /** mag = nearest and min = nearest and mip = none */
  32662. static readonly TEXTURE_NEAREST_NEAREST: number;
  32663. /** mag = linear and min = nearest and mip = nearest */
  32664. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32665. /** mag = linear and min = nearest and mip = linear */
  32666. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32667. /** mag = linear and min = linear and mip = none */
  32668. static readonly TEXTURE_LINEAR_LINEAR: number;
  32669. /** mag = linear and min = nearest and mip = none */
  32670. static readonly TEXTURE_LINEAR_NEAREST: number;
  32671. /** Explicit coordinates mode */
  32672. static readonly TEXTURE_EXPLICIT_MODE: number;
  32673. /** Spherical coordinates mode */
  32674. static readonly TEXTURE_SPHERICAL_MODE: number;
  32675. /** Planar coordinates mode */
  32676. static readonly TEXTURE_PLANAR_MODE: number;
  32677. /** Cubic coordinates mode */
  32678. static readonly TEXTURE_CUBIC_MODE: number;
  32679. /** Projection coordinates mode */
  32680. static readonly TEXTURE_PROJECTION_MODE: number;
  32681. /** Skybox coordinates mode */
  32682. static readonly TEXTURE_SKYBOX_MODE: number;
  32683. /** Inverse Cubic coordinates mode */
  32684. static readonly TEXTURE_INVCUBIC_MODE: number;
  32685. /** Equirectangular coordinates mode */
  32686. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32687. /** Equirectangular Fixed coordinates mode */
  32688. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32689. /** Equirectangular Fixed Mirrored coordinates mode */
  32690. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32691. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32692. static readonly SCALEMODE_FLOOR: number;
  32693. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32694. static readonly SCALEMODE_NEAREST: number;
  32695. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32696. static readonly SCALEMODE_CEILING: number;
  32697. /**
  32698. * Returns the current npm package of the sdk
  32699. */
  32700. static readonly NpmPackage: string;
  32701. /**
  32702. * Returns the current version of the framework
  32703. */
  32704. static readonly Version: string;
  32705. /** Gets the list of created engines */
  32706. static readonly Instances: Engine[];
  32707. /**
  32708. * Gets the latest created engine
  32709. */
  32710. static readonly LastCreatedEngine: Nullable<Engine>;
  32711. /**
  32712. * Gets the latest created scene
  32713. */
  32714. static readonly LastCreatedScene: Nullable<Scene>;
  32715. /**
  32716. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32717. * @param flag defines which part of the materials must be marked as dirty
  32718. * @param predicate defines a predicate used to filter which materials should be affected
  32719. */
  32720. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32721. /**
  32722. * Method called to create the default loading screen.
  32723. * This can be overriden in your own app.
  32724. * @param canvas The rendering canvas element
  32725. * @returns The loading screen
  32726. */
  32727. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32728. /**
  32729. * Method called to create the default rescale post process on each engine.
  32730. */
  32731. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32732. /**
  32733. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32734. **/
  32735. enableOfflineSupport: boolean;
  32736. /**
  32737. * 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)
  32738. **/
  32739. disableManifestCheck: boolean;
  32740. /**
  32741. * Gets the list of created scenes
  32742. */
  32743. scenes: Scene[];
  32744. /**
  32745. * Event raised when a new scene is created
  32746. */
  32747. onNewSceneAddedObservable: Observable<Scene>;
  32748. /**
  32749. * Gets the list of created postprocesses
  32750. */
  32751. postProcesses: PostProcess[];
  32752. /**
  32753. * Gets a boolean indicating if the pointer is currently locked
  32754. */
  32755. isPointerLock: boolean;
  32756. /**
  32757. * Observable event triggered each time the rendering canvas is resized
  32758. */
  32759. onResizeObservable: Observable<Engine>;
  32760. /**
  32761. * Observable event triggered each time the canvas loses focus
  32762. */
  32763. onCanvasBlurObservable: Observable<Engine>;
  32764. /**
  32765. * Observable event triggered each time the canvas gains focus
  32766. */
  32767. onCanvasFocusObservable: Observable<Engine>;
  32768. /**
  32769. * Observable event triggered each time the canvas receives pointerout event
  32770. */
  32771. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32772. /**
  32773. * Observable raised when the engine begins a new frame
  32774. */
  32775. onBeginFrameObservable: Observable<Engine>;
  32776. /**
  32777. * If set, will be used to request the next animation frame for the render loop
  32778. */
  32779. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32780. /**
  32781. * Observable raised when the engine ends the current frame
  32782. */
  32783. onEndFrameObservable: Observable<Engine>;
  32784. /**
  32785. * Observable raised when the engine is about to compile a shader
  32786. */
  32787. onBeforeShaderCompilationObservable: Observable<Engine>;
  32788. /**
  32789. * Observable raised when the engine has jsut compiled a shader
  32790. */
  32791. onAfterShaderCompilationObservable: Observable<Engine>;
  32792. /**
  32793. * Gets the audio engine
  32794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32795. * @ignorenaming
  32796. */
  32797. static audioEngine: IAudioEngine;
  32798. /**
  32799. * Default AudioEngine factory responsible of creating the Audio Engine.
  32800. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32801. */
  32802. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32803. /**
  32804. * Default offline support factory responsible of creating a tool used to store data locally.
  32805. * By default, this will create a Database object if the workload has been embedded.
  32806. */
  32807. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32808. private _loadingScreen;
  32809. private _pointerLockRequested;
  32810. private _dummyFramebuffer;
  32811. private _rescalePostProcess;
  32812. private _deterministicLockstep;
  32813. private _lockstepMaxSteps;
  32814. private _timeStep;
  32815. protected readonly _supportsHardwareTextureRescaling: boolean;
  32816. private _fps;
  32817. private _deltaTime;
  32818. /** @hidden */
  32819. _drawCalls: PerfCounter;
  32820. /**
  32821. * Turn this value on if you want to pause FPS computation when in background
  32822. */
  32823. disablePerformanceMonitorInBackground: boolean;
  32824. private _performanceMonitor;
  32825. /**
  32826. * Gets the performance monitor attached to this engine
  32827. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32828. */
  32829. readonly performanceMonitor: PerformanceMonitor;
  32830. private _onFocus;
  32831. private _onBlur;
  32832. private _onCanvasPointerOut;
  32833. private _onCanvasBlur;
  32834. private _onCanvasFocus;
  32835. private _onFullscreenChange;
  32836. private _onPointerLockChange;
  32837. /**
  32838. * Gets the HTML element used to attach event listeners
  32839. * @returns a HTML element
  32840. */
  32841. getInputElement(): Nullable<HTMLElement>;
  32842. /**
  32843. * Creates a new engine
  32844. * @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
  32845. * @param antialias defines enable antialiasing (default: false)
  32846. * @param options defines further options to be sent to the getContext() function
  32847. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32848. */
  32849. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32850. /**
  32851. * Gets current aspect ratio
  32852. * @param viewportOwner defines the camera to use to get the aspect ratio
  32853. * @param useScreen defines if screen size must be used (or the current render target if any)
  32854. * @returns a number defining the aspect ratio
  32855. */
  32856. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32857. /**
  32858. * Gets current screen aspect ratio
  32859. * @returns a number defining the aspect ratio
  32860. */
  32861. getScreenAspectRatio(): number;
  32862. /**
  32863. * Gets the client rect of the HTML canvas attached with the current webGL context
  32864. * @returns a client rectanglee
  32865. */
  32866. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32867. /**
  32868. * Gets the client rect of the HTML element used for events
  32869. * @returns a client rectanglee
  32870. */
  32871. getInputElementClientRect(): Nullable<ClientRect>;
  32872. /**
  32873. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32874. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32875. * @returns true if engine is in deterministic lock step mode
  32876. */
  32877. isDeterministicLockStep(): boolean;
  32878. /**
  32879. * Gets the max steps when engine is running in deterministic lock step
  32880. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32881. * @returns the max steps
  32882. */
  32883. getLockstepMaxSteps(): number;
  32884. /**
  32885. * Returns the time in ms between steps when using deterministic lock step.
  32886. * @returns time step in (ms)
  32887. */
  32888. getTimeStep(): number;
  32889. /**
  32890. * Force the mipmap generation for the given render target texture
  32891. * @param texture defines the render target texture to use
  32892. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  32893. */
  32894. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  32895. /** States */
  32896. /**
  32897. * Set various states to the webGL context
  32898. * @param culling defines backface culling state
  32899. * @param zOffset defines the value to apply to zOffset (0 by default)
  32900. * @param force defines if states must be applied even if cache is up to date
  32901. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32902. */
  32903. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32904. /**
  32905. * Set the z offset to apply to current rendering
  32906. * @param value defines the offset to apply
  32907. */
  32908. setZOffset(value: number): void;
  32909. /**
  32910. * Gets the current value of the zOffset
  32911. * @returns the current zOffset state
  32912. */
  32913. getZOffset(): number;
  32914. /**
  32915. * Enable or disable depth buffering
  32916. * @param enable defines the state to set
  32917. */
  32918. setDepthBuffer(enable: boolean): void;
  32919. /**
  32920. * Gets a boolean indicating if depth writing is enabled
  32921. * @returns the current depth writing state
  32922. */
  32923. getDepthWrite(): boolean;
  32924. /**
  32925. * Enable or disable depth writing
  32926. * @param enable defines the state to set
  32927. */
  32928. setDepthWrite(enable: boolean): void;
  32929. /**
  32930. * Gets a boolean indicating if stencil buffer is enabled
  32931. * @returns the current stencil buffer state
  32932. */
  32933. getStencilBuffer(): boolean;
  32934. /**
  32935. * Enable or disable the stencil buffer
  32936. * @param enable defines if the stencil buffer must be enabled or disabled
  32937. */
  32938. setStencilBuffer(enable: boolean): void;
  32939. /**
  32940. * Gets the current stencil mask
  32941. * @returns a number defining the new stencil mask to use
  32942. */
  32943. getStencilMask(): number;
  32944. /**
  32945. * Sets the current stencil mask
  32946. * @param mask defines the new stencil mask to use
  32947. */
  32948. setStencilMask(mask: number): void;
  32949. /**
  32950. * Gets the current stencil function
  32951. * @returns a number defining the stencil function to use
  32952. */
  32953. getStencilFunction(): number;
  32954. /**
  32955. * Gets the current stencil reference value
  32956. * @returns a number defining the stencil reference value to use
  32957. */
  32958. getStencilFunctionReference(): number;
  32959. /**
  32960. * Gets the current stencil mask
  32961. * @returns a number defining the stencil mask to use
  32962. */
  32963. getStencilFunctionMask(): number;
  32964. /**
  32965. * Sets the current stencil function
  32966. * @param stencilFunc defines the new stencil function to use
  32967. */
  32968. setStencilFunction(stencilFunc: number): void;
  32969. /**
  32970. * Sets the current stencil reference
  32971. * @param reference defines the new stencil reference to use
  32972. */
  32973. setStencilFunctionReference(reference: number): void;
  32974. /**
  32975. * Sets the current stencil mask
  32976. * @param mask defines the new stencil mask to use
  32977. */
  32978. setStencilFunctionMask(mask: number): void;
  32979. /**
  32980. * Gets the current stencil operation when stencil fails
  32981. * @returns a number defining stencil operation to use when stencil fails
  32982. */
  32983. getStencilOperationFail(): number;
  32984. /**
  32985. * Gets the current stencil operation when depth fails
  32986. * @returns a number defining stencil operation to use when depth fails
  32987. */
  32988. getStencilOperationDepthFail(): number;
  32989. /**
  32990. * Gets the current stencil operation when stencil passes
  32991. * @returns a number defining stencil operation to use when stencil passes
  32992. */
  32993. getStencilOperationPass(): number;
  32994. /**
  32995. * Sets the stencil operation to use when stencil fails
  32996. * @param operation defines the stencil operation to use when stencil fails
  32997. */
  32998. setStencilOperationFail(operation: number): void;
  32999. /**
  33000. * Sets the stencil operation to use when depth fails
  33001. * @param operation defines the stencil operation to use when depth fails
  33002. */
  33003. setStencilOperationDepthFail(operation: number): void;
  33004. /**
  33005. * Sets the stencil operation to use when stencil passes
  33006. * @param operation defines the stencil operation to use when stencil passes
  33007. */
  33008. setStencilOperationPass(operation: number): void;
  33009. /**
  33010. * Sets a boolean indicating if the dithering state is enabled or disabled
  33011. * @param value defines the dithering state
  33012. */
  33013. setDitheringState(value: boolean): void;
  33014. /**
  33015. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33016. * @param value defines the rasterizer state
  33017. */
  33018. setRasterizerState(value: boolean): void;
  33019. /**
  33020. * Gets the current depth function
  33021. * @returns a number defining the depth function
  33022. */
  33023. getDepthFunction(): Nullable<number>;
  33024. /**
  33025. * Sets the current depth function
  33026. * @param depthFunc defines the function to use
  33027. */
  33028. setDepthFunction(depthFunc: number): void;
  33029. /**
  33030. * Sets the current depth function to GREATER
  33031. */
  33032. setDepthFunctionToGreater(): void;
  33033. /**
  33034. * Sets the current depth function to GEQUAL
  33035. */
  33036. setDepthFunctionToGreaterOrEqual(): void;
  33037. /**
  33038. * Sets the current depth function to LESS
  33039. */
  33040. setDepthFunctionToLess(): void;
  33041. /**
  33042. * Sets the current depth function to LEQUAL
  33043. */
  33044. setDepthFunctionToLessOrEqual(): void;
  33045. private _cachedStencilBuffer;
  33046. private _cachedStencilFunction;
  33047. private _cachedStencilMask;
  33048. private _cachedStencilOperationPass;
  33049. private _cachedStencilOperationFail;
  33050. private _cachedStencilOperationDepthFail;
  33051. private _cachedStencilReference;
  33052. /**
  33053. * Caches the the state of the stencil buffer
  33054. */
  33055. cacheStencilState(): void;
  33056. /**
  33057. * Restores the state of the stencil buffer
  33058. */
  33059. restoreStencilState(): void;
  33060. /**
  33061. * Directly set the WebGL Viewport
  33062. * @param x defines the x coordinate of the viewport (in screen space)
  33063. * @param y defines the y coordinate of the viewport (in screen space)
  33064. * @param width defines the width of the viewport (in screen space)
  33065. * @param height defines the height of the viewport (in screen space)
  33066. * @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
  33067. */
  33068. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33069. /**
  33070. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33071. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33072. * @param y defines the y-coordinate of the corner of the clear rectangle
  33073. * @param width defines the width of the clear rectangle
  33074. * @param height defines the height of the clear rectangle
  33075. * @param clearColor defines the clear color
  33076. */
  33077. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33078. /**
  33079. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33080. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33081. * @param y defines the y-coordinate of the corner of the clear rectangle
  33082. * @param width defines the width of the clear rectangle
  33083. * @param height defines the height of the clear rectangle
  33084. */
  33085. enableScissor(x: number, y: number, width: number, height: number): void;
  33086. /**
  33087. * Disable previously set scissor test rectangle
  33088. */
  33089. disableScissor(): void;
  33090. protected _reportDrawCall(): void;
  33091. /**
  33092. * Initializes a webVR display and starts listening to display change events
  33093. * The onVRDisplayChangedObservable will be notified upon these changes
  33094. * @returns The onVRDisplayChangedObservable
  33095. */
  33096. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33097. /** @hidden */
  33098. _prepareVRComponent(): void;
  33099. /** @hidden */
  33100. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33101. /** @hidden */
  33102. _submitVRFrame(): void;
  33103. /**
  33104. * Call this function to leave webVR mode
  33105. * Will do nothing if webVR is not supported or if there is no webVR device
  33106. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33107. */
  33108. disableVR(): void;
  33109. /**
  33110. * Gets a boolean indicating that the system is in VR mode and is presenting
  33111. * @returns true if VR mode is engaged
  33112. */
  33113. isVRPresenting(): boolean;
  33114. /** @hidden */
  33115. _requestVRFrame(): void;
  33116. /** @hidden */
  33117. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33118. /**
  33119. * Gets the source code of the vertex shader associated with a specific webGL program
  33120. * @param program defines the program to use
  33121. * @returns a string containing the source code of the vertex shader associated with the program
  33122. */
  33123. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33124. /**
  33125. * Gets the source code of the fragment shader associated with a specific webGL program
  33126. * @param program defines the program to use
  33127. * @returns a string containing the source code of the fragment shader associated with the program
  33128. */
  33129. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33130. /**
  33131. * Sets a depth stencil texture from a render target to the according uniform.
  33132. * @param channel The texture channel
  33133. * @param uniform The uniform to set
  33134. * @param texture The render target texture containing the depth stencil texture to apply
  33135. */
  33136. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33137. /**
  33138. * Sets a texture to the webGL context from a postprocess
  33139. * @param channel defines the channel to use
  33140. * @param postProcess defines the source postprocess
  33141. */
  33142. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33143. /**
  33144. * Binds the output of the passed in post process to the texture channel specified
  33145. * @param channel The channel the texture should be bound to
  33146. * @param postProcess The post process which's output should be bound
  33147. */
  33148. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33149. /** @hidden */
  33150. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33151. protected _rebuildBuffers(): void;
  33152. /** @hidden */
  33153. _renderFrame(): void;
  33154. _renderLoop(): void;
  33155. /** @hidden */
  33156. _renderViews(): boolean;
  33157. /**
  33158. * Toggle full screen mode
  33159. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33160. */
  33161. switchFullscreen(requestPointerLock: boolean): void;
  33162. /**
  33163. * Enters full screen mode
  33164. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33165. */
  33166. enterFullscreen(requestPointerLock: boolean): void;
  33167. /**
  33168. * Exits full screen mode
  33169. */
  33170. exitFullscreen(): void;
  33171. /**
  33172. * Enters Pointerlock mode
  33173. */
  33174. enterPointerlock(): void;
  33175. /**
  33176. * Exits Pointerlock mode
  33177. */
  33178. exitPointerlock(): void;
  33179. /**
  33180. * Begin a new frame
  33181. */
  33182. beginFrame(): void;
  33183. /**
  33184. * Enf the current frame
  33185. */
  33186. endFrame(): void;
  33187. resize(): void;
  33188. /**
  33189. * Set the compressed texture format to use, based on the formats you have, and the formats
  33190. * supported by the hardware / browser.
  33191. *
  33192. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33193. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33194. * to API arguments needed to compressed textures. This puts the burden on the container
  33195. * generator to house the arcane code for determining these for current & future formats.
  33196. *
  33197. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33198. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33199. *
  33200. * Note: The result of this call is not taken into account when a texture is base64.
  33201. *
  33202. * @param formatsAvailable defines the list of those format families you have created
  33203. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33204. *
  33205. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33206. * @returns The extension selected.
  33207. */
  33208. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33209. /**
  33210. * Set the compressed texture extensions or file names to skip.
  33211. *
  33212. * @param skippedFiles defines the list of those texture files you want to skip
  33213. * Example: [".dds", ".env", "myfile.png"]
  33214. */
  33215. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33216. /**
  33217. * Force a specific size of the canvas
  33218. * @param width defines the new canvas' width
  33219. * @param height defines the new canvas' height
  33220. */
  33221. setSize(width: number, height: number): void;
  33222. /**
  33223. * Updates a dynamic vertex buffer.
  33224. * @param vertexBuffer the vertex buffer to update
  33225. * @param data the data used to update the vertex buffer
  33226. * @param byteOffset the byte offset of the data
  33227. * @param byteLength the byte length of the data
  33228. */
  33229. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33230. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33231. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33232. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33233. _releaseTexture(texture: InternalTexture): void;
  33234. /**
  33235. * @hidden
  33236. * Rescales a texture
  33237. * @param source input texutre
  33238. * @param destination destination texture
  33239. * @param scene scene to use to render the resize
  33240. * @param internalFormat format to use when resizing
  33241. * @param onComplete callback to be called when resize has completed
  33242. */
  33243. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33244. /**
  33245. * Gets the current framerate
  33246. * @returns a number representing the framerate
  33247. */
  33248. getFps(): number;
  33249. /**
  33250. * Gets the time spent between current and previous frame
  33251. * @returns a number representing the delta time in ms
  33252. */
  33253. getDeltaTime(): number;
  33254. private _measureFps;
  33255. /** @hidden */
  33256. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33257. /**
  33258. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33259. * @param renderTarget The render target to set the frame buffer for
  33260. */
  33261. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33262. /**
  33263. * Update a dynamic index buffer
  33264. * @param indexBuffer defines the target index buffer
  33265. * @param indices defines the data to update
  33266. * @param offset defines the offset in the target index buffer where update should start
  33267. */
  33268. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33269. /**
  33270. * Updates the sample count of a render target texture
  33271. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33272. * @param texture defines the texture to update
  33273. * @param samples defines the sample count to set
  33274. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33275. */
  33276. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33277. /**
  33278. * Updates a depth texture Comparison Mode and Function.
  33279. * If the comparison Function is equal to 0, the mode will be set to none.
  33280. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33281. * @param texture The texture to set the comparison function for
  33282. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33283. */
  33284. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33285. /**
  33286. * Creates a webGL buffer to use with instanciation
  33287. * @param capacity defines the size of the buffer
  33288. * @returns the webGL buffer
  33289. */
  33290. createInstancesBuffer(capacity: number): DataBuffer;
  33291. /**
  33292. * Delete a webGL buffer used with instanciation
  33293. * @param buffer defines the webGL buffer to delete
  33294. */
  33295. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33296. /** @hidden */
  33297. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33298. dispose(): void;
  33299. private _disableTouchAction;
  33300. /**
  33301. * Display the loading screen
  33302. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33303. */
  33304. displayLoadingUI(): void;
  33305. /**
  33306. * Hide the loading screen
  33307. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33308. */
  33309. hideLoadingUI(): void;
  33310. /**
  33311. * Gets the current loading screen object
  33312. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33313. */
  33314. /**
  33315. * Sets the current loading screen object
  33316. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33317. */
  33318. loadingScreen: ILoadingScreen;
  33319. /**
  33320. * Sets the current loading screen text
  33321. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33322. */
  33323. loadingUIText: string;
  33324. /**
  33325. * Sets the current loading screen background color
  33326. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33327. */
  33328. loadingUIBackgroundColor: string;
  33329. /** Pointerlock and fullscreen */
  33330. /**
  33331. * Ask the browser to promote the current element to pointerlock mode
  33332. * @param element defines the DOM element to promote
  33333. */
  33334. static _RequestPointerlock(element: HTMLElement): void;
  33335. /**
  33336. * Asks the browser to exit pointerlock mode
  33337. */
  33338. static _ExitPointerlock(): void;
  33339. /**
  33340. * Ask the browser to promote the current element to fullscreen rendering mode
  33341. * @param element defines the DOM element to promote
  33342. */
  33343. static _RequestFullscreen(element: HTMLElement): void;
  33344. /**
  33345. * Asks the browser to exit fullscreen mode
  33346. */
  33347. static _ExitFullscreen(): void;
  33348. }
  33349. }
  33350. declare module BABYLON {
  33351. /**
  33352. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33353. * during the life time of the application.
  33354. */
  33355. export class EngineStore {
  33356. /** Gets the list of created engines */
  33357. static Instances: Engine[];
  33358. /** @hidden */
  33359. static _LastCreatedScene: Nullable<Scene>;
  33360. /**
  33361. * Gets the latest created engine
  33362. */
  33363. static readonly LastCreatedEngine: Nullable<Engine>;
  33364. /**
  33365. * Gets the latest created scene
  33366. */
  33367. static readonly LastCreatedScene: Nullable<Scene>;
  33368. /**
  33369. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33370. * @ignorenaming
  33371. */
  33372. static UseFallbackTexture: boolean;
  33373. /**
  33374. * Texture content used if a texture cannot loaded
  33375. * @ignorenaming
  33376. */
  33377. static FallbackTexture: string;
  33378. }
  33379. }
  33380. declare module BABYLON {
  33381. /**
  33382. * Helper class that provides a small promise polyfill
  33383. */
  33384. export class PromisePolyfill {
  33385. /**
  33386. * Static function used to check if the polyfill is required
  33387. * If this is the case then the function will inject the polyfill to window.Promise
  33388. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33389. */
  33390. static Apply(force?: boolean): void;
  33391. }
  33392. }
  33393. declare module BABYLON {
  33394. /**
  33395. * Interface for screenshot methods with describe argument called `size` as object with options
  33396. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33397. */
  33398. export interface IScreenshotSize {
  33399. /**
  33400. * number in pixels for canvas height
  33401. */
  33402. height?: number;
  33403. /**
  33404. * multiplier allowing render at a higher or lower resolution
  33405. * If value is defined then height and width will be ignored and taken from camera
  33406. */
  33407. precision?: number;
  33408. /**
  33409. * number in pixels for canvas width
  33410. */
  33411. width?: number;
  33412. }
  33413. }
  33414. declare module BABYLON {
  33415. interface IColor4Like {
  33416. r: float;
  33417. g: float;
  33418. b: float;
  33419. a: float;
  33420. }
  33421. /**
  33422. * Class containing a set of static utilities functions
  33423. */
  33424. export class Tools {
  33425. /**
  33426. * Gets or sets the base URL to use to load assets
  33427. */
  33428. static BaseUrl: string;
  33429. /**
  33430. * Enable/Disable Custom HTTP Request Headers globally.
  33431. * default = false
  33432. * @see CustomRequestHeaders
  33433. */
  33434. static UseCustomRequestHeaders: boolean;
  33435. /**
  33436. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33437. * i.e. when loading files, where the server/service expects an Authorization header
  33438. */
  33439. static CustomRequestHeaders: {
  33440. [key: string]: string;
  33441. };
  33442. /**
  33443. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33444. */
  33445. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33446. /**
  33447. * Default behaviour for cors in the application.
  33448. * It can be a string if the expected behavior is identical in the entire app.
  33449. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33450. */
  33451. static CorsBehavior: string | ((url: string | string[]) => string);
  33452. /**
  33453. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33454. * @ignorenaming
  33455. */
  33456. static UseFallbackTexture: boolean;
  33457. /**
  33458. * Use this object to register external classes like custom textures or material
  33459. * to allow the laoders to instantiate them
  33460. */
  33461. static RegisteredExternalClasses: {
  33462. [key: string]: Object;
  33463. };
  33464. /**
  33465. * Texture content used if a texture cannot loaded
  33466. * @ignorenaming
  33467. */
  33468. static fallbackTexture: string;
  33469. /**
  33470. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33471. * @param u defines the coordinate on X axis
  33472. * @param v defines the coordinate on Y axis
  33473. * @param width defines the width of the source data
  33474. * @param height defines the height of the source data
  33475. * @param pixels defines the source byte array
  33476. * @param color defines the output color
  33477. */
  33478. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33479. /**
  33480. * Interpolates between a and b via alpha
  33481. * @param a The lower value (returned when alpha = 0)
  33482. * @param b The upper value (returned when alpha = 1)
  33483. * @param alpha The interpolation-factor
  33484. * @return The mixed value
  33485. */
  33486. static Mix(a: number, b: number, alpha: number): number;
  33487. /**
  33488. * Tries to instantiate a new object from a given class name
  33489. * @param className defines the class name to instantiate
  33490. * @returns the new object or null if the system was not able to do the instantiation
  33491. */
  33492. static Instantiate(className: string): any;
  33493. /**
  33494. * Provides a slice function that will work even on IE
  33495. * @param data defines the array to slice
  33496. * @param start defines the start of the data (optional)
  33497. * @param end defines the end of the data (optional)
  33498. * @returns the new sliced array
  33499. */
  33500. static Slice<T>(data: T, start?: number, end?: number): T;
  33501. /**
  33502. * Polyfill for setImmediate
  33503. * @param action defines the action to execute after the current execution block
  33504. */
  33505. static SetImmediate(action: () => void): void;
  33506. /**
  33507. * Function indicating if a number is an exponent of 2
  33508. * @param value defines the value to test
  33509. * @returns true if the value is an exponent of 2
  33510. */
  33511. static IsExponentOfTwo(value: number): boolean;
  33512. private static _tmpFloatArray;
  33513. /**
  33514. * Returns the nearest 32-bit single precision float representation of a Number
  33515. * @param value A Number. If the parameter is of a different type, it will get converted
  33516. * to a number or to NaN if it cannot be converted
  33517. * @returns number
  33518. */
  33519. static FloatRound(value: number): number;
  33520. /**
  33521. * Extracts the filename from a path
  33522. * @param path defines the path to use
  33523. * @returns the filename
  33524. */
  33525. static GetFilename(path: string): string;
  33526. /**
  33527. * Extracts the "folder" part of a path (everything before the filename).
  33528. * @param uri The URI to extract the info from
  33529. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33530. * @returns The "folder" part of the path
  33531. */
  33532. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33533. /**
  33534. * Extracts text content from a DOM element hierarchy
  33535. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33536. */
  33537. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33538. /**
  33539. * Convert an angle in radians to degrees
  33540. * @param angle defines the angle to convert
  33541. * @returns the angle in degrees
  33542. */
  33543. static ToDegrees(angle: number): number;
  33544. /**
  33545. * Convert an angle in degrees to radians
  33546. * @param angle defines the angle to convert
  33547. * @returns the angle in radians
  33548. */
  33549. static ToRadians(angle: number): number;
  33550. /**
  33551. * Returns an array if obj is not an array
  33552. * @param obj defines the object to evaluate as an array
  33553. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33554. * @returns either obj directly if obj is an array or a new array containing obj
  33555. */
  33556. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33557. /**
  33558. * Gets the pointer prefix to use
  33559. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33560. */
  33561. static GetPointerPrefix(): string;
  33562. /**
  33563. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33564. * @param url define the url we are trying
  33565. * @param element define the dom element where to configure the cors policy
  33566. */
  33567. static SetCorsBehavior(url: string | string[], element: {
  33568. crossOrigin: string | null;
  33569. }): void;
  33570. /**
  33571. * Removes unwanted characters from an url
  33572. * @param url defines the url to clean
  33573. * @returns the cleaned url
  33574. */
  33575. static CleanUrl(url: string): string;
  33576. /**
  33577. * Gets or sets a function used to pre-process url before using them to load assets
  33578. */
  33579. static PreprocessUrl: (url: string) => string;
  33580. /**
  33581. * Loads an image as an HTMLImageElement.
  33582. * @param input url string, ArrayBuffer, or Blob to load
  33583. * @param onLoad callback called when the image successfully loads
  33584. * @param onError callback called when the image fails to load
  33585. * @param offlineProvider offline provider for caching
  33586. * @param mimeType optional mime type
  33587. * @returns the HTMLImageElement of the loaded image
  33588. */
  33589. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33590. /**
  33591. * Loads a file from a url
  33592. * @param url url string, ArrayBuffer, or Blob to load
  33593. * @param onSuccess callback called when the file successfully loads
  33594. * @param onProgress callback called while file is loading (if the server supports this mode)
  33595. * @param offlineProvider defines the offline provider for caching
  33596. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33597. * @param onError callback called when the file fails to load
  33598. * @returns a file request object
  33599. */
  33600. 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;
  33601. /**
  33602. * Loads a file from a url
  33603. * @param url the file url to load
  33604. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33605. */
  33606. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33607. /**
  33608. * Load a script (identified by an url). When the url returns, the
  33609. * content of this file is added into a new script element, attached to the DOM (body element)
  33610. * @param scriptUrl defines the url of the script to laod
  33611. * @param onSuccess defines the callback called when the script is loaded
  33612. * @param onError defines the callback to call if an error occurs
  33613. * @param scriptId defines the id of the script element
  33614. */
  33615. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33616. /**
  33617. * Load an asynchronous script (identified by an url). When the url returns, the
  33618. * content of this file is added into a new script element, attached to the DOM (body element)
  33619. * @param scriptUrl defines the url of the script to laod
  33620. * @param scriptId defines the id of the script element
  33621. * @returns a promise request object
  33622. */
  33623. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33624. /**
  33625. * Loads a file from a blob
  33626. * @param fileToLoad defines the blob to use
  33627. * @param callback defines the callback to call when data is loaded
  33628. * @param progressCallback defines the callback to call during loading process
  33629. * @returns a file request object
  33630. */
  33631. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33632. /**
  33633. * Reads a file from a File object
  33634. * @param file defines the file to load
  33635. * @param onSuccess defines the callback to call when data is loaded
  33636. * @param onProgress defines the callback to call during loading process
  33637. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33638. * @param onError defines the callback to call when an error occurs
  33639. * @returns a file request object
  33640. */
  33641. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33642. /**
  33643. * Creates a data url from a given string content
  33644. * @param content defines the content to convert
  33645. * @returns the new data url link
  33646. */
  33647. static FileAsURL(content: string): string;
  33648. /**
  33649. * Format the given number to a specific decimal format
  33650. * @param value defines the number to format
  33651. * @param decimals defines the number of decimals to use
  33652. * @returns the formatted string
  33653. */
  33654. static Format(value: number, decimals?: number): string;
  33655. /**
  33656. * Tries to copy an object by duplicating every property
  33657. * @param source defines the source object
  33658. * @param destination defines the target object
  33659. * @param doNotCopyList defines a list of properties to avoid
  33660. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33661. */
  33662. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33663. /**
  33664. * Gets a boolean indicating if the given object has no own property
  33665. * @param obj defines the object to test
  33666. * @returns true if object has no own property
  33667. */
  33668. static IsEmpty(obj: any): boolean;
  33669. /**
  33670. * Function used to register events at window level
  33671. * @param windowElement defines the Window object to use
  33672. * @param events defines the events to register
  33673. */
  33674. static RegisterTopRootEvents(windowElement: Window, events: {
  33675. name: string;
  33676. handler: Nullable<(e: FocusEvent) => any>;
  33677. }[]): void;
  33678. /**
  33679. * Function used to unregister events from window level
  33680. * @param windowElement defines the Window object to use
  33681. * @param events defines the events to unregister
  33682. */
  33683. static UnregisterTopRootEvents(windowElement: Window, events: {
  33684. name: string;
  33685. handler: Nullable<(e: FocusEvent) => any>;
  33686. }[]): void;
  33687. /**
  33688. * @ignore
  33689. */
  33690. static _ScreenshotCanvas: HTMLCanvasElement;
  33691. /**
  33692. * Dumps the current bound framebuffer
  33693. * @param width defines the rendering width
  33694. * @param height defines the rendering height
  33695. * @param engine defines the hosting engine
  33696. * @param successCallback defines the callback triggered once the data are available
  33697. * @param mimeType defines the mime type of the result
  33698. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33699. */
  33700. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33701. /**
  33702. * Converts the canvas data to blob.
  33703. * This acts as a polyfill for browsers not supporting the to blob function.
  33704. * @param canvas Defines the canvas to extract the data from
  33705. * @param successCallback Defines the callback triggered once the data are available
  33706. * @param mimeType Defines the mime type of the result
  33707. */
  33708. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33709. /**
  33710. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33711. * @param successCallback defines the callback triggered once the data are available
  33712. * @param mimeType defines the mime type of the result
  33713. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33714. */
  33715. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33716. /**
  33717. * Downloads a blob in the browser
  33718. * @param blob defines the blob to download
  33719. * @param fileName defines the name of the downloaded file
  33720. */
  33721. static Download(blob: Blob, fileName: string): void;
  33722. /**
  33723. * Captures a screenshot of the current rendering
  33724. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33725. * @param engine defines the rendering engine
  33726. * @param camera defines the source camera
  33727. * @param size This parameter can be set to a single number or to an object with the
  33728. * following (optional) properties: precision, width, height. If a single number is passed,
  33729. * it will be used for both width and height. If an object is passed, the screenshot size
  33730. * will be derived from the parameters. The precision property is a multiplier allowing
  33731. * rendering at a higher or lower resolution
  33732. * @param successCallback defines the callback receives a single parameter which contains the
  33733. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33734. * src parameter of an <img> to display it
  33735. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33736. * Check your browser for supported MIME types
  33737. */
  33738. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33739. /**
  33740. * Captures a screenshot of the current rendering
  33741. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33742. * @param engine defines the rendering engine
  33743. * @param camera defines the source camera
  33744. * @param size This parameter can be set to a single number or to an object with the
  33745. * following (optional) properties: precision, width, height. If a single number is passed,
  33746. * it will be used for both width and height. If an object is passed, the screenshot size
  33747. * will be derived from the parameters. The precision property is a multiplier allowing
  33748. * rendering at a higher or lower resolution
  33749. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33750. * Check your browser for supported MIME types
  33751. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33752. * to the src parameter of an <img> to display it
  33753. */
  33754. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33755. /**
  33756. * Generates an image screenshot from the specified camera.
  33757. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33758. * @param engine The engine to use for rendering
  33759. * @param camera The camera to use for rendering
  33760. * @param size This parameter can be set to a single number or to an object with the
  33761. * following (optional) properties: precision, width, height. If a single number is passed,
  33762. * it will be used for both width and height. If an object is passed, the screenshot size
  33763. * will be derived from the parameters. The precision property is a multiplier allowing
  33764. * rendering at a higher or lower resolution
  33765. * @param successCallback The callback receives a single parameter which contains the
  33766. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33767. * src parameter of an <img> to display it
  33768. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33769. * Check your browser for supported MIME types
  33770. * @param samples Texture samples (default: 1)
  33771. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33772. * @param fileName A name for for the downloaded file.
  33773. */
  33774. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33775. /**
  33776. * Generates an image screenshot from the specified camera.
  33777. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33778. * @param engine The engine to use for rendering
  33779. * @param camera The camera to use for rendering
  33780. * @param size This parameter can be set to a single number or to an object with the
  33781. * following (optional) properties: precision, width, height. If a single number is passed,
  33782. * it will be used for both width and height. If an object is passed, the screenshot size
  33783. * will be derived from the parameters. The precision property is a multiplier allowing
  33784. * rendering at a higher or lower resolution
  33785. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33786. * Check your browser for supported MIME types
  33787. * @param samples Texture samples (default: 1)
  33788. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33789. * @param fileName A name for for the downloaded file.
  33790. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33791. * to the src parameter of an <img> to display it
  33792. */
  33793. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33794. /**
  33795. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33796. * Be aware Math.random() could cause collisions, but:
  33797. * "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"
  33798. * @returns a pseudo random id
  33799. */
  33800. static RandomId(): string;
  33801. /**
  33802. * Test if the given uri is a base64 string
  33803. * @param uri The uri to test
  33804. * @return True if the uri is a base64 string or false otherwise
  33805. */
  33806. static IsBase64(uri: string): boolean;
  33807. /**
  33808. * Decode the given base64 uri.
  33809. * @param uri The uri to decode
  33810. * @return The decoded base64 data.
  33811. */
  33812. static DecodeBase64(uri: string): ArrayBuffer;
  33813. /**
  33814. * Gets the absolute url.
  33815. * @param url the input url
  33816. * @return the absolute url
  33817. */
  33818. static GetAbsoluteUrl(url: string): string;
  33819. /**
  33820. * No log
  33821. */
  33822. static readonly NoneLogLevel: number;
  33823. /**
  33824. * Only message logs
  33825. */
  33826. static readonly MessageLogLevel: number;
  33827. /**
  33828. * Only warning logs
  33829. */
  33830. static readonly WarningLogLevel: number;
  33831. /**
  33832. * Only error logs
  33833. */
  33834. static readonly ErrorLogLevel: number;
  33835. /**
  33836. * All logs
  33837. */
  33838. static readonly AllLogLevel: number;
  33839. /**
  33840. * Gets a value indicating the number of loading errors
  33841. * @ignorenaming
  33842. */
  33843. static readonly errorsCount: number;
  33844. /**
  33845. * Callback called when a new log is added
  33846. */
  33847. static OnNewCacheEntry: (entry: string) => void;
  33848. /**
  33849. * Log a message to the console
  33850. * @param message defines the message to log
  33851. */
  33852. static Log(message: string): void;
  33853. /**
  33854. * Write a warning message to the console
  33855. * @param message defines the message to log
  33856. */
  33857. static Warn(message: string): void;
  33858. /**
  33859. * Write an error message to the console
  33860. * @param message defines the message to log
  33861. */
  33862. static Error(message: string): void;
  33863. /**
  33864. * Gets current log cache (list of logs)
  33865. */
  33866. static readonly LogCache: string;
  33867. /**
  33868. * Clears the log cache
  33869. */
  33870. static ClearLogCache(): void;
  33871. /**
  33872. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33873. */
  33874. static LogLevels: number;
  33875. /**
  33876. * Checks if the window object exists
  33877. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33878. */
  33879. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33880. /**
  33881. * No performance log
  33882. */
  33883. static readonly PerformanceNoneLogLevel: number;
  33884. /**
  33885. * Use user marks to log performance
  33886. */
  33887. static readonly PerformanceUserMarkLogLevel: number;
  33888. /**
  33889. * Log performance to the console
  33890. */
  33891. static readonly PerformanceConsoleLogLevel: number;
  33892. private static _performance;
  33893. /**
  33894. * Sets the current performance log level
  33895. */
  33896. static PerformanceLogLevel: number;
  33897. private static _StartPerformanceCounterDisabled;
  33898. private static _EndPerformanceCounterDisabled;
  33899. private static _StartUserMark;
  33900. private static _EndUserMark;
  33901. private static _StartPerformanceConsole;
  33902. private static _EndPerformanceConsole;
  33903. /**
  33904. * Starts a performance counter
  33905. */
  33906. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33907. /**
  33908. * Ends a specific performance coutner
  33909. */
  33910. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33911. /**
  33912. * Gets either window.performance.now() if supported or Date.now() else
  33913. */
  33914. static readonly Now: number;
  33915. /**
  33916. * This method will return the name of the class used to create the instance of the given object.
  33917. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33918. * @param object the object to get the class name from
  33919. * @param isType defines if the object is actually a type
  33920. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33921. */
  33922. static GetClassName(object: any, isType?: boolean): string;
  33923. /**
  33924. * Gets the first element of an array satisfying a given predicate
  33925. * @param array defines the array to browse
  33926. * @param predicate defines the predicate to use
  33927. * @returns null if not found or the element
  33928. */
  33929. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33930. /**
  33931. * This method will return the name of the full name of the class, including its owning module (if any).
  33932. * 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).
  33933. * @param object the object to get the class name from
  33934. * @param isType defines if the object is actually a type
  33935. * @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.
  33936. * @ignorenaming
  33937. */
  33938. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33939. /**
  33940. * Returns a promise that resolves after the given amount of time.
  33941. * @param delay Number of milliseconds to delay
  33942. * @returns Promise that resolves after the given amount of time
  33943. */
  33944. static DelayAsync(delay: number): Promise<void>;
  33945. }
  33946. /**
  33947. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33948. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33949. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33950. * @param name The name of the class, case should be preserved
  33951. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33952. */
  33953. export function className(name: string, module?: string): (target: Object) => void;
  33954. /**
  33955. * An implementation of a loop for asynchronous functions.
  33956. */
  33957. export class AsyncLoop {
  33958. /**
  33959. * Defines the number of iterations for the loop
  33960. */
  33961. iterations: number;
  33962. /**
  33963. * Defines the current index of the loop.
  33964. */
  33965. index: number;
  33966. private _done;
  33967. private _fn;
  33968. private _successCallback;
  33969. /**
  33970. * Constructor.
  33971. * @param iterations the number of iterations.
  33972. * @param func the function to run each iteration
  33973. * @param successCallback the callback that will be called upon succesful execution
  33974. * @param offset starting offset.
  33975. */
  33976. constructor(
  33977. /**
  33978. * Defines the number of iterations for the loop
  33979. */
  33980. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33981. /**
  33982. * Execute the next iteration. Must be called after the last iteration was finished.
  33983. */
  33984. executeNext(): void;
  33985. /**
  33986. * Break the loop and run the success callback.
  33987. */
  33988. breakLoop(): void;
  33989. /**
  33990. * Create and run an async loop.
  33991. * @param iterations the number of iterations.
  33992. * @param fn the function to run each iteration
  33993. * @param successCallback the callback that will be called upon succesful execution
  33994. * @param offset starting offset.
  33995. * @returns the created async loop object
  33996. */
  33997. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33998. /**
  33999. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34000. * @param iterations total number of iterations
  34001. * @param syncedIterations number of synchronous iterations in each async iteration.
  34002. * @param fn the function to call each iteration.
  34003. * @param callback a success call back that will be called when iterating stops.
  34004. * @param breakFunction a break condition (optional)
  34005. * @param timeout timeout settings for the setTimeout function. default - 0.
  34006. * @returns the created async loop object
  34007. */
  34008. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34009. }
  34010. }
  34011. declare module BABYLON {
  34012. /**
  34013. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34014. * The underlying implementation relies on an associative array to ensure the best performances.
  34015. * The value can be anything including 'null' but except 'undefined'
  34016. */
  34017. export class StringDictionary<T> {
  34018. /**
  34019. * This will clear this dictionary and copy the content from the 'source' one.
  34020. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34021. * @param source the dictionary to take the content from and copy to this dictionary
  34022. */
  34023. copyFrom(source: StringDictionary<T>): void;
  34024. /**
  34025. * Get a value based from its key
  34026. * @param key the given key to get the matching value from
  34027. * @return the value if found, otherwise undefined is returned
  34028. */
  34029. get(key: string): T | undefined;
  34030. /**
  34031. * Get a value from its key or add it if it doesn't exist.
  34032. * This method will ensure you that a given key/data will be present in the dictionary.
  34033. * @param key the given key to get the matching value from
  34034. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34035. * The factory will only be invoked if there's no data for the given key.
  34036. * @return the value corresponding to the key.
  34037. */
  34038. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34039. /**
  34040. * Get a value from its key if present in the dictionary otherwise add it
  34041. * @param key the key to get the value from
  34042. * @param val if there's no such key/value pair in the dictionary add it with this value
  34043. * @return the value corresponding to the key
  34044. */
  34045. getOrAdd(key: string, val: T): T;
  34046. /**
  34047. * Check if there's a given key in the dictionary
  34048. * @param key the key to check for
  34049. * @return true if the key is present, false otherwise
  34050. */
  34051. contains(key: string): boolean;
  34052. /**
  34053. * Add a new key and its corresponding value
  34054. * @param key the key to add
  34055. * @param value the value corresponding to the key
  34056. * @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
  34057. */
  34058. add(key: string, value: T): boolean;
  34059. /**
  34060. * Update a specific value associated to a key
  34061. * @param key defines the key to use
  34062. * @param value defines the value to store
  34063. * @returns true if the value was updated (or false if the key was not found)
  34064. */
  34065. set(key: string, value: T): boolean;
  34066. /**
  34067. * Get the element of the given key and remove it from the dictionary
  34068. * @param key defines the key to search
  34069. * @returns the value associated with the key or null if not found
  34070. */
  34071. getAndRemove(key: string): Nullable<T>;
  34072. /**
  34073. * Remove a key/value from the dictionary.
  34074. * @param key the key to remove
  34075. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34076. */
  34077. remove(key: string): boolean;
  34078. /**
  34079. * Clear the whole content of the dictionary
  34080. */
  34081. clear(): void;
  34082. /**
  34083. * Gets the current count
  34084. */
  34085. readonly count: number;
  34086. /**
  34087. * Execute a callback on each key/val of the dictionary.
  34088. * Note that you can remove any element in this dictionary in the callback implementation
  34089. * @param callback the callback to execute on a given key/value pair
  34090. */
  34091. forEach(callback: (key: string, val: T) => void): void;
  34092. /**
  34093. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34094. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34095. * Note that you can remove any element in this dictionary in the callback implementation
  34096. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34097. * @returns the first item
  34098. */
  34099. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34100. private _count;
  34101. private _data;
  34102. }
  34103. }
  34104. declare module BABYLON {
  34105. /** @hidden */
  34106. export interface ICollisionCoordinator {
  34107. createCollider(): Collider;
  34108. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34109. init(scene: Scene): void;
  34110. }
  34111. /** @hidden */
  34112. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34113. private _scene;
  34114. private _scaledPosition;
  34115. private _scaledVelocity;
  34116. private _finalPosition;
  34117. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34118. createCollider(): Collider;
  34119. init(scene: Scene): void;
  34120. private _collideWithWorld;
  34121. }
  34122. }
  34123. declare module BABYLON {
  34124. /**
  34125. * Class used to manage all inputs for the scene.
  34126. */
  34127. export class InputManager {
  34128. /** The distance in pixel that you have to move to prevent some events */
  34129. static DragMovementThreshold: number;
  34130. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34131. static LongPressDelay: number;
  34132. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34133. static DoubleClickDelay: number;
  34134. /** If you need to check double click without raising a single click at first click, enable this flag */
  34135. static ExclusiveDoubleClickMode: boolean;
  34136. private _wheelEventName;
  34137. private _onPointerMove;
  34138. private _onPointerDown;
  34139. private _onPointerUp;
  34140. private _initClickEvent;
  34141. private _initActionManager;
  34142. private _delayedSimpleClick;
  34143. private _delayedSimpleClickTimeout;
  34144. private _previousDelayedSimpleClickTimeout;
  34145. private _meshPickProceed;
  34146. private _previousButtonPressed;
  34147. private _currentPickResult;
  34148. private _previousPickResult;
  34149. private _totalPointersPressed;
  34150. private _doubleClickOccured;
  34151. private _pointerOverMesh;
  34152. private _pickedDownMesh;
  34153. private _pickedUpMesh;
  34154. private _pointerX;
  34155. private _pointerY;
  34156. private _unTranslatedPointerX;
  34157. private _unTranslatedPointerY;
  34158. private _startingPointerPosition;
  34159. private _previousStartingPointerPosition;
  34160. private _startingPointerTime;
  34161. private _previousStartingPointerTime;
  34162. private _pointerCaptures;
  34163. private _onKeyDown;
  34164. private _onKeyUp;
  34165. private _onCanvasFocusObserver;
  34166. private _onCanvasBlurObserver;
  34167. private _scene;
  34168. /**
  34169. * Creates a new InputManager
  34170. * @param scene defines the hosting scene
  34171. */
  34172. constructor(scene: Scene);
  34173. /**
  34174. * Gets the mesh that is currently under the pointer
  34175. */
  34176. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34177. /**
  34178. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34179. */
  34180. readonly unTranslatedPointer: Vector2;
  34181. /**
  34182. * Gets or sets the current on-screen X position of the pointer
  34183. */
  34184. pointerX: number;
  34185. /**
  34186. * Gets or sets the current on-screen Y position of the pointer
  34187. */
  34188. pointerY: number;
  34189. private _updatePointerPosition;
  34190. private _processPointerMove;
  34191. private _setRayOnPointerInfo;
  34192. private _checkPrePointerObservable;
  34193. /**
  34194. * Use this method to simulate a pointer move on a mesh
  34195. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34196. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34197. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34198. */
  34199. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34200. /**
  34201. * Use this method to simulate a pointer down on a mesh
  34202. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34203. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34204. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34205. */
  34206. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34207. private _processPointerDown;
  34208. /** @hidden */
  34209. _isPointerSwiping(): boolean;
  34210. /**
  34211. * Use this method to simulate a pointer up on a mesh
  34212. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34213. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34214. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34215. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34216. */
  34217. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34218. private _processPointerUp;
  34219. /**
  34220. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34221. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34222. * @returns true if the pointer was captured
  34223. */
  34224. isPointerCaptured(pointerId?: number): boolean;
  34225. /**
  34226. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34227. * @param attachUp defines if you want to attach events to pointerup
  34228. * @param attachDown defines if you want to attach events to pointerdown
  34229. * @param attachMove defines if you want to attach events to pointermove
  34230. */
  34231. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34232. /**
  34233. * Detaches all event handlers
  34234. */
  34235. detachControl(): void;
  34236. /**
  34237. * Force the value of meshUnderPointer
  34238. * @param mesh defines the mesh to use
  34239. */
  34240. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34241. /**
  34242. * Gets the mesh under the pointer
  34243. * @returns a Mesh or null if no mesh is under the pointer
  34244. */
  34245. getPointerOverMesh(): Nullable<AbstractMesh>;
  34246. }
  34247. }
  34248. declare module BABYLON {
  34249. /**
  34250. * Helper class used to generate session unique ID
  34251. */
  34252. export class UniqueIdGenerator {
  34253. private static _UniqueIdCounter;
  34254. /**
  34255. * Gets an unique (relatively to the current scene) Id
  34256. */
  34257. static readonly UniqueId: number;
  34258. }
  34259. }
  34260. declare module BABYLON {
  34261. /**
  34262. * This class defines the direct association between an animation and a target
  34263. */
  34264. export class TargetedAnimation {
  34265. /**
  34266. * Animation to perform
  34267. */
  34268. animation: Animation;
  34269. /**
  34270. * Target to animate
  34271. */
  34272. target: any;
  34273. /**
  34274. * Serialize the object
  34275. * @returns the JSON object representing the current entity
  34276. */
  34277. serialize(): any;
  34278. }
  34279. /**
  34280. * Use this class to create coordinated animations on multiple targets
  34281. */
  34282. export class AnimationGroup implements IDisposable {
  34283. /** The name of the animation group */
  34284. name: string;
  34285. private _scene;
  34286. private _targetedAnimations;
  34287. private _animatables;
  34288. private _from;
  34289. private _to;
  34290. private _isStarted;
  34291. private _isPaused;
  34292. private _speedRatio;
  34293. private _loopAnimation;
  34294. /**
  34295. * Gets or sets the unique id of the node
  34296. */
  34297. uniqueId: number;
  34298. /**
  34299. * This observable will notify when one animation have ended
  34300. */
  34301. onAnimationEndObservable: Observable<TargetedAnimation>;
  34302. /**
  34303. * Observer raised when one animation loops
  34304. */
  34305. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34306. /**
  34307. * Observer raised when all animations have looped
  34308. */
  34309. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34310. /**
  34311. * This observable will notify when all animations have ended.
  34312. */
  34313. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34314. /**
  34315. * This observable will notify when all animations have paused.
  34316. */
  34317. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34318. /**
  34319. * This observable will notify when all animations are playing.
  34320. */
  34321. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34322. /**
  34323. * Gets the first frame
  34324. */
  34325. readonly from: number;
  34326. /**
  34327. * Gets the last frame
  34328. */
  34329. readonly to: number;
  34330. /**
  34331. * Define if the animations are started
  34332. */
  34333. readonly isStarted: boolean;
  34334. /**
  34335. * Gets a value indicating that the current group is playing
  34336. */
  34337. readonly isPlaying: boolean;
  34338. /**
  34339. * Gets or sets the speed ratio to use for all animations
  34340. */
  34341. /**
  34342. * Gets or sets the speed ratio to use for all animations
  34343. */
  34344. speedRatio: number;
  34345. /**
  34346. * Gets or sets if all animations should loop or not
  34347. */
  34348. loopAnimation: boolean;
  34349. /**
  34350. * Gets the targeted animations for this animation group
  34351. */
  34352. readonly targetedAnimations: Array<TargetedAnimation>;
  34353. /**
  34354. * returning the list of animatables controlled by this animation group.
  34355. */
  34356. readonly animatables: Array<Animatable>;
  34357. /**
  34358. * Instantiates a new Animation Group.
  34359. * This helps managing several animations at once.
  34360. * @see http://doc.babylonjs.com/how_to/group
  34361. * @param name Defines the name of the group
  34362. * @param scene Defines the scene the group belongs to
  34363. */
  34364. constructor(
  34365. /** The name of the animation group */
  34366. name: string, scene?: Nullable<Scene>);
  34367. /**
  34368. * Add an animation (with its target) in the group
  34369. * @param animation defines the animation we want to add
  34370. * @param target defines the target of the animation
  34371. * @returns the TargetedAnimation object
  34372. */
  34373. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34374. /**
  34375. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34376. * It can add constant keys at begin or end
  34377. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34378. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34379. * @returns the animation group
  34380. */
  34381. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34382. private _animationLoopCount;
  34383. private _animationLoopFlags;
  34384. private _processLoop;
  34385. /**
  34386. * Start all animations on given targets
  34387. * @param loop defines if animations must loop
  34388. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34389. * @param from defines the from key (optional)
  34390. * @param to defines the to key (optional)
  34391. * @returns the current animation group
  34392. */
  34393. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34394. /**
  34395. * Pause all animations
  34396. * @returns the animation group
  34397. */
  34398. pause(): AnimationGroup;
  34399. /**
  34400. * Play all animations to initial state
  34401. * This function will start() the animations if they were not started or will restart() them if they were paused
  34402. * @param loop defines if animations must loop
  34403. * @returns the animation group
  34404. */
  34405. play(loop?: boolean): AnimationGroup;
  34406. /**
  34407. * Reset all animations to initial state
  34408. * @returns the animation group
  34409. */
  34410. reset(): AnimationGroup;
  34411. /**
  34412. * Restart animations from key 0
  34413. * @returns the animation group
  34414. */
  34415. restart(): AnimationGroup;
  34416. /**
  34417. * Stop all animations
  34418. * @returns the animation group
  34419. */
  34420. stop(): AnimationGroup;
  34421. /**
  34422. * Set animation weight for all animatables
  34423. * @param weight defines the weight to use
  34424. * @return the animationGroup
  34425. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34426. */
  34427. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34428. /**
  34429. * Synchronize and normalize all animatables with a source animatable
  34430. * @param root defines the root animatable to synchronize with
  34431. * @return the animationGroup
  34432. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34433. */
  34434. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34435. /**
  34436. * Goes to a specific frame in this animation group
  34437. * @param frame the frame number to go to
  34438. * @return the animationGroup
  34439. */
  34440. goToFrame(frame: number): AnimationGroup;
  34441. /**
  34442. * Dispose all associated resources
  34443. */
  34444. dispose(): void;
  34445. private _checkAnimationGroupEnded;
  34446. /**
  34447. * Clone the current animation group and returns a copy
  34448. * @param newName defines the name of the new group
  34449. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34450. * @returns the new aniamtion group
  34451. */
  34452. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34453. /**
  34454. * Serializes the animationGroup to an object
  34455. * @returns Serialized object
  34456. */
  34457. serialize(): any;
  34458. /**
  34459. * Returns a new AnimationGroup object parsed from the source provided.
  34460. * @param parsedAnimationGroup defines the source
  34461. * @param scene defines the scene that will receive the animationGroup
  34462. * @returns a new AnimationGroup
  34463. */
  34464. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34465. /**
  34466. * Returns the string "AnimationGroup"
  34467. * @returns "AnimationGroup"
  34468. */
  34469. getClassName(): string;
  34470. /**
  34471. * Creates a detailled string about the object
  34472. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34473. * @returns a string representing the object
  34474. */
  34475. toString(fullDetails?: boolean): string;
  34476. }
  34477. }
  34478. declare module BABYLON {
  34479. /**
  34480. * Define an interface for all classes that will hold resources
  34481. */
  34482. export interface IDisposable {
  34483. /**
  34484. * Releases all held resources
  34485. */
  34486. dispose(): void;
  34487. }
  34488. /** Interface defining initialization parameters for Scene class */
  34489. export interface SceneOptions {
  34490. /**
  34491. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34492. * It will improve performance when the number of geometries becomes important.
  34493. */
  34494. useGeometryUniqueIdsMap?: boolean;
  34495. /**
  34496. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34497. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34498. */
  34499. useMaterialMeshMap?: boolean;
  34500. /**
  34501. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34502. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34503. */
  34504. useClonedMeshhMap?: boolean;
  34505. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34506. virtual?: boolean;
  34507. }
  34508. /**
  34509. * Represents a scene to be rendered by the engine.
  34510. * @see http://doc.babylonjs.com/features/scene
  34511. */
  34512. export class Scene extends AbstractScene implements IAnimatable {
  34513. /** The fog is deactivated */
  34514. static readonly FOGMODE_NONE: number;
  34515. /** The fog density is following an exponential function */
  34516. static readonly FOGMODE_EXP: number;
  34517. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34518. static readonly FOGMODE_EXP2: number;
  34519. /** The fog density is following a linear function. */
  34520. static readonly FOGMODE_LINEAR: number;
  34521. /**
  34522. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34523. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34524. */
  34525. static MinDeltaTime: number;
  34526. /**
  34527. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34528. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34529. */
  34530. static MaxDeltaTime: number;
  34531. /**
  34532. * Factory used to create the default material.
  34533. * @param name The name of the material to create
  34534. * @param scene The scene to create the material for
  34535. * @returns The default material
  34536. */
  34537. static DefaultMaterialFactory(scene: Scene): Material;
  34538. /**
  34539. * Factory used to create the a collision coordinator.
  34540. * @returns The collision coordinator
  34541. */
  34542. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34543. /** @hidden */
  34544. _inputManager: InputManager;
  34545. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34546. cameraToUseForPointers: Nullable<Camera>;
  34547. /** @hidden */
  34548. readonly _isScene: boolean;
  34549. /**
  34550. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34551. */
  34552. autoClear: boolean;
  34553. /**
  34554. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34555. */
  34556. autoClearDepthAndStencil: boolean;
  34557. /**
  34558. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34559. */
  34560. clearColor: Color4;
  34561. /**
  34562. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34563. */
  34564. ambientColor: Color3;
  34565. /**
  34566. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34567. * It should only be one of the following (if not the default embedded one):
  34568. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34569. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34570. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34571. * The material properties need to be setup according to the type of texture in use.
  34572. */
  34573. environmentBRDFTexture: BaseTexture;
  34574. /** @hidden */
  34575. protected _environmentTexture: Nullable<BaseTexture>;
  34576. /**
  34577. * Texture used in all pbr material as the reflection texture.
  34578. * As in the majority of the scene they are the same (exception for multi room and so on),
  34579. * this is easier to reference from here than from all the materials.
  34580. */
  34581. /**
  34582. * Texture used in all pbr material as the reflection texture.
  34583. * As in the majority of the scene they are the same (exception for multi room and so on),
  34584. * this is easier to set here than in all the materials.
  34585. */
  34586. environmentTexture: Nullable<BaseTexture>;
  34587. /** @hidden */
  34588. protected _environmentIntensity: number;
  34589. /**
  34590. * Intensity of the environment in all pbr material.
  34591. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34592. * As in the majority of the scene they are the same (exception for multi room and so on),
  34593. * this is easier to reference from here than from all the materials.
  34594. */
  34595. /**
  34596. * Intensity of the environment in all pbr material.
  34597. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34598. * As in the majority of the scene they are the same (exception for multi room and so on),
  34599. * this is easier to set here than in all the materials.
  34600. */
  34601. environmentIntensity: number;
  34602. /** @hidden */
  34603. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34604. /**
  34605. * Default image processing configuration used either in the rendering
  34606. * Forward main pass or through the imageProcessingPostProcess if present.
  34607. * As in the majority of the scene they are the same (exception for multi camera),
  34608. * this is easier to reference from here than from all the materials and post process.
  34609. *
  34610. * No setter as we it is a shared configuration, you can set the values instead.
  34611. */
  34612. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34613. private _forceWireframe;
  34614. /**
  34615. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34616. */
  34617. forceWireframe: boolean;
  34618. private _forcePointsCloud;
  34619. /**
  34620. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34621. */
  34622. forcePointsCloud: boolean;
  34623. /**
  34624. * Gets or sets the active clipplane 1
  34625. */
  34626. clipPlane: Nullable<Plane>;
  34627. /**
  34628. * Gets or sets the active clipplane 2
  34629. */
  34630. clipPlane2: Nullable<Plane>;
  34631. /**
  34632. * Gets or sets the active clipplane 3
  34633. */
  34634. clipPlane3: Nullable<Plane>;
  34635. /**
  34636. * Gets or sets the active clipplane 4
  34637. */
  34638. clipPlane4: Nullable<Plane>;
  34639. /**
  34640. * Gets or sets a boolean indicating if animations are enabled
  34641. */
  34642. animationsEnabled: boolean;
  34643. private _animationPropertiesOverride;
  34644. /**
  34645. * Gets or sets the animation properties override
  34646. */
  34647. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34648. /**
  34649. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34650. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34651. */
  34652. useConstantAnimationDeltaTime: boolean;
  34653. /**
  34654. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34655. * Please note that it requires to run a ray cast through the scene on every frame
  34656. */
  34657. constantlyUpdateMeshUnderPointer: boolean;
  34658. /**
  34659. * Defines the HTML cursor to use when hovering over interactive elements
  34660. */
  34661. hoverCursor: string;
  34662. /**
  34663. * Defines the HTML default cursor to use (empty by default)
  34664. */
  34665. defaultCursor: string;
  34666. /**
  34667. * Defines wether cursors are handled by the scene.
  34668. */
  34669. doNotHandleCursors: boolean;
  34670. /**
  34671. * This is used to call preventDefault() on pointer down
  34672. * in order to block unwanted artifacts like system double clicks
  34673. */
  34674. preventDefaultOnPointerDown: boolean;
  34675. /**
  34676. * This is used to call preventDefault() on pointer up
  34677. * in order to block unwanted artifacts like system double clicks
  34678. */
  34679. preventDefaultOnPointerUp: boolean;
  34680. /**
  34681. * Gets or sets user defined metadata
  34682. */
  34683. metadata: any;
  34684. /**
  34685. * For internal use only. Please do not use.
  34686. */
  34687. reservedDataStore: any;
  34688. /**
  34689. * Gets the name of the plugin used to load this scene (null by default)
  34690. */
  34691. loadingPluginName: string;
  34692. /**
  34693. * Use this array to add regular expressions used to disable offline support for specific urls
  34694. */
  34695. disableOfflineSupportExceptionRules: RegExp[];
  34696. /**
  34697. * An event triggered when the scene is disposed.
  34698. */
  34699. onDisposeObservable: Observable<Scene>;
  34700. private _onDisposeObserver;
  34701. /** Sets a function to be executed when this scene is disposed. */
  34702. onDispose: () => void;
  34703. /**
  34704. * An event triggered before rendering the scene (right after animations and physics)
  34705. */
  34706. onBeforeRenderObservable: Observable<Scene>;
  34707. private _onBeforeRenderObserver;
  34708. /** Sets a function to be executed before rendering this scene */
  34709. beforeRender: Nullable<() => void>;
  34710. /**
  34711. * An event triggered after rendering the scene
  34712. */
  34713. onAfterRenderObservable: Observable<Scene>;
  34714. /**
  34715. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34716. */
  34717. onAfterRenderCameraObservable: Observable<Camera>;
  34718. private _onAfterRenderObserver;
  34719. /** Sets a function to be executed after rendering this scene */
  34720. afterRender: Nullable<() => void>;
  34721. /**
  34722. * An event triggered before animating the scene
  34723. */
  34724. onBeforeAnimationsObservable: Observable<Scene>;
  34725. /**
  34726. * An event triggered after animations processing
  34727. */
  34728. onAfterAnimationsObservable: Observable<Scene>;
  34729. /**
  34730. * An event triggered before draw calls are ready to be sent
  34731. */
  34732. onBeforeDrawPhaseObservable: Observable<Scene>;
  34733. /**
  34734. * An event triggered after draw calls have been sent
  34735. */
  34736. onAfterDrawPhaseObservable: Observable<Scene>;
  34737. /**
  34738. * An event triggered when the scene is ready
  34739. */
  34740. onReadyObservable: Observable<Scene>;
  34741. /**
  34742. * An event triggered before rendering a camera
  34743. */
  34744. onBeforeCameraRenderObservable: Observable<Camera>;
  34745. private _onBeforeCameraRenderObserver;
  34746. /** Sets a function to be executed before rendering a camera*/
  34747. beforeCameraRender: () => void;
  34748. /**
  34749. * An event triggered after rendering a camera
  34750. */
  34751. onAfterCameraRenderObservable: Observable<Camera>;
  34752. private _onAfterCameraRenderObserver;
  34753. /** Sets a function to be executed after rendering a camera*/
  34754. afterCameraRender: () => void;
  34755. /**
  34756. * An event triggered when active meshes evaluation is about to start
  34757. */
  34758. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34759. /**
  34760. * An event triggered when active meshes evaluation is done
  34761. */
  34762. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34763. /**
  34764. * An event triggered when particles rendering is about to start
  34765. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34766. */
  34767. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34768. /**
  34769. * An event triggered when particles rendering is done
  34770. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34771. */
  34772. onAfterParticlesRenderingObservable: Observable<Scene>;
  34773. /**
  34774. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34775. */
  34776. onDataLoadedObservable: Observable<Scene>;
  34777. /**
  34778. * An event triggered when a camera is created
  34779. */
  34780. onNewCameraAddedObservable: Observable<Camera>;
  34781. /**
  34782. * An event triggered when a camera is removed
  34783. */
  34784. onCameraRemovedObservable: Observable<Camera>;
  34785. /**
  34786. * An event triggered when a light is created
  34787. */
  34788. onNewLightAddedObservable: Observable<Light>;
  34789. /**
  34790. * An event triggered when a light is removed
  34791. */
  34792. onLightRemovedObservable: Observable<Light>;
  34793. /**
  34794. * An event triggered when a geometry is created
  34795. */
  34796. onNewGeometryAddedObservable: Observable<Geometry>;
  34797. /**
  34798. * An event triggered when a geometry is removed
  34799. */
  34800. onGeometryRemovedObservable: Observable<Geometry>;
  34801. /**
  34802. * An event triggered when a transform node is created
  34803. */
  34804. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34805. /**
  34806. * An event triggered when a transform node is removed
  34807. */
  34808. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34809. /**
  34810. * An event triggered when a mesh is created
  34811. */
  34812. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34813. /**
  34814. * An event triggered when a mesh is removed
  34815. */
  34816. onMeshRemovedObservable: Observable<AbstractMesh>;
  34817. /**
  34818. * An event triggered when a skeleton is created
  34819. */
  34820. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34821. /**
  34822. * An event triggered when a skeleton is removed
  34823. */
  34824. onSkeletonRemovedObservable: Observable<Skeleton>;
  34825. /**
  34826. * An event triggered when a material is created
  34827. */
  34828. onNewMaterialAddedObservable: Observable<Material>;
  34829. /**
  34830. * An event triggered when a material is removed
  34831. */
  34832. onMaterialRemovedObservable: Observable<Material>;
  34833. /**
  34834. * An event triggered when a texture is created
  34835. */
  34836. onNewTextureAddedObservable: Observable<BaseTexture>;
  34837. /**
  34838. * An event triggered when a texture is removed
  34839. */
  34840. onTextureRemovedObservable: Observable<BaseTexture>;
  34841. /**
  34842. * An event triggered when render targets are about to be rendered
  34843. * Can happen multiple times per frame.
  34844. */
  34845. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34846. /**
  34847. * An event triggered when render targets were rendered.
  34848. * Can happen multiple times per frame.
  34849. */
  34850. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34851. /**
  34852. * An event triggered before calculating deterministic simulation step
  34853. */
  34854. onBeforeStepObservable: Observable<Scene>;
  34855. /**
  34856. * An event triggered after calculating deterministic simulation step
  34857. */
  34858. onAfterStepObservable: Observable<Scene>;
  34859. /**
  34860. * An event triggered when the activeCamera property is updated
  34861. */
  34862. onActiveCameraChanged: Observable<Scene>;
  34863. /**
  34864. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34865. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34866. * 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)
  34867. */
  34868. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34869. /**
  34870. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34871. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34872. * 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)
  34873. */
  34874. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34875. /**
  34876. * This Observable will when a mesh has been imported into the scene.
  34877. */
  34878. onMeshImportedObservable: Observable<AbstractMesh>;
  34879. /**
  34880. * This Observable will when an animation file has been imported into the scene.
  34881. */
  34882. onAnimationFileImportedObservable: Observable<Scene>;
  34883. /**
  34884. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34885. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34886. */
  34887. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34888. /** @hidden */
  34889. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34890. /**
  34891. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34892. */
  34893. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34894. /**
  34895. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34896. */
  34897. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34898. /**
  34899. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34900. */
  34901. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34902. /** Callback called when a pointer move is detected */
  34903. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34904. /** Callback called when a pointer down is detected */
  34905. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34906. /** Callback called when a pointer up is detected */
  34907. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34908. /** Callback called when a pointer pick is detected */
  34909. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34910. /**
  34911. * 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).
  34912. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34913. */
  34914. onPrePointerObservable: Observable<PointerInfoPre>;
  34915. /**
  34916. * Observable event triggered each time an input event is received from the rendering canvas
  34917. */
  34918. onPointerObservable: Observable<PointerInfo>;
  34919. /**
  34920. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34921. */
  34922. readonly unTranslatedPointer: Vector2;
  34923. /**
  34924. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34925. */
  34926. static DragMovementThreshold: number;
  34927. /**
  34928. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34929. */
  34930. static LongPressDelay: number;
  34931. /**
  34932. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34933. */
  34934. static DoubleClickDelay: number;
  34935. /** If you need to check double click without raising a single click at first click, enable this flag */
  34936. static ExclusiveDoubleClickMode: boolean;
  34937. /** @hidden */
  34938. _mirroredCameraPosition: Nullable<Vector3>;
  34939. /**
  34940. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34941. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34942. */
  34943. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34944. /**
  34945. * Observable event triggered each time an keyboard event is received from the hosting window
  34946. */
  34947. onKeyboardObservable: Observable<KeyboardInfo>;
  34948. private _useRightHandedSystem;
  34949. /**
  34950. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34951. */
  34952. useRightHandedSystem: boolean;
  34953. private _timeAccumulator;
  34954. private _currentStepId;
  34955. private _currentInternalStep;
  34956. /**
  34957. * Sets the step Id used by deterministic lock step
  34958. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34959. * @param newStepId defines the step Id
  34960. */
  34961. setStepId(newStepId: number): void;
  34962. /**
  34963. * Gets the step Id used by deterministic lock step
  34964. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34965. * @returns the step Id
  34966. */
  34967. getStepId(): number;
  34968. /**
  34969. * Gets the internal step used by deterministic lock step
  34970. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34971. * @returns the internal step
  34972. */
  34973. getInternalStep(): number;
  34974. private _fogEnabled;
  34975. /**
  34976. * Gets or sets a boolean indicating if fog is enabled on this scene
  34977. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34978. * (Default is true)
  34979. */
  34980. fogEnabled: boolean;
  34981. private _fogMode;
  34982. /**
  34983. * Gets or sets the fog mode to use
  34984. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34985. * | mode | value |
  34986. * | --- | --- |
  34987. * | FOGMODE_NONE | 0 |
  34988. * | FOGMODE_EXP | 1 |
  34989. * | FOGMODE_EXP2 | 2 |
  34990. * | FOGMODE_LINEAR | 3 |
  34991. */
  34992. fogMode: number;
  34993. /**
  34994. * Gets or sets the fog color to use
  34995. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34996. * (Default is Color3(0.2, 0.2, 0.3))
  34997. */
  34998. fogColor: Color3;
  34999. /**
  35000. * Gets or sets the fog density to use
  35001. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35002. * (Default is 0.1)
  35003. */
  35004. fogDensity: number;
  35005. /**
  35006. * Gets or sets the fog start distance to use
  35007. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35008. * (Default is 0)
  35009. */
  35010. fogStart: number;
  35011. /**
  35012. * Gets or sets the fog end distance to use
  35013. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35014. * (Default is 1000)
  35015. */
  35016. fogEnd: number;
  35017. private _shadowsEnabled;
  35018. /**
  35019. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35020. */
  35021. shadowsEnabled: boolean;
  35022. private _lightsEnabled;
  35023. /**
  35024. * Gets or sets a boolean indicating if lights are enabled on this scene
  35025. */
  35026. lightsEnabled: boolean;
  35027. /** All of the active cameras added to this scene. */
  35028. activeCameras: Camera[];
  35029. /** @hidden */
  35030. _activeCamera: Nullable<Camera>;
  35031. /** Gets or sets the current active camera */
  35032. activeCamera: Nullable<Camera>;
  35033. private _defaultMaterial;
  35034. /** The default material used on meshes when no material is affected */
  35035. /** The default material used on meshes when no material is affected */
  35036. defaultMaterial: Material;
  35037. private _texturesEnabled;
  35038. /**
  35039. * Gets or sets a boolean indicating if textures are enabled on this scene
  35040. */
  35041. texturesEnabled: boolean;
  35042. /**
  35043. * Gets or sets a boolean indicating if particles are enabled on this scene
  35044. */
  35045. particlesEnabled: boolean;
  35046. /**
  35047. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35048. */
  35049. spritesEnabled: boolean;
  35050. private _skeletonsEnabled;
  35051. /**
  35052. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35053. */
  35054. skeletonsEnabled: boolean;
  35055. /**
  35056. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35057. */
  35058. lensFlaresEnabled: boolean;
  35059. /**
  35060. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35061. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35062. */
  35063. collisionsEnabled: boolean;
  35064. private _collisionCoordinator;
  35065. /** @hidden */
  35066. readonly collisionCoordinator: ICollisionCoordinator;
  35067. /**
  35068. * Defines the gravity applied to this scene (used only for collisions)
  35069. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35070. */
  35071. gravity: Vector3;
  35072. /**
  35073. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35074. */
  35075. postProcessesEnabled: boolean;
  35076. /**
  35077. * The list of postprocesses added to the scene
  35078. */
  35079. postProcesses: PostProcess[];
  35080. /**
  35081. * Gets the current postprocess manager
  35082. */
  35083. postProcessManager: PostProcessManager;
  35084. /**
  35085. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35086. */
  35087. renderTargetsEnabled: boolean;
  35088. /**
  35089. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35090. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35091. */
  35092. dumpNextRenderTargets: boolean;
  35093. /**
  35094. * The list of user defined render targets added to the scene
  35095. */
  35096. customRenderTargets: RenderTargetTexture[];
  35097. /**
  35098. * Defines if texture loading must be delayed
  35099. * If true, textures will only be loaded when they need to be rendered
  35100. */
  35101. useDelayedTextureLoading: boolean;
  35102. /**
  35103. * Gets the list of meshes imported to the scene through SceneLoader
  35104. */
  35105. importedMeshesFiles: String[];
  35106. /**
  35107. * Gets or sets a boolean indicating if probes are enabled on this scene
  35108. */
  35109. probesEnabled: boolean;
  35110. /**
  35111. * Gets or sets the current offline provider to use to store scene data
  35112. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35113. */
  35114. offlineProvider: IOfflineProvider;
  35115. /**
  35116. * Gets or sets the action manager associated with the scene
  35117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35118. */
  35119. actionManager: AbstractActionManager;
  35120. private _meshesForIntersections;
  35121. /**
  35122. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35123. */
  35124. proceduralTexturesEnabled: boolean;
  35125. private _engine;
  35126. private _totalVertices;
  35127. /** @hidden */
  35128. _activeIndices: PerfCounter;
  35129. /** @hidden */
  35130. _activeParticles: PerfCounter;
  35131. /** @hidden */
  35132. _activeBones: PerfCounter;
  35133. private _animationRatio;
  35134. /** @hidden */
  35135. _animationTimeLast: number;
  35136. /** @hidden */
  35137. _animationTime: number;
  35138. /**
  35139. * Gets or sets a general scale for animation speed
  35140. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35141. */
  35142. animationTimeScale: number;
  35143. /** @hidden */
  35144. _cachedMaterial: Nullable<Material>;
  35145. /** @hidden */
  35146. _cachedEffect: Nullable<Effect>;
  35147. /** @hidden */
  35148. _cachedVisibility: Nullable<number>;
  35149. private _renderId;
  35150. private _frameId;
  35151. private _executeWhenReadyTimeoutId;
  35152. private _intermediateRendering;
  35153. private _viewUpdateFlag;
  35154. private _projectionUpdateFlag;
  35155. /** @hidden */
  35156. _toBeDisposed: Nullable<IDisposable>[];
  35157. private _activeRequests;
  35158. /** @hidden */
  35159. _pendingData: any[];
  35160. private _isDisposed;
  35161. /**
  35162. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35163. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35164. */
  35165. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35166. private _activeMeshes;
  35167. private _processedMaterials;
  35168. private _renderTargets;
  35169. /** @hidden */
  35170. _activeParticleSystems: SmartArray<IParticleSystem>;
  35171. private _activeSkeletons;
  35172. private _softwareSkinnedMeshes;
  35173. private _renderingManager;
  35174. /** @hidden */
  35175. _activeAnimatables: Animatable[];
  35176. private _transformMatrix;
  35177. private _sceneUbo;
  35178. /** @hidden */
  35179. _viewMatrix: Matrix;
  35180. private _projectionMatrix;
  35181. /** @hidden */
  35182. _forcedViewPosition: Nullable<Vector3>;
  35183. /** @hidden */
  35184. _frustumPlanes: Plane[];
  35185. /**
  35186. * Gets the list of frustum planes (built from the active camera)
  35187. */
  35188. readonly frustumPlanes: Plane[];
  35189. /**
  35190. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35191. * This is useful if there are more lights that the maximum simulteanous authorized
  35192. */
  35193. requireLightSorting: boolean;
  35194. /** @hidden */
  35195. readonly useMaterialMeshMap: boolean;
  35196. /** @hidden */
  35197. readonly useClonedMeshhMap: boolean;
  35198. private _externalData;
  35199. private _uid;
  35200. /**
  35201. * @hidden
  35202. * Backing store of defined scene components.
  35203. */
  35204. _components: ISceneComponent[];
  35205. /**
  35206. * @hidden
  35207. * Backing store of defined scene components.
  35208. */
  35209. _serializableComponents: ISceneSerializableComponent[];
  35210. /**
  35211. * List of components to register on the next registration step.
  35212. */
  35213. private _transientComponents;
  35214. /**
  35215. * Registers the transient components if needed.
  35216. */
  35217. private _registerTransientComponents;
  35218. /**
  35219. * @hidden
  35220. * Add a component to the scene.
  35221. * Note that the ccomponent could be registered on th next frame if this is called after
  35222. * the register component stage.
  35223. * @param component Defines the component to add to the scene
  35224. */
  35225. _addComponent(component: ISceneComponent): void;
  35226. /**
  35227. * @hidden
  35228. * Gets a component from the scene.
  35229. * @param name defines the name of the component to retrieve
  35230. * @returns the component or null if not present
  35231. */
  35232. _getComponent(name: string): Nullable<ISceneComponent>;
  35233. /**
  35234. * @hidden
  35235. * Defines the actions happening before camera updates.
  35236. */
  35237. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35238. /**
  35239. * @hidden
  35240. * Defines the actions happening before clear the canvas.
  35241. */
  35242. _beforeClearStage: Stage<SimpleStageAction>;
  35243. /**
  35244. * @hidden
  35245. * Defines the actions when collecting render targets for the frame.
  35246. */
  35247. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35248. /**
  35249. * @hidden
  35250. * Defines the actions happening for one camera in the frame.
  35251. */
  35252. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35253. /**
  35254. * @hidden
  35255. * Defines the actions happening during the per mesh ready checks.
  35256. */
  35257. _isReadyForMeshStage: Stage<MeshStageAction>;
  35258. /**
  35259. * @hidden
  35260. * Defines the actions happening before evaluate active mesh checks.
  35261. */
  35262. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35263. /**
  35264. * @hidden
  35265. * Defines the actions happening during the evaluate sub mesh checks.
  35266. */
  35267. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35268. /**
  35269. * @hidden
  35270. * Defines the actions happening during the active mesh stage.
  35271. */
  35272. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35273. /**
  35274. * @hidden
  35275. * Defines the actions happening during the per camera render target step.
  35276. */
  35277. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35278. /**
  35279. * @hidden
  35280. * Defines the actions happening just before the active camera is drawing.
  35281. */
  35282. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35283. /**
  35284. * @hidden
  35285. * Defines the actions happening just before a render target is drawing.
  35286. */
  35287. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35288. /**
  35289. * @hidden
  35290. * Defines the actions happening just before a rendering group is drawing.
  35291. */
  35292. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35293. /**
  35294. * @hidden
  35295. * Defines the actions happening just before a mesh is drawing.
  35296. */
  35297. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35298. /**
  35299. * @hidden
  35300. * Defines the actions happening just after a mesh has been drawn.
  35301. */
  35302. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35303. /**
  35304. * @hidden
  35305. * Defines the actions happening just after a rendering group has been drawn.
  35306. */
  35307. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35308. /**
  35309. * @hidden
  35310. * Defines the actions happening just after the active camera has been drawn.
  35311. */
  35312. _afterCameraDrawStage: Stage<CameraStageAction>;
  35313. /**
  35314. * @hidden
  35315. * Defines the actions happening just after a render target has been drawn.
  35316. */
  35317. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35318. /**
  35319. * @hidden
  35320. * Defines the actions happening just after rendering all cameras and computing intersections.
  35321. */
  35322. _afterRenderStage: Stage<SimpleStageAction>;
  35323. /**
  35324. * @hidden
  35325. * Defines the actions happening when a pointer move event happens.
  35326. */
  35327. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35328. /**
  35329. * @hidden
  35330. * Defines the actions happening when a pointer down event happens.
  35331. */
  35332. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35333. /**
  35334. * @hidden
  35335. * Defines the actions happening when a pointer up event happens.
  35336. */
  35337. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35338. /**
  35339. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35340. */
  35341. private geometriesByUniqueId;
  35342. /**
  35343. * Creates a new Scene
  35344. * @param engine defines the engine to use to render this scene
  35345. * @param options defines the scene options
  35346. */
  35347. constructor(engine: Engine, options?: SceneOptions);
  35348. /**
  35349. * Gets a string idenfifying the name of the class
  35350. * @returns "Scene" string
  35351. */
  35352. getClassName(): string;
  35353. private _defaultMeshCandidates;
  35354. /**
  35355. * @hidden
  35356. */
  35357. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35358. private _defaultSubMeshCandidates;
  35359. /**
  35360. * @hidden
  35361. */
  35362. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35363. /**
  35364. * Sets the default candidate providers for the scene.
  35365. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35366. * and getCollidingSubMeshCandidates to their default function
  35367. */
  35368. setDefaultCandidateProviders(): void;
  35369. /**
  35370. * Gets the mesh that is currently under the pointer
  35371. */
  35372. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35373. /**
  35374. * Gets or sets the current on-screen X position of the pointer
  35375. */
  35376. pointerX: number;
  35377. /**
  35378. * Gets or sets the current on-screen Y position of the pointer
  35379. */
  35380. pointerY: number;
  35381. /**
  35382. * Gets the cached material (ie. the latest rendered one)
  35383. * @returns the cached material
  35384. */
  35385. getCachedMaterial(): Nullable<Material>;
  35386. /**
  35387. * Gets the cached effect (ie. the latest rendered one)
  35388. * @returns the cached effect
  35389. */
  35390. getCachedEffect(): Nullable<Effect>;
  35391. /**
  35392. * Gets the cached visibility state (ie. the latest rendered one)
  35393. * @returns the cached visibility state
  35394. */
  35395. getCachedVisibility(): Nullable<number>;
  35396. /**
  35397. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35398. * @param material defines the current material
  35399. * @param effect defines the current effect
  35400. * @param visibility defines the current visibility state
  35401. * @returns true if one parameter is not cached
  35402. */
  35403. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35404. /**
  35405. * Gets the engine associated with the scene
  35406. * @returns an Engine
  35407. */
  35408. getEngine(): Engine;
  35409. /**
  35410. * Gets the total number of vertices rendered per frame
  35411. * @returns the total number of vertices rendered per frame
  35412. */
  35413. getTotalVertices(): number;
  35414. /**
  35415. * Gets the performance counter for total vertices
  35416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35417. */
  35418. readonly totalVerticesPerfCounter: PerfCounter;
  35419. /**
  35420. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35421. * @returns the total number of active indices rendered per frame
  35422. */
  35423. getActiveIndices(): number;
  35424. /**
  35425. * Gets the performance counter for active indices
  35426. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35427. */
  35428. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35429. /**
  35430. * Gets the total number of active particles rendered per frame
  35431. * @returns the total number of active particles rendered per frame
  35432. */
  35433. getActiveParticles(): number;
  35434. /**
  35435. * Gets the performance counter for active particles
  35436. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35437. */
  35438. readonly activeParticlesPerfCounter: PerfCounter;
  35439. /**
  35440. * Gets the total number of active bones rendered per frame
  35441. * @returns the total number of active bones rendered per frame
  35442. */
  35443. getActiveBones(): number;
  35444. /**
  35445. * Gets the performance counter for active bones
  35446. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35447. */
  35448. readonly activeBonesPerfCounter: PerfCounter;
  35449. /**
  35450. * Gets the array of active meshes
  35451. * @returns an array of AbstractMesh
  35452. */
  35453. getActiveMeshes(): SmartArray<AbstractMesh>;
  35454. /**
  35455. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35456. * @returns a number
  35457. */
  35458. getAnimationRatio(): number;
  35459. /**
  35460. * Gets an unique Id for the current render phase
  35461. * @returns a number
  35462. */
  35463. getRenderId(): number;
  35464. /**
  35465. * Gets an unique Id for the current frame
  35466. * @returns a number
  35467. */
  35468. getFrameId(): number;
  35469. /** Call this function if you want to manually increment the render Id*/
  35470. incrementRenderId(): void;
  35471. private _createUbo;
  35472. /**
  35473. * Use this method to simulate a pointer move on a mesh
  35474. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35475. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35476. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35477. * @returns the current scene
  35478. */
  35479. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35480. /**
  35481. * Use this method to simulate a pointer down on a mesh
  35482. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35483. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35484. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35485. * @returns the current scene
  35486. */
  35487. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35488. /**
  35489. * Use this method to simulate a pointer up on a mesh
  35490. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35491. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35492. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35493. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35494. * @returns the current scene
  35495. */
  35496. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35497. /**
  35498. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35499. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35500. * @returns true if the pointer was captured
  35501. */
  35502. isPointerCaptured(pointerId?: number): boolean;
  35503. /**
  35504. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35505. * @param attachUp defines if you want to attach events to pointerup
  35506. * @param attachDown defines if you want to attach events to pointerdown
  35507. * @param attachMove defines if you want to attach events to pointermove
  35508. */
  35509. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35510. /** Detaches all event handlers*/
  35511. detachControl(): void;
  35512. /**
  35513. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35514. * Delay loaded resources are not taking in account
  35515. * @return true if all required resources are ready
  35516. */
  35517. isReady(): boolean;
  35518. /** Resets all cached information relative to material (including effect and visibility) */
  35519. resetCachedMaterial(): void;
  35520. /**
  35521. * Registers a function to be called before every frame render
  35522. * @param func defines the function to register
  35523. */
  35524. registerBeforeRender(func: () => void): void;
  35525. /**
  35526. * Unregisters a function called before every frame render
  35527. * @param func defines the function to unregister
  35528. */
  35529. unregisterBeforeRender(func: () => void): void;
  35530. /**
  35531. * Registers a function to be called after every frame render
  35532. * @param func defines the function to register
  35533. */
  35534. registerAfterRender(func: () => void): void;
  35535. /**
  35536. * Unregisters a function called after every frame render
  35537. * @param func defines the function to unregister
  35538. */
  35539. unregisterAfterRender(func: () => void): void;
  35540. private _executeOnceBeforeRender;
  35541. /**
  35542. * The provided function will run before render once and will be disposed afterwards.
  35543. * A timeout delay can be provided so that the function will be executed in N ms.
  35544. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35545. * @param func The function to be executed.
  35546. * @param timeout optional delay in ms
  35547. */
  35548. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35549. /** @hidden */
  35550. _addPendingData(data: any): void;
  35551. /** @hidden */
  35552. _removePendingData(data: any): void;
  35553. /**
  35554. * Returns the number of items waiting to be loaded
  35555. * @returns the number of items waiting to be loaded
  35556. */
  35557. getWaitingItemsCount(): number;
  35558. /**
  35559. * Returns a boolean indicating if the scene is still loading data
  35560. */
  35561. readonly isLoading: boolean;
  35562. /**
  35563. * Registers a function to be executed when the scene is ready
  35564. * @param {Function} func - the function to be executed
  35565. */
  35566. executeWhenReady(func: () => void): void;
  35567. /**
  35568. * Returns a promise that resolves when the scene is ready
  35569. * @returns A promise that resolves when the scene is ready
  35570. */
  35571. whenReadyAsync(): Promise<void>;
  35572. /** @hidden */
  35573. _checkIsReady(): void;
  35574. /**
  35575. * Gets all animatable attached to the scene
  35576. */
  35577. readonly animatables: Animatable[];
  35578. /**
  35579. * Resets the last animation time frame.
  35580. * Useful to override when animations start running when loading a scene for the first time.
  35581. */
  35582. resetLastAnimationTimeFrame(): void;
  35583. /**
  35584. * Gets the current view matrix
  35585. * @returns a Matrix
  35586. */
  35587. getViewMatrix(): Matrix;
  35588. /**
  35589. * Gets the current projection matrix
  35590. * @returns a Matrix
  35591. */
  35592. getProjectionMatrix(): Matrix;
  35593. /**
  35594. * Gets the current transform matrix
  35595. * @returns a Matrix made of View * Projection
  35596. */
  35597. getTransformMatrix(): Matrix;
  35598. /**
  35599. * Sets the current transform matrix
  35600. * @param viewL defines the View matrix to use
  35601. * @param projectionL defines the Projection matrix to use
  35602. * @param viewR defines the right View matrix to use (if provided)
  35603. * @param projectionR defines the right Projection matrix to use (if provided)
  35604. */
  35605. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35606. /**
  35607. * Gets the uniform buffer used to store scene data
  35608. * @returns a UniformBuffer
  35609. */
  35610. getSceneUniformBuffer(): UniformBuffer;
  35611. /**
  35612. * Gets an unique (relatively to the current scene) Id
  35613. * @returns an unique number for the scene
  35614. */
  35615. getUniqueId(): number;
  35616. /**
  35617. * Add a mesh to the list of scene's meshes
  35618. * @param newMesh defines the mesh to add
  35619. * @param recursive if all child meshes should also be added to the scene
  35620. */
  35621. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35622. /**
  35623. * Remove a mesh for the list of scene's meshes
  35624. * @param toRemove defines the mesh to remove
  35625. * @param recursive if all child meshes should also be removed from the scene
  35626. * @returns the index where the mesh was in the mesh list
  35627. */
  35628. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35629. /**
  35630. * Add a transform node to the list of scene's transform nodes
  35631. * @param newTransformNode defines the transform node to add
  35632. */
  35633. addTransformNode(newTransformNode: TransformNode): void;
  35634. /**
  35635. * Remove a transform node for the list of scene's transform nodes
  35636. * @param toRemove defines the transform node to remove
  35637. * @returns the index where the transform node was in the transform node list
  35638. */
  35639. removeTransformNode(toRemove: TransformNode): number;
  35640. /**
  35641. * Remove a skeleton for the list of scene's skeletons
  35642. * @param toRemove defines the skeleton to remove
  35643. * @returns the index where the skeleton was in the skeleton list
  35644. */
  35645. removeSkeleton(toRemove: Skeleton): number;
  35646. /**
  35647. * Remove a morph target for the list of scene's morph targets
  35648. * @param toRemove defines the morph target to remove
  35649. * @returns the index where the morph target was in the morph target list
  35650. */
  35651. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35652. /**
  35653. * Remove a light for the list of scene's lights
  35654. * @param toRemove defines the light to remove
  35655. * @returns the index where the light was in the light list
  35656. */
  35657. removeLight(toRemove: Light): number;
  35658. /**
  35659. * Remove a camera for the list of scene's cameras
  35660. * @param toRemove defines the camera to remove
  35661. * @returns the index where the camera was in the camera list
  35662. */
  35663. removeCamera(toRemove: Camera): number;
  35664. /**
  35665. * Remove a particle system for the list of scene's particle systems
  35666. * @param toRemove defines the particle system to remove
  35667. * @returns the index where the particle system was in the particle system list
  35668. */
  35669. removeParticleSystem(toRemove: IParticleSystem): number;
  35670. /**
  35671. * Remove a animation for the list of scene's animations
  35672. * @param toRemove defines the animation to remove
  35673. * @returns the index where the animation was in the animation list
  35674. */
  35675. removeAnimation(toRemove: Animation): number;
  35676. /**
  35677. * Will stop the animation of the given target
  35678. * @param target - the target
  35679. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35680. * @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)
  35681. */
  35682. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35683. /**
  35684. * Removes the given animation group from this scene.
  35685. * @param toRemove The animation group to remove
  35686. * @returns The index of the removed animation group
  35687. */
  35688. removeAnimationGroup(toRemove: AnimationGroup): number;
  35689. /**
  35690. * Removes the given multi-material from this scene.
  35691. * @param toRemove The multi-material to remove
  35692. * @returns The index of the removed multi-material
  35693. */
  35694. removeMultiMaterial(toRemove: MultiMaterial): number;
  35695. /**
  35696. * Removes the given material from this scene.
  35697. * @param toRemove The material to remove
  35698. * @returns The index of the removed material
  35699. */
  35700. removeMaterial(toRemove: Material): number;
  35701. /**
  35702. * Removes the given action manager from this scene.
  35703. * @param toRemove The action manager to remove
  35704. * @returns The index of the removed action manager
  35705. */
  35706. removeActionManager(toRemove: AbstractActionManager): number;
  35707. /**
  35708. * Removes the given texture from this scene.
  35709. * @param toRemove The texture to remove
  35710. * @returns The index of the removed texture
  35711. */
  35712. removeTexture(toRemove: BaseTexture): number;
  35713. /**
  35714. * Adds the given light to this scene
  35715. * @param newLight The light to add
  35716. */
  35717. addLight(newLight: Light): void;
  35718. /**
  35719. * Sorts the list list based on light priorities
  35720. */
  35721. sortLightsByPriority(): void;
  35722. /**
  35723. * Adds the given camera to this scene
  35724. * @param newCamera The camera to add
  35725. */
  35726. addCamera(newCamera: Camera): void;
  35727. /**
  35728. * Adds the given skeleton to this scene
  35729. * @param newSkeleton The skeleton to add
  35730. */
  35731. addSkeleton(newSkeleton: Skeleton): void;
  35732. /**
  35733. * Adds the given particle system to this scene
  35734. * @param newParticleSystem The particle system to add
  35735. */
  35736. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35737. /**
  35738. * Adds the given animation to this scene
  35739. * @param newAnimation The animation to add
  35740. */
  35741. addAnimation(newAnimation: Animation): void;
  35742. /**
  35743. * Adds the given animation group to this scene.
  35744. * @param newAnimationGroup The animation group to add
  35745. */
  35746. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35747. /**
  35748. * Adds the given multi-material to this scene
  35749. * @param newMultiMaterial The multi-material to add
  35750. */
  35751. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35752. /**
  35753. * Adds the given material to this scene
  35754. * @param newMaterial The material to add
  35755. */
  35756. addMaterial(newMaterial: Material): void;
  35757. /**
  35758. * Adds the given morph target to this scene
  35759. * @param newMorphTargetManager The morph target to add
  35760. */
  35761. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35762. /**
  35763. * Adds the given geometry to this scene
  35764. * @param newGeometry The geometry to add
  35765. */
  35766. addGeometry(newGeometry: Geometry): void;
  35767. /**
  35768. * Adds the given action manager to this scene
  35769. * @param newActionManager The action manager to add
  35770. */
  35771. addActionManager(newActionManager: AbstractActionManager): void;
  35772. /**
  35773. * Adds the given texture to this scene.
  35774. * @param newTexture The texture to add
  35775. */
  35776. addTexture(newTexture: BaseTexture): void;
  35777. /**
  35778. * Switch active camera
  35779. * @param newCamera defines the new active camera
  35780. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35781. */
  35782. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35783. /**
  35784. * sets the active camera of the scene using its ID
  35785. * @param id defines the camera's ID
  35786. * @return the new active camera or null if none found.
  35787. */
  35788. setActiveCameraByID(id: string): Nullable<Camera>;
  35789. /**
  35790. * sets the active camera of the scene using its name
  35791. * @param name defines the camera's name
  35792. * @returns the new active camera or null if none found.
  35793. */
  35794. setActiveCameraByName(name: string): Nullable<Camera>;
  35795. /**
  35796. * get an animation group using its name
  35797. * @param name defines the material's name
  35798. * @return the animation group or null if none found.
  35799. */
  35800. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35801. /**
  35802. * Get a material using its unique id
  35803. * @param uniqueId defines the material's unique id
  35804. * @return the material or null if none found.
  35805. */
  35806. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35807. /**
  35808. * get a material using its id
  35809. * @param id defines the material's ID
  35810. * @return the material or null if none found.
  35811. */
  35812. getMaterialByID(id: string): Nullable<Material>;
  35813. /**
  35814. * Gets a the last added material using a given id
  35815. * @param id defines the material's ID
  35816. * @return the last material with the given id or null if none found.
  35817. */
  35818. getLastMaterialByID(id: string): Nullable<Material>;
  35819. /**
  35820. * Gets a material using its name
  35821. * @param name defines the material's name
  35822. * @return the material or null if none found.
  35823. */
  35824. getMaterialByName(name: string): Nullable<Material>;
  35825. /**
  35826. * Get a texture using its unique id
  35827. * @param uniqueId defines the texture's unique id
  35828. * @return the texture or null if none found.
  35829. */
  35830. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35831. /**
  35832. * Gets a camera using its id
  35833. * @param id defines the id to look for
  35834. * @returns the camera or null if not found
  35835. */
  35836. getCameraByID(id: string): Nullable<Camera>;
  35837. /**
  35838. * Gets a camera using its unique id
  35839. * @param uniqueId defines the unique id to look for
  35840. * @returns the camera or null if not found
  35841. */
  35842. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35843. /**
  35844. * Gets a camera using its name
  35845. * @param name defines the camera's name
  35846. * @return the camera or null if none found.
  35847. */
  35848. getCameraByName(name: string): Nullable<Camera>;
  35849. /**
  35850. * Gets a bone using its id
  35851. * @param id defines the bone's id
  35852. * @return the bone or null if not found
  35853. */
  35854. getBoneByID(id: string): Nullable<Bone>;
  35855. /**
  35856. * Gets a bone using its id
  35857. * @param name defines the bone's name
  35858. * @return the bone or null if not found
  35859. */
  35860. getBoneByName(name: string): Nullable<Bone>;
  35861. /**
  35862. * Gets a light node using its name
  35863. * @param name defines the the light's name
  35864. * @return the light or null if none found.
  35865. */
  35866. getLightByName(name: string): Nullable<Light>;
  35867. /**
  35868. * Gets a light node using its id
  35869. * @param id defines the light's id
  35870. * @return the light or null if none found.
  35871. */
  35872. getLightByID(id: string): Nullable<Light>;
  35873. /**
  35874. * Gets a light node using its scene-generated unique ID
  35875. * @param uniqueId defines the light's unique id
  35876. * @return the light or null if none found.
  35877. */
  35878. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35879. /**
  35880. * Gets a particle system by id
  35881. * @param id defines the particle system id
  35882. * @return the corresponding system or null if none found
  35883. */
  35884. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35885. /**
  35886. * Gets a geometry using its ID
  35887. * @param id defines the geometry's id
  35888. * @return the geometry or null if none found.
  35889. */
  35890. getGeometryByID(id: string): Nullable<Geometry>;
  35891. private _getGeometryByUniqueID;
  35892. /**
  35893. * Add a new geometry to this scene
  35894. * @param geometry defines the geometry to be added to the scene.
  35895. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35896. * @return a boolean defining if the geometry was added or not
  35897. */
  35898. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35899. /**
  35900. * Removes an existing geometry
  35901. * @param geometry defines the geometry to be removed from the scene
  35902. * @return a boolean defining if the geometry was removed or not
  35903. */
  35904. removeGeometry(geometry: Geometry): boolean;
  35905. /**
  35906. * Gets the list of geometries attached to the scene
  35907. * @returns an array of Geometry
  35908. */
  35909. getGeometries(): Geometry[];
  35910. /**
  35911. * Gets the first added mesh found of a given ID
  35912. * @param id defines the id to search for
  35913. * @return the mesh found or null if not found at all
  35914. */
  35915. getMeshByID(id: string): Nullable<AbstractMesh>;
  35916. /**
  35917. * Gets a list of meshes using their id
  35918. * @param id defines the id to search for
  35919. * @returns a list of meshes
  35920. */
  35921. getMeshesByID(id: string): Array<AbstractMesh>;
  35922. /**
  35923. * Gets the first added transform node found of a given ID
  35924. * @param id defines the id to search for
  35925. * @return the found transform node or null if not found at all.
  35926. */
  35927. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35928. /**
  35929. * Gets a transform node with its auto-generated unique id
  35930. * @param uniqueId efines the unique id to search for
  35931. * @return the found transform node or null if not found at all.
  35932. */
  35933. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35934. /**
  35935. * Gets a list of transform nodes using their id
  35936. * @param id defines the id to search for
  35937. * @returns a list of transform nodes
  35938. */
  35939. getTransformNodesByID(id: string): Array<TransformNode>;
  35940. /**
  35941. * Gets a mesh with its auto-generated unique id
  35942. * @param uniqueId defines the unique id to search for
  35943. * @return the found mesh or null if not found at all.
  35944. */
  35945. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35946. /**
  35947. * Gets a the last added mesh using a given id
  35948. * @param id defines the id to search for
  35949. * @return the found mesh or null if not found at all.
  35950. */
  35951. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35952. /**
  35953. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35954. * @param id defines the id to search for
  35955. * @return the found node or null if not found at all
  35956. */
  35957. getLastEntryByID(id: string): Nullable<Node>;
  35958. /**
  35959. * Gets a node (Mesh, Camera, Light) using a given id
  35960. * @param id defines the id to search for
  35961. * @return the found node or null if not found at all
  35962. */
  35963. getNodeByID(id: string): Nullable<Node>;
  35964. /**
  35965. * Gets a node (Mesh, Camera, Light) using a given name
  35966. * @param name defines the name to search for
  35967. * @return the found node or null if not found at all.
  35968. */
  35969. getNodeByName(name: string): Nullable<Node>;
  35970. /**
  35971. * Gets a mesh using a given name
  35972. * @param name defines the name to search for
  35973. * @return the found mesh or null if not found at all.
  35974. */
  35975. getMeshByName(name: string): Nullable<AbstractMesh>;
  35976. /**
  35977. * Gets a transform node using a given name
  35978. * @param name defines the name to search for
  35979. * @return the found transform node or null if not found at all.
  35980. */
  35981. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35982. /**
  35983. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35984. * @param id defines the id to search for
  35985. * @return the found skeleton or null if not found at all.
  35986. */
  35987. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35988. /**
  35989. * Gets a skeleton using a given auto generated unique id
  35990. * @param uniqueId defines the unique id to search for
  35991. * @return the found skeleton or null if not found at all.
  35992. */
  35993. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35994. /**
  35995. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35996. * @param id defines the id to search for
  35997. * @return the found skeleton or null if not found at all.
  35998. */
  35999. getSkeletonById(id: string): Nullable<Skeleton>;
  36000. /**
  36001. * Gets a skeleton using a given name
  36002. * @param name defines the name to search for
  36003. * @return the found skeleton or null if not found at all.
  36004. */
  36005. getSkeletonByName(name: string): Nullable<Skeleton>;
  36006. /**
  36007. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36008. * @param id defines the id to search for
  36009. * @return the found morph target manager or null if not found at all.
  36010. */
  36011. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36012. /**
  36013. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36014. * @param id defines the id to search for
  36015. * @return the found morph target or null if not found at all.
  36016. */
  36017. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36018. /**
  36019. * Gets a boolean indicating if the given mesh is active
  36020. * @param mesh defines the mesh to look for
  36021. * @returns true if the mesh is in the active list
  36022. */
  36023. isActiveMesh(mesh: AbstractMesh): boolean;
  36024. /**
  36025. * Return a unique id as a string which can serve as an identifier for the scene
  36026. */
  36027. readonly uid: string;
  36028. /**
  36029. * Add an externaly attached data from its key.
  36030. * This method call will fail and return false, if such key already exists.
  36031. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36032. * @param key the unique key that identifies the data
  36033. * @param data the data object to associate to the key for this Engine instance
  36034. * @return true if no such key were already present and the data was added successfully, false otherwise
  36035. */
  36036. addExternalData<T>(key: string, data: T): boolean;
  36037. /**
  36038. * Get an externaly attached data from its key
  36039. * @param key the unique key that identifies the data
  36040. * @return the associated data, if present (can be null), or undefined if not present
  36041. */
  36042. getExternalData<T>(key: string): Nullable<T>;
  36043. /**
  36044. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36045. * @param key the unique key that identifies the data
  36046. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36047. * @return the associated data, can be null if the factory returned null.
  36048. */
  36049. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36050. /**
  36051. * Remove an externaly attached data from the Engine instance
  36052. * @param key the unique key that identifies the data
  36053. * @return true if the data was successfully removed, false if it doesn't exist
  36054. */
  36055. removeExternalData(key: string): boolean;
  36056. private _evaluateSubMesh;
  36057. /**
  36058. * Clear the processed materials smart array preventing retention point in material dispose.
  36059. */
  36060. freeProcessedMaterials(): void;
  36061. private _preventFreeActiveMeshesAndRenderingGroups;
  36062. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36063. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36064. * when disposing several meshes in a row or a hierarchy of meshes.
  36065. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36066. */
  36067. blockfreeActiveMeshesAndRenderingGroups: boolean;
  36068. /**
  36069. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36070. */
  36071. freeActiveMeshes(): void;
  36072. /**
  36073. * Clear the info related to rendering groups preventing retention points during dispose.
  36074. */
  36075. freeRenderingGroups(): void;
  36076. /** @hidden */
  36077. _isInIntermediateRendering(): boolean;
  36078. /**
  36079. * Lambda returning the list of potentially active meshes.
  36080. */
  36081. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36082. /**
  36083. * Lambda returning the list of potentially active sub meshes.
  36084. */
  36085. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36086. /**
  36087. * Lambda returning the list of potentially intersecting sub meshes.
  36088. */
  36089. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36090. /**
  36091. * Lambda returning the list of potentially colliding sub meshes.
  36092. */
  36093. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36094. private _activeMeshesFrozen;
  36095. private _skipEvaluateActiveMeshesCompletely;
  36096. /**
  36097. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36098. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36099. * @returns the current scene
  36100. */
  36101. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36102. /**
  36103. * Use this function to restart evaluating active meshes on every frame
  36104. * @returns the current scene
  36105. */
  36106. unfreezeActiveMeshes(): Scene;
  36107. private _evaluateActiveMeshes;
  36108. private _activeMesh;
  36109. /**
  36110. * Update the transform matrix to update from the current active camera
  36111. * @param force defines a boolean used to force the update even if cache is up to date
  36112. */
  36113. updateTransformMatrix(force?: boolean): void;
  36114. private _bindFrameBuffer;
  36115. /** @hidden */
  36116. _allowPostProcessClearColor: boolean;
  36117. /** @hidden */
  36118. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36119. private _processSubCameras;
  36120. private _checkIntersections;
  36121. /** @hidden */
  36122. _advancePhysicsEngineStep(step: number): void;
  36123. /**
  36124. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36125. */
  36126. getDeterministicFrameTime: () => number;
  36127. /** @hidden */
  36128. _animate(): void;
  36129. /** Execute all animations (for a frame) */
  36130. animate(): void;
  36131. /**
  36132. * Render the scene
  36133. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36134. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36135. */
  36136. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36137. /**
  36138. * Freeze all materials
  36139. * A frozen material will not be updatable but should be faster to render
  36140. */
  36141. freezeMaterials(): void;
  36142. /**
  36143. * Unfreeze all materials
  36144. * A frozen material will not be updatable but should be faster to render
  36145. */
  36146. unfreezeMaterials(): void;
  36147. /**
  36148. * Releases all held ressources
  36149. */
  36150. dispose(): void;
  36151. /**
  36152. * Gets if the scene is already disposed
  36153. */
  36154. readonly isDisposed: boolean;
  36155. /**
  36156. * Call this function to reduce memory footprint of the scene.
  36157. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36158. */
  36159. clearCachedVertexData(): void;
  36160. /**
  36161. * This function will remove the local cached buffer data from texture.
  36162. * It will save memory but will prevent the texture from being rebuilt
  36163. */
  36164. cleanCachedTextureBuffer(): void;
  36165. /**
  36166. * Get the world extend vectors with an optional filter
  36167. *
  36168. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36169. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36170. */
  36171. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36172. min: Vector3;
  36173. max: Vector3;
  36174. };
  36175. /**
  36176. * Creates a ray that can be used to pick in the scene
  36177. * @param x defines the x coordinate of the origin (on-screen)
  36178. * @param y defines the y coordinate of the origin (on-screen)
  36179. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36180. * @param camera defines the camera to use for the picking
  36181. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36182. * @returns a Ray
  36183. */
  36184. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36185. /**
  36186. * Creates a ray that can be used to pick in the scene
  36187. * @param x defines the x coordinate of the origin (on-screen)
  36188. * @param y defines the y coordinate of the origin (on-screen)
  36189. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36190. * @param result defines the ray where to store the picking ray
  36191. * @param camera defines the camera to use for the picking
  36192. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36193. * @returns the current scene
  36194. */
  36195. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36196. /**
  36197. * Creates a ray that can be used to pick in the scene
  36198. * @param x defines the x coordinate of the origin (on-screen)
  36199. * @param y defines the y coordinate of the origin (on-screen)
  36200. * @param camera defines the camera to use for the picking
  36201. * @returns a Ray
  36202. */
  36203. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36204. /**
  36205. * Creates a ray that can be used to pick in the scene
  36206. * @param x defines the x coordinate of the origin (on-screen)
  36207. * @param y defines the y coordinate of the origin (on-screen)
  36208. * @param result defines the ray where to store the picking ray
  36209. * @param camera defines the camera to use for the picking
  36210. * @returns the current scene
  36211. */
  36212. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36213. /** Launch a ray to try to pick a mesh in the scene
  36214. * @param x position on screen
  36215. * @param y position on screen
  36216. * @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
  36217. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36218. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36219. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36220. * @returns a PickingInfo
  36221. */
  36222. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36223. /** Use the given ray to pick a mesh in the scene
  36224. * @param ray The ray to use to pick meshes
  36225. * @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
  36226. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36227. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36228. * @returns a PickingInfo
  36229. */
  36230. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36231. /**
  36232. * Launch a ray to try to pick a mesh in the scene
  36233. * @param x X position on screen
  36234. * @param y Y position on screen
  36235. * @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
  36236. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36237. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36238. * @returns an array of PickingInfo
  36239. */
  36240. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36241. /**
  36242. * Launch a ray to try to pick a mesh in the scene
  36243. * @param ray Ray to use
  36244. * @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
  36245. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36246. * @returns an array of PickingInfo
  36247. */
  36248. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36249. /**
  36250. * Force the value of meshUnderPointer
  36251. * @param mesh defines the mesh to use
  36252. */
  36253. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36254. /**
  36255. * Gets the mesh under the pointer
  36256. * @returns a Mesh or null if no mesh is under the pointer
  36257. */
  36258. getPointerOverMesh(): Nullable<AbstractMesh>;
  36259. /** @hidden */
  36260. _rebuildGeometries(): void;
  36261. /** @hidden */
  36262. _rebuildTextures(): void;
  36263. private _getByTags;
  36264. /**
  36265. * Get a list of meshes by tags
  36266. * @param tagsQuery defines the tags query to use
  36267. * @param forEach defines a predicate used to filter results
  36268. * @returns an array of Mesh
  36269. */
  36270. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36271. /**
  36272. * Get a list of cameras by tags
  36273. * @param tagsQuery defines the tags query to use
  36274. * @param forEach defines a predicate used to filter results
  36275. * @returns an array of Camera
  36276. */
  36277. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36278. /**
  36279. * Get a list of lights by tags
  36280. * @param tagsQuery defines the tags query to use
  36281. * @param forEach defines a predicate used to filter results
  36282. * @returns an array of Light
  36283. */
  36284. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36285. /**
  36286. * Get a list of materials by tags
  36287. * @param tagsQuery defines the tags query to use
  36288. * @param forEach defines a predicate used to filter results
  36289. * @returns an array of Material
  36290. */
  36291. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36292. /**
  36293. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36294. * This allowed control for front to back rendering or reversly depending of the special needs.
  36295. *
  36296. * @param renderingGroupId The rendering group id corresponding to its index
  36297. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36298. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36299. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36300. */
  36301. 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;
  36302. /**
  36303. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36304. *
  36305. * @param renderingGroupId The rendering group id corresponding to its index
  36306. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36307. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36308. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36309. */
  36310. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36311. /**
  36312. * Gets the current auto clear configuration for one rendering group of the rendering
  36313. * manager.
  36314. * @param index the rendering group index to get the information for
  36315. * @returns The auto clear setup for the requested rendering group
  36316. */
  36317. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36318. private _blockMaterialDirtyMechanism;
  36319. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36320. blockMaterialDirtyMechanism: boolean;
  36321. /**
  36322. * Will flag all materials as dirty to trigger new shader compilation
  36323. * @param flag defines the flag used to specify which material part must be marked as dirty
  36324. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36325. */
  36326. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36327. /** @hidden */
  36328. _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;
  36329. /** @hidden */
  36330. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36331. /** @hidden */
  36332. _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;
  36333. /** @hidden */
  36334. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36335. /** @hidden */
  36336. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36337. /** @hidden */
  36338. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36339. }
  36340. }
  36341. declare module BABYLON {
  36342. /**
  36343. * Set of assets to keep when moving a scene into an asset container.
  36344. */
  36345. export class KeepAssets extends AbstractScene {
  36346. }
  36347. /**
  36348. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36349. */
  36350. export class InstantiatedEntries {
  36351. /**
  36352. * List of new root nodes (eg. nodes with no parent)
  36353. */
  36354. rootNodes: TransformNode[];
  36355. /**
  36356. * List of new skeletons
  36357. */
  36358. skeletons: Skeleton[];
  36359. /**
  36360. * List of new animation groups
  36361. */
  36362. animationGroups: AnimationGroup[];
  36363. }
  36364. /**
  36365. * Container with a set of assets that can be added or removed from a scene.
  36366. */
  36367. export class AssetContainer extends AbstractScene {
  36368. /**
  36369. * The scene the AssetContainer belongs to.
  36370. */
  36371. scene: Scene;
  36372. /**
  36373. * Instantiates an AssetContainer.
  36374. * @param scene The scene the AssetContainer belongs to.
  36375. */
  36376. constructor(scene: Scene);
  36377. /**
  36378. * Instantiate or clone all meshes and add the new ones to the scene.
  36379. * Skeletons and animation groups will all be cloned
  36380. * @param nameFunction defines an optional function used to get new names for clones
  36381. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36382. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36383. */
  36384. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36385. /**
  36386. * Adds all the assets from the container to the scene.
  36387. */
  36388. addAllToScene(): void;
  36389. /**
  36390. * Removes all the assets in the container from the scene
  36391. */
  36392. removeAllFromScene(): void;
  36393. /**
  36394. * Disposes all the assets in the container
  36395. */
  36396. dispose(): void;
  36397. private _moveAssets;
  36398. /**
  36399. * Removes all the assets contained in the scene and adds them to the container.
  36400. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36401. */
  36402. moveAllFromScene(keepAssets?: KeepAssets): void;
  36403. /**
  36404. * 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.
  36405. * @returns the root mesh
  36406. */
  36407. createRootMesh(): Mesh;
  36408. /**
  36409. * Merge animations from this asset container into a scene
  36410. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36411. * @param animatables set of animatables to retarget to a node from the scene
  36412. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36413. */
  36414. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36415. }
  36416. }
  36417. declare module BABYLON {
  36418. /**
  36419. * Defines how the parser contract is defined.
  36420. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36421. */
  36422. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36423. /**
  36424. * Defines how the individual parser contract is defined.
  36425. * These parser can parse an individual asset
  36426. */
  36427. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36428. /**
  36429. * Base class of the scene acting as a container for the different elements composing a scene.
  36430. * This class is dynamically extended by the different components of the scene increasing
  36431. * flexibility and reducing coupling
  36432. */
  36433. export abstract class AbstractScene {
  36434. /**
  36435. * Stores the list of available parsers in the application.
  36436. */
  36437. private static _BabylonFileParsers;
  36438. /**
  36439. * Stores the list of available individual parsers in the application.
  36440. */
  36441. private static _IndividualBabylonFileParsers;
  36442. /**
  36443. * Adds a parser in the list of available ones
  36444. * @param name Defines the name of the parser
  36445. * @param parser Defines the parser to add
  36446. */
  36447. static AddParser(name: string, parser: BabylonFileParser): void;
  36448. /**
  36449. * Gets a general parser from the list of avaialble ones
  36450. * @param name Defines the name of the parser
  36451. * @returns the requested parser or null
  36452. */
  36453. static GetParser(name: string): Nullable<BabylonFileParser>;
  36454. /**
  36455. * Adds n individual parser in the list of available ones
  36456. * @param name Defines the name of the parser
  36457. * @param parser Defines the parser to add
  36458. */
  36459. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36460. /**
  36461. * Gets an individual parser from the list of avaialble ones
  36462. * @param name Defines the name of the parser
  36463. * @returns the requested parser or null
  36464. */
  36465. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36466. /**
  36467. * Parser json data and populate both a scene and its associated container object
  36468. * @param jsonData Defines the data to parse
  36469. * @param scene Defines the scene to parse the data for
  36470. * @param container Defines the container attached to the parsing sequence
  36471. * @param rootUrl Defines the root url of the data
  36472. */
  36473. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36474. /**
  36475. * Gets the list of root nodes (ie. nodes with no parent)
  36476. */
  36477. rootNodes: Node[];
  36478. /** All of the cameras added to this scene
  36479. * @see http://doc.babylonjs.com/babylon101/cameras
  36480. */
  36481. cameras: Camera[];
  36482. /**
  36483. * All of the lights added to this scene
  36484. * @see http://doc.babylonjs.com/babylon101/lights
  36485. */
  36486. lights: Light[];
  36487. /**
  36488. * All of the (abstract) meshes added to this scene
  36489. */
  36490. meshes: AbstractMesh[];
  36491. /**
  36492. * The list of skeletons added to the scene
  36493. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36494. */
  36495. skeletons: Skeleton[];
  36496. /**
  36497. * All of the particle systems added to this scene
  36498. * @see http://doc.babylonjs.com/babylon101/particles
  36499. */
  36500. particleSystems: IParticleSystem[];
  36501. /**
  36502. * Gets a list of Animations associated with the scene
  36503. */
  36504. animations: Animation[];
  36505. /**
  36506. * All of the animation groups added to this scene
  36507. * @see http://doc.babylonjs.com/how_to/group
  36508. */
  36509. animationGroups: AnimationGroup[];
  36510. /**
  36511. * All of the multi-materials added to this scene
  36512. * @see http://doc.babylonjs.com/how_to/multi_materials
  36513. */
  36514. multiMaterials: MultiMaterial[];
  36515. /**
  36516. * All of the materials added to this scene
  36517. * In the context of a Scene, it is not supposed to be modified manually.
  36518. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36519. * Note also that the order of the Material within the array is not significant and might change.
  36520. * @see http://doc.babylonjs.com/babylon101/materials
  36521. */
  36522. materials: Material[];
  36523. /**
  36524. * The list of morph target managers added to the scene
  36525. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36526. */
  36527. morphTargetManagers: MorphTargetManager[];
  36528. /**
  36529. * The list of geometries used in the scene.
  36530. */
  36531. geometries: Geometry[];
  36532. /**
  36533. * All of the tranform nodes added to this scene
  36534. * In the context of a Scene, it is not supposed to be modified manually.
  36535. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36536. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36537. * @see http://doc.babylonjs.com/how_to/transformnode
  36538. */
  36539. transformNodes: TransformNode[];
  36540. /**
  36541. * ActionManagers available on the scene.
  36542. */
  36543. actionManagers: AbstractActionManager[];
  36544. /**
  36545. * Textures to keep.
  36546. */
  36547. textures: BaseTexture[];
  36548. /**
  36549. * Environment texture for the scene
  36550. */
  36551. environmentTexture: Nullable<BaseTexture>;
  36552. /**
  36553. * @returns all meshes, lights, cameras, transformNodes and bones
  36554. */
  36555. getNodes(): Array<Node>;
  36556. }
  36557. }
  36558. declare module BABYLON {
  36559. /**
  36560. * Interface used to define options for Sound class
  36561. */
  36562. export interface ISoundOptions {
  36563. /**
  36564. * Does the sound autoplay once loaded.
  36565. */
  36566. autoplay?: boolean;
  36567. /**
  36568. * Does the sound loop after it finishes playing once.
  36569. */
  36570. loop?: boolean;
  36571. /**
  36572. * Sound's volume
  36573. */
  36574. volume?: number;
  36575. /**
  36576. * Is it a spatial sound?
  36577. */
  36578. spatialSound?: boolean;
  36579. /**
  36580. * Maximum distance to hear that sound
  36581. */
  36582. maxDistance?: number;
  36583. /**
  36584. * Uses user defined attenuation function
  36585. */
  36586. useCustomAttenuation?: boolean;
  36587. /**
  36588. * Define the roll off factor of spatial sounds.
  36589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36590. */
  36591. rolloffFactor?: number;
  36592. /**
  36593. * Define the reference distance the sound should be heard perfectly.
  36594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36595. */
  36596. refDistance?: number;
  36597. /**
  36598. * Define the distance attenuation model the sound will follow.
  36599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36600. */
  36601. distanceModel?: string;
  36602. /**
  36603. * Defines the playback speed (1 by default)
  36604. */
  36605. playbackRate?: number;
  36606. /**
  36607. * Defines if the sound is from a streaming source
  36608. */
  36609. streaming?: boolean;
  36610. /**
  36611. * Defines an optional length (in seconds) inside the sound file
  36612. */
  36613. length?: number;
  36614. /**
  36615. * Defines an optional offset (in seconds) inside the sound file
  36616. */
  36617. offset?: number;
  36618. /**
  36619. * If true, URLs will not be required to state the audio file codec to use.
  36620. */
  36621. skipCodecCheck?: boolean;
  36622. }
  36623. /**
  36624. * Defines a sound that can be played in the application.
  36625. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36627. */
  36628. export class Sound {
  36629. /**
  36630. * The name of the sound in the scene.
  36631. */
  36632. name: string;
  36633. /**
  36634. * Does the sound autoplay once loaded.
  36635. */
  36636. autoplay: boolean;
  36637. /**
  36638. * Does the sound loop after it finishes playing once.
  36639. */
  36640. loop: boolean;
  36641. /**
  36642. * Does the sound use a custom attenuation curve to simulate the falloff
  36643. * happening when the source gets further away from the camera.
  36644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36645. */
  36646. useCustomAttenuation: boolean;
  36647. /**
  36648. * The sound track id this sound belongs to.
  36649. */
  36650. soundTrackId: number;
  36651. /**
  36652. * Is this sound currently played.
  36653. */
  36654. isPlaying: boolean;
  36655. /**
  36656. * Is this sound currently paused.
  36657. */
  36658. isPaused: boolean;
  36659. /**
  36660. * Does this sound enables spatial sound.
  36661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36662. */
  36663. spatialSound: boolean;
  36664. /**
  36665. * Define the reference distance the sound should be heard perfectly.
  36666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36667. */
  36668. refDistance: number;
  36669. /**
  36670. * Define the roll off factor of spatial sounds.
  36671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36672. */
  36673. rolloffFactor: number;
  36674. /**
  36675. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36677. */
  36678. maxDistance: number;
  36679. /**
  36680. * Define the distance attenuation model the sound will follow.
  36681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36682. */
  36683. distanceModel: string;
  36684. /**
  36685. * @hidden
  36686. * Back Compat
  36687. **/
  36688. onended: () => any;
  36689. /**
  36690. * Observable event when the current playing sound finishes.
  36691. */
  36692. onEndedObservable: Observable<Sound>;
  36693. private _panningModel;
  36694. private _playbackRate;
  36695. private _streaming;
  36696. private _startTime;
  36697. private _startOffset;
  36698. private _position;
  36699. /** @hidden */
  36700. _positionInEmitterSpace: boolean;
  36701. private _localDirection;
  36702. private _volume;
  36703. private _isReadyToPlay;
  36704. private _isDirectional;
  36705. private _readyToPlayCallback;
  36706. private _audioBuffer;
  36707. private _soundSource;
  36708. private _streamingSource;
  36709. private _soundPanner;
  36710. private _soundGain;
  36711. private _inputAudioNode;
  36712. private _outputAudioNode;
  36713. private _coneInnerAngle;
  36714. private _coneOuterAngle;
  36715. private _coneOuterGain;
  36716. private _scene;
  36717. private _connectedTransformNode;
  36718. private _customAttenuationFunction;
  36719. private _registerFunc;
  36720. private _isOutputConnected;
  36721. private _htmlAudioElement;
  36722. private _urlType;
  36723. private _length?;
  36724. private _offset?;
  36725. /** @hidden */
  36726. static _SceneComponentInitialization: (scene: Scene) => void;
  36727. /**
  36728. * Create a sound and attach it to a scene
  36729. * @param name Name of your sound
  36730. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36731. * @param scene defines the scene the sound belongs to
  36732. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36733. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36734. */
  36735. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36736. /**
  36737. * Release the sound and its associated resources
  36738. */
  36739. dispose(): void;
  36740. /**
  36741. * Gets if the sounds is ready to be played or not.
  36742. * @returns true if ready, otherwise false
  36743. */
  36744. isReady(): boolean;
  36745. private _soundLoaded;
  36746. /**
  36747. * Sets the data of the sound from an audiobuffer
  36748. * @param audioBuffer The audioBuffer containing the data
  36749. */
  36750. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36751. /**
  36752. * Updates the current sounds options such as maxdistance, loop...
  36753. * @param options A JSON object containing values named as the object properties
  36754. */
  36755. updateOptions(options: ISoundOptions): void;
  36756. private _createSpatialParameters;
  36757. private _updateSpatialParameters;
  36758. /**
  36759. * Switch the panning model to HRTF:
  36760. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36762. */
  36763. switchPanningModelToHRTF(): void;
  36764. /**
  36765. * Switch the panning model to Equal Power:
  36766. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36768. */
  36769. switchPanningModelToEqualPower(): void;
  36770. private _switchPanningModel;
  36771. /**
  36772. * Connect this sound to a sound track audio node like gain...
  36773. * @param soundTrackAudioNode the sound track audio node to connect to
  36774. */
  36775. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36776. /**
  36777. * Transform this sound into a directional source
  36778. * @param coneInnerAngle Size of the inner cone in degree
  36779. * @param coneOuterAngle Size of the outer cone in degree
  36780. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36781. */
  36782. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36783. /**
  36784. * Gets or sets the inner angle for the directional cone.
  36785. */
  36786. /**
  36787. * Gets or sets the inner angle for the directional cone.
  36788. */
  36789. directionalConeInnerAngle: number;
  36790. /**
  36791. * Gets or sets the outer angle for the directional cone.
  36792. */
  36793. /**
  36794. * Gets or sets the outer angle for the directional cone.
  36795. */
  36796. directionalConeOuterAngle: number;
  36797. /**
  36798. * Sets the position of the emitter if spatial sound is enabled
  36799. * @param newPosition Defines the new posisiton
  36800. */
  36801. setPosition(newPosition: Vector3): void;
  36802. /**
  36803. * Sets the local direction of the emitter if spatial sound is enabled
  36804. * @param newLocalDirection Defines the new local direction
  36805. */
  36806. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36807. private _updateDirection;
  36808. /** @hidden */
  36809. updateDistanceFromListener(): void;
  36810. /**
  36811. * Sets a new custom attenuation function for the sound.
  36812. * @param callback Defines the function used for the attenuation
  36813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36814. */
  36815. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36816. /**
  36817. * Play the sound
  36818. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36819. * @param offset (optional) Start the sound at a specific time in seconds
  36820. * @param length (optional) Sound duration (in seconds)
  36821. */
  36822. play(time?: number, offset?: number, length?: number): void;
  36823. private _onended;
  36824. /**
  36825. * Stop the sound
  36826. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36827. */
  36828. stop(time?: number): void;
  36829. /**
  36830. * Put the sound in pause
  36831. */
  36832. pause(): void;
  36833. /**
  36834. * Sets a dedicated volume for this sounds
  36835. * @param newVolume Define the new volume of the sound
  36836. * @param time Define time for gradual change to new volume
  36837. */
  36838. setVolume(newVolume: number, time?: number): void;
  36839. /**
  36840. * Set the sound play back rate
  36841. * @param newPlaybackRate Define the playback rate the sound should be played at
  36842. */
  36843. setPlaybackRate(newPlaybackRate: number): void;
  36844. /**
  36845. * Gets the volume of the sound.
  36846. * @returns the volume of the sound
  36847. */
  36848. getVolume(): number;
  36849. /**
  36850. * Attach the sound to a dedicated mesh
  36851. * @param transformNode The transform node to connect the sound with
  36852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36853. */
  36854. attachToMesh(transformNode: TransformNode): void;
  36855. /**
  36856. * Detach the sound from the previously attached mesh
  36857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36858. */
  36859. detachFromMesh(): void;
  36860. private _onRegisterAfterWorldMatrixUpdate;
  36861. /**
  36862. * Clone the current sound in the scene.
  36863. * @returns the new sound clone
  36864. */
  36865. clone(): Nullable<Sound>;
  36866. /**
  36867. * Gets the current underlying audio buffer containing the data
  36868. * @returns the audio buffer
  36869. */
  36870. getAudioBuffer(): Nullable<AudioBuffer>;
  36871. /**
  36872. * Serializes the Sound in a JSON representation
  36873. * @returns the JSON representation of the sound
  36874. */
  36875. serialize(): any;
  36876. /**
  36877. * Parse a JSON representation of a sound to innstantiate in a given scene
  36878. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36879. * @param scene Define the scene the new parsed sound should be created in
  36880. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36881. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36882. * @returns the newly parsed sound
  36883. */
  36884. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36885. }
  36886. }
  36887. declare module BABYLON {
  36888. /**
  36889. * This defines an action helpful to play a defined sound on a triggered action.
  36890. */
  36891. export class PlaySoundAction extends Action {
  36892. private _sound;
  36893. /**
  36894. * Instantiate the action
  36895. * @param triggerOptions defines the trigger options
  36896. * @param sound defines the sound to play
  36897. * @param condition defines the trigger related conditions
  36898. */
  36899. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36900. /** @hidden */
  36901. _prepare(): void;
  36902. /**
  36903. * Execute the action and play the sound.
  36904. */
  36905. execute(): void;
  36906. /**
  36907. * Serializes the actions and its related information.
  36908. * @param parent defines the object to serialize in
  36909. * @returns the serialized object
  36910. */
  36911. serialize(parent: any): any;
  36912. }
  36913. /**
  36914. * This defines an action helpful to stop a defined sound on a triggered action.
  36915. */
  36916. export class StopSoundAction extends Action {
  36917. private _sound;
  36918. /**
  36919. * Instantiate the action
  36920. * @param triggerOptions defines the trigger options
  36921. * @param sound defines the sound to stop
  36922. * @param condition defines the trigger related conditions
  36923. */
  36924. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36925. /** @hidden */
  36926. _prepare(): void;
  36927. /**
  36928. * Execute the action and stop the sound.
  36929. */
  36930. execute(): void;
  36931. /**
  36932. * Serializes the actions and its related information.
  36933. * @param parent defines the object to serialize in
  36934. * @returns the serialized object
  36935. */
  36936. serialize(parent: any): any;
  36937. }
  36938. }
  36939. declare module BABYLON {
  36940. /**
  36941. * This defines an action responsible to change the value of a property
  36942. * by interpolating between its current value and the newly set one once triggered.
  36943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36944. */
  36945. export class InterpolateValueAction extends Action {
  36946. /**
  36947. * Defines the path of the property where the value should be interpolated
  36948. */
  36949. propertyPath: string;
  36950. /**
  36951. * Defines the target value at the end of the interpolation.
  36952. */
  36953. value: any;
  36954. /**
  36955. * Defines the time it will take for the property to interpolate to the value.
  36956. */
  36957. duration: number;
  36958. /**
  36959. * Defines if the other scene animations should be stopped when the action has been triggered
  36960. */
  36961. stopOtherAnimations?: boolean;
  36962. /**
  36963. * Defines a callback raised once the interpolation animation has been done.
  36964. */
  36965. onInterpolationDone?: () => void;
  36966. /**
  36967. * Observable triggered once the interpolation animation has been done.
  36968. */
  36969. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36970. private _target;
  36971. private _effectiveTarget;
  36972. private _property;
  36973. /**
  36974. * Instantiate the action
  36975. * @param triggerOptions defines the trigger options
  36976. * @param target defines the object containing the value to interpolate
  36977. * @param propertyPath defines the path to the property in the target object
  36978. * @param value defines the target value at the end of the interpolation
  36979. * @param duration deines the time it will take for the property to interpolate to the value.
  36980. * @param condition defines the trigger related conditions
  36981. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36982. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36983. */
  36984. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36985. /** @hidden */
  36986. _prepare(): void;
  36987. /**
  36988. * Execute the action starts the value interpolation.
  36989. */
  36990. execute(): void;
  36991. /**
  36992. * Serializes the actions and its related information.
  36993. * @param parent defines the object to serialize in
  36994. * @returns the serialized object
  36995. */
  36996. serialize(parent: any): any;
  36997. }
  36998. }
  36999. declare module BABYLON {
  37000. /**
  37001. * Options allowed during the creation of a sound track.
  37002. */
  37003. export interface ISoundTrackOptions {
  37004. /**
  37005. * The volume the sound track should take during creation
  37006. */
  37007. volume?: number;
  37008. /**
  37009. * Define if the sound track is the main sound track of the scene
  37010. */
  37011. mainTrack?: boolean;
  37012. }
  37013. /**
  37014. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37015. * It will be also used in a future release to apply effects on a specific track.
  37016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37017. */
  37018. export class SoundTrack {
  37019. /**
  37020. * The unique identifier of the sound track in the scene.
  37021. */
  37022. id: number;
  37023. /**
  37024. * The list of sounds included in the sound track.
  37025. */
  37026. soundCollection: Array<Sound>;
  37027. private _outputAudioNode;
  37028. private _scene;
  37029. private _connectedAnalyser;
  37030. private _options;
  37031. private _isInitialized;
  37032. /**
  37033. * Creates a new sound track.
  37034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37035. * @param scene Define the scene the sound track belongs to
  37036. * @param options
  37037. */
  37038. constructor(scene: Scene, options?: ISoundTrackOptions);
  37039. private _initializeSoundTrackAudioGraph;
  37040. /**
  37041. * Release the sound track and its associated resources
  37042. */
  37043. dispose(): void;
  37044. /**
  37045. * Adds a sound to this sound track
  37046. * @param sound define the cound to add
  37047. * @ignoreNaming
  37048. */
  37049. AddSound(sound: Sound): void;
  37050. /**
  37051. * Removes a sound to this sound track
  37052. * @param sound define the cound to remove
  37053. * @ignoreNaming
  37054. */
  37055. RemoveSound(sound: Sound): void;
  37056. /**
  37057. * Set a global volume for the full sound track.
  37058. * @param newVolume Define the new volume of the sound track
  37059. */
  37060. setVolume(newVolume: number): void;
  37061. /**
  37062. * Switch the panning model to HRTF:
  37063. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37065. */
  37066. switchPanningModelToHRTF(): void;
  37067. /**
  37068. * Switch the panning model to Equal Power:
  37069. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37071. */
  37072. switchPanningModelToEqualPower(): void;
  37073. /**
  37074. * Connect the sound track to an audio analyser allowing some amazing
  37075. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37077. * @param analyser The analyser to connect to the engine
  37078. */
  37079. connectToAnalyser(analyser: Analyser): void;
  37080. }
  37081. }
  37082. declare module BABYLON {
  37083. interface AbstractScene {
  37084. /**
  37085. * The list of sounds used in the scene.
  37086. */
  37087. sounds: Nullable<Array<Sound>>;
  37088. }
  37089. interface Scene {
  37090. /**
  37091. * @hidden
  37092. * Backing field
  37093. */
  37094. _mainSoundTrack: SoundTrack;
  37095. /**
  37096. * The main sound track played by the scene.
  37097. * It cotains your primary collection of sounds.
  37098. */
  37099. mainSoundTrack: SoundTrack;
  37100. /**
  37101. * The list of sound tracks added to the scene
  37102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37103. */
  37104. soundTracks: Nullable<Array<SoundTrack>>;
  37105. /**
  37106. * Gets a sound using a given name
  37107. * @param name defines the name to search for
  37108. * @return the found sound or null if not found at all.
  37109. */
  37110. getSoundByName(name: string): Nullable<Sound>;
  37111. /**
  37112. * Gets or sets if audio support is enabled
  37113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37114. */
  37115. audioEnabled: boolean;
  37116. /**
  37117. * Gets or sets if audio will be output to headphones
  37118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37119. */
  37120. headphone: boolean;
  37121. /**
  37122. * Gets or sets custom audio listener position provider
  37123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37124. */
  37125. audioListenerPositionProvider: Nullable<() => Vector3>;
  37126. /**
  37127. * Gets or sets a refresh rate when using 3D audio positioning
  37128. */
  37129. audioPositioningRefreshRate: number;
  37130. }
  37131. /**
  37132. * Defines the sound scene component responsible to manage any sounds
  37133. * in a given scene.
  37134. */
  37135. export class AudioSceneComponent implements ISceneSerializableComponent {
  37136. /**
  37137. * The component name helpfull to identify the component in the list of scene components.
  37138. */
  37139. readonly name: string;
  37140. /**
  37141. * The scene the component belongs to.
  37142. */
  37143. scene: Scene;
  37144. private _audioEnabled;
  37145. /**
  37146. * Gets whether audio is enabled or not.
  37147. * Please use related enable/disable method to switch state.
  37148. */
  37149. readonly audioEnabled: boolean;
  37150. private _headphone;
  37151. /**
  37152. * Gets whether audio is outputing to headphone or not.
  37153. * Please use the according Switch methods to change output.
  37154. */
  37155. readonly headphone: boolean;
  37156. /**
  37157. * Gets or sets a refresh rate when using 3D audio positioning
  37158. */
  37159. audioPositioningRefreshRate: number;
  37160. private _audioListenerPositionProvider;
  37161. /**
  37162. * Gets the current audio listener position provider
  37163. */
  37164. /**
  37165. * Sets a custom listener position for all sounds in the scene
  37166. * By default, this is the position of the first active camera
  37167. */
  37168. audioListenerPositionProvider: Nullable<() => Vector3>;
  37169. /**
  37170. * Creates a new instance of the component for the given scene
  37171. * @param scene Defines the scene to register the component in
  37172. */
  37173. constructor(scene: Scene);
  37174. /**
  37175. * Registers the component in a given scene
  37176. */
  37177. register(): void;
  37178. /**
  37179. * Rebuilds the elements related to this component in case of
  37180. * context lost for instance.
  37181. */
  37182. rebuild(): void;
  37183. /**
  37184. * Serializes the component data to the specified json object
  37185. * @param serializationObject The object to serialize to
  37186. */
  37187. serialize(serializationObject: any): void;
  37188. /**
  37189. * Adds all the elements from the container to the scene
  37190. * @param container the container holding the elements
  37191. */
  37192. addFromContainer(container: AbstractScene): void;
  37193. /**
  37194. * Removes all the elements in the container from the scene
  37195. * @param container contains the elements to remove
  37196. * @param dispose if the removed element should be disposed (default: false)
  37197. */
  37198. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37199. /**
  37200. * Disposes the component and the associated ressources.
  37201. */
  37202. dispose(): void;
  37203. /**
  37204. * Disables audio in the associated scene.
  37205. */
  37206. disableAudio(): void;
  37207. /**
  37208. * Enables audio in the associated scene.
  37209. */
  37210. enableAudio(): void;
  37211. /**
  37212. * Switch audio to headphone output.
  37213. */
  37214. switchAudioModeForHeadphones(): void;
  37215. /**
  37216. * Switch audio to normal speakers.
  37217. */
  37218. switchAudioModeForNormalSpeakers(): void;
  37219. private _cachedCameraDirection;
  37220. private _cachedCameraPosition;
  37221. private _lastCheck;
  37222. private _afterRender;
  37223. }
  37224. }
  37225. declare module BABYLON {
  37226. /**
  37227. * Wraps one or more Sound objects and selects one with random weight for playback.
  37228. */
  37229. export class WeightedSound {
  37230. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37231. loop: boolean;
  37232. private _coneInnerAngle;
  37233. private _coneOuterAngle;
  37234. private _volume;
  37235. /** A Sound is currently playing. */
  37236. isPlaying: boolean;
  37237. /** A Sound is currently paused. */
  37238. isPaused: boolean;
  37239. private _sounds;
  37240. private _weights;
  37241. private _currentIndex?;
  37242. /**
  37243. * Creates a new WeightedSound from the list of sounds given.
  37244. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37245. * @param sounds Array of Sounds that will be selected from.
  37246. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37247. */
  37248. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37249. /**
  37250. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37251. */
  37252. /**
  37253. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37254. */
  37255. directionalConeInnerAngle: number;
  37256. /**
  37257. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37258. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37259. */
  37260. /**
  37261. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37262. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37263. */
  37264. directionalConeOuterAngle: number;
  37265. /**
  37266. * Playback volume.
  37267. */
  37268. /**
  37269. * Playback volume.
  37270. */
  37271. volume: number;
  37272. private _onended;
  37273. /**
  37274. * Suspend playback
  37275. */
  37276. pause(): void;
  37277. /**
  37278. * Stop playback
  37279. */
  37280. stop(): void;
  37281. /**
  37282. * Start playback.
  37283. * @param startOffset Position the clip head at a specific time in seconds.
  37284. */
  37285. play(startOffset?: number): void;
  37286. }
  37287. }
  37288. declare module BABYLON {
  37289. /**
  37290. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37291. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37292. */
  37293. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37294. /**
  37295. * Gets the name of the behavior.
  37296. */
  37297. readonly name: string;
  37298. /**
  37299. * The easing function used by animations
  37300. */
  37301. static EasingFunction: BackEase;
  37302. /**
  37303. * The easing mode used by animations
  37304. */
  37305. static EasingMode: number;
  37306. /**
  37307. * The duration of the animation, in milliseconds
  37308. */
  37309. transitionDuration: number;
  37310. /**
  37311. * Length of the distance animated by the transition when lower radius is reached
  37312. */
  37313. lowerRadiusTransitionRange: number;
  37314. /**
  37315. * Length of the distance animated by the transition when upper radius is reached
  37316. */
  37317. upperRadiusTransitionRange: number;
  37318. private _autoTransitionRange;
  37319. /**
  37320. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37321. */
  37322. /**
  37323. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37324. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37325. */
  37326. autoTransitionRange: boolean;
  37327. private _attachedCamera;
  37328. private _onAfterCheckInputsObserver;
  37329. private _onMeshTargetChangedObserver;
  37330. /**
  37331. * Initializes the behavior.
  37332. */
  37333. init(): void;
  37334. /**
  37335. * Attaches the behavior to its arc rotate camera.
  37336. * @param camera Defines the camera to attach the behavior to
  37337. */
  37338. attach(camera: ArcRotateCamera): void;
  37339. /**
  37340. * Detaches the behavior from its current arc rotate camera.
  37341. */
  37342. detach(): void;
  37343. private _radiusIsAnimating;
  37344. private _radiusBounceTransition;
  37345. private _animatables;
  37346. private _cachedWheelPrecision;
  37347. /**
  37348. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37349. * @param radiusLimit The limit to check against.
  37350. * @return Bool to indicate if at limit.
  37351. */
  37352. private _isRadiusAtLimit;
  37353. /**
  37354. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37355. * @param radiusDelta The delta by which to animate to. Can be negative.
  37356. */
  37357. private _applyBoundRadiusAnimation;
  37358. /**
  37359. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37360. */
  37361. protected _clearAnimationLocks(): void;
  37362. /**
  37363. * Stops and removes all animations that have been applied to the camera
  37364. */
  37365. stopAllAnimations(): void;
  37366. }
  37367. }
  37368. declare module BABYLON {
  37369. /**
  37370. * 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.
  37371. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37372. */
  37373. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37374. /**
  37375. * Gets the name of the behavior.
  37376. */
  37377. readonly name: string;
  37378. private _mode;
  37379. private _radiusScale;
  37380. private _positionScale;
  37381. private _defaultElevation;
  37382. private _elevationReturnTime;
  37383. private _elevationReturnWaitTime;
  37384. private _zoomStopsAnimation;
  37385. private _framingTime;
  37386. /**
  37387. * The easing function used by animations
  37388. */
  37389. static EasingFunction: ExponentialEase;
  37390. /**
  37391. * The easing mode used by animations
  37392. */
  37393. static EasingMode: number;
  37394. /**
  37395. * Sets the current mode used by the behavior
  37396. */
  37397. /**
  37398. * Gets current mode used by the behavior.
  37399. */
  37400. mode: number;
  37401. /**
  37402. * Sets the scale applied to the radius (1 by default)
  37403. */
  37404. /**
  37405. * Gets the scale applied to the radius
  37406. */
  37407. radiusScale: number;
  37408. /**
  37409. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37410. */
  37411. /**
  37412. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37413. */
  37414. positionScale: number;
  37415. /**
  37416. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37417. * behaviour is triggered, in radians.
  37418. */
  37419. /**
  37420. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37421. * behaviour is triggered, in radians.
  37422. */
  37423. defaultElevation: number;
  37424. /**
  37425. * Sets the time (in milliseconds) taken to return to the default beta position.
  37426. * Negative value indicates camera should not return to default.
  37427. */
  37428. /**
  37429. * Gets the time (in milliseconds) taken to return to the default beta position.
  37430. * Negative value indicates camera should not return to default.
  37431. */
  37432. elevationReturnTime: number;
  37433. /**
  37434. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37435. */
  37436. /**
  37437. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37438. */
  37439. elevationReturnWaitTime: number;
  37440. /**
  37441. * Sets the flag that indicates if user zooming should stop animation.
  37442. */
  37443. /**
  37444. * Gets the flag that indicates if user zooming should stop animation.
  37445. */
  37446. zoomStopsAnimation: boolean;
  37447. /**
  37448. * Sets the transition time when framing the mesh, in milliseconds
  37449. */
  37450. /**
  37451. * Gets the transition time when framing the mesh, in milliseconds
  37452. */
  37453. framingTime: number;
  37454. /**
  37455. * Define if the behavior should automatically change the configured
  37456. * camera limits and sensibilities.
  37457. */
  37458. autoCorrectCameraLimitsAndSensibility: boolean;
  37459. private _onPrePointerObservableObserver;
  37460. private _onAfterCheckInputsObserver;
  37461. private _onMeshTargetChangedObserver;
  37462. private _attachedCamera;
  37463. private _isPointerDown;
  37464. private _lastInteractionTime;
  37465. /**
  37466. * Initializes the behavior.
  37467. */
  37468. init(): void;
  37469. /**
  37470. * Attaches the behavior to its arc rotate camera.
  37471. * @param camera Defines the camera to attach the behavior to
  37472. */
  37473. attach(camera: ArcRotateCamera): void;
  37474. /**
  37475. * Detaches the behavior from its current arc rotate camera.
  37476. */
  37477. detach(): void;
  37478. private _animatables;
  37479. private _betaIsAnimating;
  37480. private _betaTransition;
  37481. private _radiusTransition;
  37482. private _vectorTransition;
  37483. /**
  37484. * Targets the given mesh and updates zoom level accordingly.
  37485. * @param mesh The mesh to target.
  37486. * @param radius Optional. If a cached radius position already exists, overrides default.
  37487. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37488. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37489. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37490. */
  37491. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37492. /**
  37493. * Targets the given mesh with its children and updates zoom level accordingly.
  37494. * @param mesh The mesh to target.
  37495. * @param radius Optional. If a cached radius position already exists, overrides default.
  37496. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37497. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37498. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37499. */
  37500. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37501. /**
  37502. * Targets the given meshes with their children and updates zoom level accordingly.
  37503. * @param meshes The mesh to target.
  37504. * @param radius Optional. If a cached radius position already exists, overrides default.
  37505. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37506. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37507. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37508. */
  37509. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37510. /**
  37511. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37512. * @param minimumWorld Determines the smaller position of the bounding box extend
  37513. * @param maximumWorld Determines the bigger position of the bounding box extend
  37514. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37515. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37516. */
  37517. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37518. /**
  37519. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37520. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37521. * frustum width.
  37522. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37523. * to fully enclose the mesh in the viewing frustum.
  37524. */
  37525. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37526. /**
  37527. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37528. * is automatically returned to its default position (expected to be above ground plane).
  37529. */
  37530. private _maintainCameraAboveGround;
  37531. /**
  37532. * Returns the frustum slope based on the canvas ratio and camera FOV
  37533. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37534. */
  37535. private _getFrustumSlope;
  37536. /**
  37537. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37538. */
  37539. private _clearAnimationLocks;
  37540. /**
  37541. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37542. */
  37543. private _applyUserInteraction;
  37544. /**
  37545. * Stops and removes all animations that have been applied to the camera
  37546. */
  37547. stopAllAnimations(): void;
  37548. /**
  37549. * Gets a value indicating if the user is moving the camera
  37550. */
  37551. readonly isUserIsMoving: boolean;
  37552. /**
  37553. * The camera can move all the way towards the mesh.
  37554. */
  37555. static IgnoreBoundsSizeMode: number;
  37556. /**
  37557. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37558. */
  37559. static FitFrustumSidesMode: number;
  37560. }
  37561. }
  37562. declare module BABYLON {
  37563. /**
  37564. * Base class for Camera Pointer Inputs.
  37565. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37566. * for example usage.
  37567. */
  37568. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37569. /**
  37570. * Defines the camera the input is attached to.
  37571. */
  37572. abstract camera: Camera;
  37573. /**
  37574. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37575. */
  37576. protected _altKey: boolean;
  37577. protected _ctrlKey: boolean;
  37578. protected _metaKey: boolean;
  37579. protected _shiftKey: boolean;
  37580. /**
  37581. * Which mouse buttons were pressed at time of last mouse event.
  37582. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37583. */
  37584. protected _buttonsPressed: number;
  37585. /**
  37586. * Defines the buttons associated with the input to handle camera move.
  37587. */
  37588. buttons: number[];
  37589. /**
  37590. * Attach the input controls to a specific dom element to get the input from.
  37591. * @param element Defines the element the controls should be listened from
  37592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37593. */
  37594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37595. /**
  37596. * Detach the current controls from the specified dom element.
  37597. * @param element Defines the element to stop listening the inputs from
  37598. */
  37599. detachControl(element: Nullable<HTMLElement>): void;
  37600. /**
  37601. * Gets the class name of the current input.
  37602. * @returns the class name
  37603. */
  37604. getClassName(): string;
  37605. /**
  37606. * Get the friendly name associated with the input class.
  37607. * @returns the input friendly name
  37608. */
  37609. getSimpleName(): string;
  37610. /**
  37611. * Called on pointer POINTERDOUBLETAP event.
  37612. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37613. */
  37614. protected onDoubleTap(type: string): void;
  37615. /**
  37616. * Called on pointer POINTERMOVE event if only a single touch is active.
  37617. * Override this method to provide functionality.
  37618. */
  37619. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37620. /**
  37621. * Called on pointer POINTERMOVE event if multiple touches are active.
  37622. * Override this method to provide functionality.
  37623. */
  37624. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37625. /**
  37626. * Called on JS contextmenu event.
  37627. * Override this method to provide functionality.
  37628. */
  37629. protected onContextMenu(evt: PointerEvent): void;
  37630. /**
  37631. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37632. * press.
  37633. * Override this method to provide functionality.
  37634. */
  37635. protected onButtonDown(evt: PointerEvent): void;
  37636. /**
  37637. * Called each time a new POINTERUP event occurs. Ie, for each button
  37638. * release.
  37639. * Override this method to provide functionality.
  37640. */
  37641. protected onButtonUp(evt: PointerEvent): void;
  37642. /**
  37643. * Called when window becomes inactive.
  37644. * Override this method to provide functionality.
  37645. */
  37646. protected onLostFocus(): void;
  37647. private _pointerInput;
  37648. private _observer;
  37649. private _onLostFocus;
  37650. private pointA;
  37651. private pointB;
  37652. }
  37653. }
  37654. declare module BABYLON {
  37655. /**
  37656. * Manage the pointers inputs to control an arc rotate camera.
  37657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37658. */
  37659. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37660. /**
  37661. * Defines the camera the input is attached to.
  37662. */
  37663. camera: ArcRotateCamera;
  37664. /**
  37665. * Gets the class name of the current input.
  37666. * @returns the class name
  37667. */
  37668. getClassName(): string;
  37669. /**
  37670. * Defines the buttons associated with the input to handle camera move.
  37671. */
  37672. buttons: number[];
  37673. /**
  37674. * Defines the pointer angular sensibility along the X axis or how fast is
  37675. * the camera rotating.
  37676. */
  37677. angularSensibilityX: number;
  37678. /**
  37679. * Defines the pointer angular sensibility along the Y axis or how fast is
  37680. * the camera rotating.
  37681. */
  37682. angularSensibilityY: number;
  37683. /**
  37684. * Defines the pointer pinch precision or how fast is the camera zooming.
  37685. */
  37686. pinchPrecision: number;
  37687. /**
  37688. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37689. * from 0.
  37690. * It defines the percentage of current camera.radius to use as delta when
  37691. * pinch zoom is used.
  37692. */
  37693. pinchDeltaPercentage: number;
  37694. /**
  37695. * Defines the pointer panning sensibility or how fast is the camera moving.
  37696. */
  37697. panningSensibility: number;
  37698. /**
  37699. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37700. */
  37701. multiTouchPanning: boolean;
  37702. /**
  37703. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37704. * zoom (pinch) through multitouch.
  37705. */
  37706. multiTouchPanAndZoom: boolean;
  37707. /**
  37708. * Revers pinch action direction.
  37709. */
  37710. pinchInwards: boolean;
  37711. private _isPanClick;
  37712. private _twoFingerActivityCount;
  37713. private _isPinching;
  37714. /**
  37715. * Called on pointer POINTERMOVE event if only a single touch is active.
  37716. */
  37717. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37718. /**
  37719. * Called on pointer POINTERDOUBLETAP event.
  37720. */
  37721. protected onDoubleTap(type: string): void;
  37722. /**
  37723. * Called on pointer POINTERMOVE event if multiple touches are active.
  37724. */
  37725. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37726. /**
  37727. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37728. * press.
  37729. */
  37730. protected onButtonDown(evt: PointerEvent): void;
  37731. /**
  37732. * Called each time a new POINTERUP event occurs. Ie, for each button
  37733. * release.
  37734. */
  37735. protected onButtonUp(evt: PointerEvent): void;
  37736. /**
  37737. * Called when window becomes inactive.
  37738. */
  37739. protected onLostFocus(): void;
  37740. }
  37741. }
  37742. declare module BABYLON {
  37743. /**
  37744. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37746. */
  37747. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37748. /**
  37749. * Defines the camera the input is attached to.
  37750. */
  37751. camera: ArcRotateCamera;
  37752. /**
  37753. * Defines the list of key codes associated with the up action (increase alpha)
  37754. */
  37755. keysUp: number[];
  37756. /**
  37757. * Defines the list of key codes associated with the down action (decrease alpha)
  37758. */
  37759. keysDown: number[];
  37760. /**
  37761. * Defines the list of key codes associated with the left action (increase beta)
  37762. */
  37763. keysLeft: number[];
  37764. /**
  37765. * Defines the list of key codes associated with the right action (decrease beta)
  37766. */
  37767. keysRight: number[];
  37768. /**
  37769. * Defines the list of key codes associated with the reset action.
  37770. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37771. */
  37772. keysReset: number[];
  37773. /**
  37774. * Defines the panning sensibility of the inputs.
  37775. * (How fast is the camera paning)
  37776. */
  37777. panningSensibility: number;
  37778. /**
  37779. * Defines the zooming sensibility of the inputs.
  37780. * (How fast is the camera zooming)
  37781. */
  37782. zoomingSensibility: number;
  37783. /**
  37784. * Defines wether maintaining the alt key down switch the movement mode from
  37785. * orientation to zoom.
  37786. */
  37787. useAltToZoom: boolean;
  37788. /**
  37789. * Rotation speed of the camera
  37790. */
  37791. angularSpeed: number;
  37792. private _keys;
  37793. private _ctrlPressed;
  37794. private _altPressed;
  37795. private _onCanvasBlurObserver;
  37796. private _onKeyboardObserver;
  37797. private _engine;
  37798. private _scene;
  37799. /**
  37800. * Attach the input controls to a specific dom element to get the input from.
  37801. * @param element Defines the element the controls should be listened from
  37802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37803. */
  37804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37805. /**
  37806. * Detach the current controls from the specified dom element.
  37807. * @param element Defines the element to stop listening the inputs from
  37808. */
  37809. detachControl(element: Nullable<HTMLElement>): void;
  37810. /**
  37811. * Update the current camera state depending on the inputs that have been used this frame.
  37812. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37813. */
  37814. checkInputs(): void;
  37815. /**
  37816. * Gets the class name of the current intput.
  37817. * @returns the class name
  37818. */
  37819. getClassName(): string;
  37820. /**
  37821. * Get the friendly name associated with the input class.
  37822. * @returns the input friendly name
  37823. */
  37824. getSimpleName(): string;
  37825. }
  37826. }
  37827. declare module BABYLON {
  37828. /**
  37829. * Manage the mouse wheel inputs to control an arc rotate camera.
  37830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37831. */
  37832. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37833. /**
  37834. * Defines the camera the input is attached to.
  37835. */
  37836. camera: ArcRotateCamera;
  37837. /**
  37838. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37839. */
  37840. wheelPrecision: number;
  37841. /**
  37842. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37843. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37844. */
  37845. wheelDeltaPercentage: number;
  37846. private _wheel;
  37847. private _observer;
  37848. private computeDeltaFromMouseWheelLegacyEvent;
  37849. /**
  37850. * Attach the input controls to a specific dom element to get the input from.
  37851. * @param element Defines the element the controls should be listened from
  37852. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37853. */
  37854. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37855. /**
  37856. * Detach the current controls from the specified dom element.
  37857. * @param element Defines the element to stop listening the inputs from
  37858. */
  37859. detachControl(element: Nullable<HTMLElement>): void;
  37860. /**
  37861. * Gets the class name of the current intput.
  37862. * @returns the class name
  37863. */
  37864. getClassName(): string;
  37865. /**
  37866. * Get the friendly name associated with the input class.
  37867. * @returns the input friendly name
  37868. */
  37869. getSimpleName(): string;
  37870. }
  37871. }
  37872. declare module BABYLON {
  37873. /**
  37874. * Default Inputs manager for the ArcRotateCamera.
  37875. * It groups all the default supported inputs for ease of use.
  37876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37877. */
  37878. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37879. /**
  37880. * Instantiates a new ArcRotateCameraInputsManager.
  37881. * @param camera Defines the camera the inputs belong to
  37882. */
  37883. constructor(camera: ArcRotateCamera);
  37884. /**
  37885. * Add mouse wheel input support to the input manager.
  37886. * @returns the current input manager
  37887. */
  37888. addMouseWheel(): ArcRotateCameraInputsManager;
  37889. /**
  37890. * Add pointers input support to the input manager.
  37891. * @returns the current input manager
  37892. */
  37893. addPointers(): ArcRotateCameraInputsManager;
  37894. /**
  37895. * Add keyboard input support to the input manager.
  37896. * @returns the current input manager
  37897. */
  37898. addKeyboard(): ArcRotateCameraInputsManager;
  37899. }
  37900. }
  37901. declare module BABYLON {
  37902. /**
  37903. * This represents an orbital type of camera.
  37904. *
  37905. * 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.
  37906. * 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.
  37907. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37908. */
  37909. export class ArcRotateCamera extends TargetCamera {
  37910. /**
  37911. * Defines the rotation angle of the camera along the longitudinal axis.
  37912. */
  37913. alpha: number;
  37914. /**
  37915. * Defines the rotation angle of the camera along the latitudinal axis.
  37916. */
  37917. beta: number;
  37918. /**
  37919. * Defines the radius of the camera from it s target point.
  37920. */
  37921. radius: number;
  37922. protected _target: Vector3;
  37923. protected _targetHost: Nullable<AbstractMesh>;
  37924. /**
  37925. * Defines the target point of the camera.
  37926. * The camera looks towards it form the radius distance.
  37927. */
  37928. target: Vector3;
  37929. /**
  37930. * Define the current local position of the camera in the scene
  37931. */
  37932. position: Vector3;
  37933. protected _upVector: Vector3;
  37934. protected _upToYMatrix: Matrix;
  37935. protected _YToUpMatrix: Matrix;
  37936. /**
  37937. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37938. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37939. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37940. */
  37941. upVector: Vector3;
  37942. /**
  37943. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37944. */
  37945. setMatUp(): void;
  37946. /**
  37947. * Current inertia value on the longitudinal axis.
  37948. * The bigger this number the longer it will take for the camera to stop.
  37949. */
  37950. inertialAlphaOffset: number;
  37951. /**
  37952. * Current inertia value on the latitudinal axis.
  37953. * The bigger this number the longer it will take for the camera to stop.
  37954. */
  37955. inertialBetaOffset: number;
  37956. /**
  37957. * Current inertia value on the radius axis.
  37958. * The bigger this number the longer it will take for the camera to stop.
  37959. */
  37960. inertialRadiusOffset: number;
  37961. /**
  37962. * Minimum allowed angle on the longitudinal axis.
  37963. * This can help limiting how the Camera is able to move in the scene.
  37964. */
  37965. lowerAlphaLimit: Nullable<number>;
  37966. /**
  37967. * Maximum allowed angle on the longitudinal axis.
  37968. * This can help limiting how the Camera is able to move in the scene.
  37969. */
  37970. upperAlphaLimit: Nullable<number>;
  37971. /**
  37972. * Minimum allowed angle on the latitudinal axis.
  37973. * This can help limiting how the Camera is able to move in the scene.
  37974. */
  37975. lowerBetaLimit: number;
  37976. /**
  37977. * Maximum allowed angle on the latitudinal axis.
  37978. * This can help limiting how the Camera is able to move in the scene.
  37979. */
  37980. upperBetaLimit: number;
  37981. /**
  37982. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37983. * This can help limiting how the Camera is able to move in the scene.
  37984. */
  37985. lowerRadiusLimit: Nullable<number>;
  37986. /**
  37987. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37988. * This can help limiting how the Camera is able to move in the scene.
  37989. */
  37990. upperRadiusLimit: Nullable<number>;
  37991. /**
  37992. * Defines the current inertia value used during panning of the camera along the X axis.
  37993. */
  37994. inertialPanningX: number;
  37995. /**
  37996. * Defines the current inertia value used during panning of the camera along the Y axis.
  37997. */
  37998. inertialPanningY: number;
  37999. /**
  38000. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38001. * Basically if your fingers moves away from more than this distance you will be considered
  38002. * in pinch mode.
  38003. */
  38004. pinchToPanMaxDistance: number;
  38005. /**
  38006. * Defines the maximum distance the camera can pan.
  38007. * This could help keeping the cammera always in your scene.
  38008. */
  38009. panningDistanceLimit: Nullable<number>;
  38010. /**
  38011. * Defines the target of the camera before paning.
  38012. */
  38013. panningOriginTarget: Vector3;
  38014. /**
  38015. * Defines the value of the inertia used during panning.
  38016. * 0 would mean stop inertia and one would mean no decelleration at all.
  38017. */
  38018. panningInertia: number;
  38019. /**
  38020. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38021. */
  38022. angularSensibilityX: number;
  38023. /**
  38024. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38025. */
  38026. angularSensibilityY: number;
  38027. /**
  38028. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38029. */
  38030. pinchPrecision: number;
  38031. /**
  38032. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38033. * It will be used instead of pinchDeltaPrecision if different from 0.
  38034. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38035. */
  38036. pinchDeltaPercentage: number;
  38037. /**
  38038. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38039. */
  38040. panningSensibility: number;
  38041. /**
  38042. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38043. */
  38044. keysUp: number[];
  38045. /**
  38046. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38047. */
  38048. keysDown: number[];
  38049. /**
  38050. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38051. */
  38052. keysLeft: number[];
  38053. /**
  38054. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38055. */
  38056. keysRight: number[];
  38057. /**
  38058. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38059. */
  38060. wheelPrecision: number;
  38061. /**
  38062. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38063. * It will be used instead of pinchDeltaPrecision if different from 0.
  38064. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38065. */
  38066. wheelDeltaPercentage: number;
  38067. /**
  38068. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38069. */
  38070. zoomOnFactor: number;
  38071. /**
  38072. * Defines a screen offset for the camera position.
  38073. */
  38074. targetScreenOffset: Vector2;
  38075. /**
  38076. * Allows the camera to be completely reversed.
  38077. * If false the camera can not arrive upside down.
  38078. */
  38079. allowUpsideDown: boolean;
  38080. /**
  38081. * Define if double tap/click is used to restore the previously saved state of the camera.
  38082. */
  38083. useInputToRestoreState: boolean;
  38084. /** @hidden */
  38085. _viewMatrix: Matrix;
  38086. /** @hidden */
  38087. _useCtrlForPanning: boolean;
  38088. /** @hidden */
  38089. _panningMouseButton: number;
  38090. /**
  38091. * Defines the input associated to the camera.
  38092. */
  38093. inputs: ArcRotateCameraInputsManager;
  38094. /** @hidden */
  38095. _reset: () => void;
  38096. /**
  38097. * Defines the allowed panning axis.
  38098. */
  38099. panningAxis: Vector3;
  38100. protected _localDirection: Vector3;
  38101. protected _transformedDirection: Vector3;
  38102. private _bouncingBehavior;
  38103. /**
  38104. * Gets the bouncing behavior of the camera if it has been enabled.
  38105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38106. */
  38107. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38108. /**
  38109. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38110. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38111. */
  38112. useBouncingBehavior: boolean;
  38113. private _framingBehavior;
  38114. /**
  38115. * Gets the framing behavior of the camera if it has been enabled.
  38116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38117. */
  38118. readonly framingBehavior: Nullable<FramingBehavior>;
  38119. /**
  38120. * Defines if the framing behavior of the camera is enabled on the camera.
  38121. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38122. */
  38123. useFramingBehavior: boolean;
  38124. private _autoRotationBehavior;
  38125. /**
  38126. * Gets the auto rotation behavior of the camera if it has been enabled.
  38127. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38128. */
  38129. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38130. /**
  38131. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38132. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38133. */
  38134. useAutoRotationBehavior: boolean;
  38135. /**
  38136. * Observable triggered when the mesh target has been changed on the camera.
  38137. */
  38138. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38139. /**
  38140. * Event raised when the camera is colliding with a mesh.
  38141. */
  38142. onCollide: (collidedMesh: AbstractMesh) => void;
  38143. /**
  38144. * Defines whether the camera should check collision with the objects oh the scene.
  38145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38146. */
  38147. checkCollisions: boolean;
  38148. /**
  38149. * Defines the collision radius of the camera.
  38150. * This simulates a sphere around the camera.
  38151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38152. */
  38153. collisionRadius: Vector3;
  38154. protected _collider: Collider;
  38155. protected _previousPosition: Vector3;
  38156. protected _collisionVelocity: Vector3;
  38157. protected _newPosition: Vector3;
  38158. protected _previousAlpha: number;
  38159. protected _previousBeta: number;
  38160. protected _previousRadius: number;
  38161. protected _collisionTriggered: boolean;
  38162. protected _targetBoundingCenter: Nullable<Vector3>;
  38163. private _computationVector;
  38164. /**
  38165. * Instantiates a new ArcRotateCamera in a given scene
  38166. * @param name Defines the name of the camera
  38167. * @param alpha Defines the camera rotation along the logitudinal axis
  38168. * @param beta Defines the camera rotation along the latitudinal axis
  38169. * @param radius Defines the camera distance from its target
  38170. * @param target Defines the camera target
  38171. * @param scene Defines the scene the camera belongs to
  38172. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38173. */
  38174. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38175. /** @hidden */
  38176. _initCache(): void;
  38177. /** @hidden */
  38178. _updateCache(ignoreParentClass?: boolean): void;
  38179. protected _getTargetPosition(): Vector3;
  38180. private _storedAlpha;
  38181. private _storedBeta;
  38182. private _storedRadius;
  38183. private _storedTarget;
  38184. private _storedTargetScreenOffset;
  38185. /**
  38186. * Stores the current state of the camera (alpha, beta, radius and target)
  38187. * @returns the camera itself
  38188. */
  38189. storeState(): Camera;
  38190. /**
  38191. * @hidden
  38192. * Restored camera state. You must call storeState() first
  38193. */
  38194. _restoreStateValues(): boolean;
  38195. /** @hidden */
  38196. _isSynchronizedViewMatrix(): boolean;
  38197. /**
  38198. * Attached controls to the current camera.
  38199. * @param element Defines the element the controls should be listened from
  38200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38201. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38202. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38203. */
  38204. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38205. /**
  38206. * Detach the current controls from the camera.
  38207. * The camera will stop reacting to inputs.
  38208. * @param element Defines the element to stop listening the inputs from
  38209. */
  38210. detachControl(element: HTMLElement): void;
  38211. /** @hidden */
  38212. _checkInputs(): void;
  38213. protected _checkLimits(): void;
  38214. /**
  38215. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38216. */
  38217. rebuildAnglesAndRadius(): void;
  38218. /**
  38219. * Use a position to define the current camera related information like alpha, beta and radius
  38220. * @param position Defines the position to set the camera at
  38221. */
  38222. setPosition(position: Vector3): void;
  38223. /**
  38224. * Defines the target the camera should look at.
  38225. * This will automatically adapt alpha beta and radius to fit within the new target.
  38226. * @param target Defines the new target as a Vector or a mesh
  38227. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38228. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38229. */
  38230. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38231. /** @hidden */
  38232. _getViewMatrix(): Matrix;
  38233. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38234. /**
  38235. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38236. * @param meshes Defines the mesh to zoom on
  38237. * @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)
  38238. */
  38239. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38240. /**
  38241. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38242. * The target will be changed but the radius
  38243. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38244. * @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)
  38245. */
  38246. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38247. min: Vector3;
  38248. max: Vector3;
  38249. distance: number;
  38250. }, doNotUpdateMaxZ?: boolean): void;
  38251. /**
  38252. * @override
  38253. * Override Camera.createRigCamera
  38254. */
  38255. createRigCamera(name: string, cameraIndex: number): Camera;
  38256. /**
  38257. * @hidden
  38258. * @override
  38259. * Override Camera._updateRigCameras
  38260. */
  38261. _updateRigCameras(): void;
  38262. /**
  38263. * Destroy the camera and release the current resources hold by it.
  38264. */
  38265. dispose(): void;
  38266. /**
  38267. * Gets the current object class name.
  38268. * @return the class name
  38269. */
  38270. getClassName(): string;
  38271. }
  38272. }
  38273. declare module BABYLON {
  38274. /**
  38275. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38276. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38277. */
  38278. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38279. /**
  38280. * Gets the name of the behavior.
  38281. */
  38282. readonly name: string;
  38283. private _zoomStopsAnimation;
  38284. private _idleRotationSpeed;
  38285. private _idleRotationWaitTime;
  38286. private _idleRotationSpinupTime;
  38287. /**
  38288. * Sets the flag that indicates if user zooming should stop animation.
  38289. */
  38290. /**
  38291. * Gets the flag that indicates if user zooming should stop animation.
  38292. */
  38293. zoomStopsAnimation: boolean;
  38294. /**
  38295. * Sets the default speed at which the camera rotates around the model.
  38296. */
  38297. /**
  38298. * Gets the default speed at which the camera rotates around the model.
  38299. */
  38300. idleRotationSpeed: number;
  38301. /**
  38302. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38303. */
  38304. /**
  38305. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38306. */
  38307. idleRotationWaitTime: number;
  38308. /**
  38309. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38310. */
  38311. /**
  38312. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38313. */
  38314. idleRotationSpinupTime: number;
  38315. /**
  38316. * Gets a value indicating if the camera is currently rotating because of this behavior
  38317. */
  38318. readonly rotationInProgress: boolean;
  38319. private _onPrePointerObservableObserver;
  38320. private _onAfterCheckInputsObserver;
  38321. private _attachedCamera;
  38322. private _isPointerDown;
  38323. private _lastFrameTime;
  38324. private _lastInteractionTime;
  38325. private _cameraRotationSpeed;
  38326. /**
  38327. * Initializes the behavior.
  38328. */
  38329. init(): void;
  38330. /**
  38331. * Attaches the behavior to its arc rotate camera.
  38332. * @param camera Defines the camera to attach the behavior to
  38333. */
  38334. attach(camera: ArcRotateCamera): void;
  38335. /**
  38336. * Detaches the behavior from its current arc rotate camera.
  38337. */
  38338. detach(): void;
  38339. /**
  38340. * Returns true if user is scrolling.
  38341. * @return true if user is scrolling.
  38342. */
  38343. private _userIsZooming;
  38344. private _lastFrameRadius;
  38345. private _shouldAnimationStopForInteraction;
  38346. /**
  38347. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38348. */
  38349. private _applyUserInteraction;
  38350. private _userIsMoving;
  38351. }
  38352. }
  38353. declare module BABYLON {
  38354. /**
  38355. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38356. */
  38357. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38358. private ui;
  38359. /**
  38360. * The name of the behavior
  38361. */
  38362. name: string;
  38363. /**
  38364. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38365. */
  38366. distanceAwayFromFace: number;
  38367. /**
  38368. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38369. */
  38370. distanceAwayFromBottomOfFace: number;
  38371. private _faceVectors;
  38372. private _target;
  38373. private _scene;
  38374. private _onRenderObserver;
  38375. private _tmpMatrix;
  38376. private _tmpVector;
  38377. /**
  38378. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38379. * @param ui The transform node that should be attched to the mesh
  38380. */
  38381. constructor(ui: TransformNode);
  38382. /**
  38383. * Initializes the behavior
  38384. */
  38385. init(): void;
  38386. private _closestFace;
  38387. private _zeroVector;
  38388. private _lookAtTmpMatrix;
  38389. private _lookAtToRef;
  38390. /**
  38391. * Attaches the AttachToBoxBehavior to the passed in mesh
  38392. * @param target The mesh that the specified node will be attached to
  38393. */
  38394. attach(target: Mesh): void;
  38395. /**
  38396. * Detaches the behavior from the mesh
  38397. */
  38398. detach(): void;
  38399. }
  38400. }
  38401. declare module BABYLON {
  38402. /**
  38403. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38404. */
  38405. export class FadeInOutBehavior implements Behavior<Mesh> {
  38406. /**
  38407. * Time in milliseconds to delay before fading in (Default: 0)
  38408. */
  38409. delay: number;
  38410. /**
  38411. * Time in milliseconds for the mesh to fade in (Default: 300)
  38412. */
  38413. fadeInTime: number;
  38414. private _millisecondsPerFrame;
  38415. private _hovered;
  38416. private _hoverValue;
  38417. private _ownerNode;
  38418. /**
  38419. * Instatiates the FadeInOutBehavior
  38420. */
  38421. constructor();
  38422. /**
  38423. * The name of the behavior
  38424. */
  38425. readonly name: string;
  38426. /**
  38427. * Initializes the behavior
  38428. */
  38429. init(): void;
  38430. /**
  38431. * Attaches the fade behavior on the passed in mesh
  38432. * @param ownerNode The mesh that will be faded in/out once attached
  38433. */
  38434. attach(ownerNode: Mesh): void;
  38435. /**
  38436. * Detaches the behavior from the mesh
  38437. */
  38438. detach(): void;
  38439. /**
  38440. * Triggers the mesh to begin fading in or out
  38441. * @param value if the object should fade in or out (true to fade in)
  38442. */
  38443. fadeIn(value: boolean): void;
  38444. private _update;
  38445. private _setAllVisibility;
  38446. }
  38447. }
  38448. declare module BABYLON {
  38449. /**
  38450. * Class containing a set of static utilities functions for managing Pivots
  38451. * @hidden
  38452. */
  38453. export class PivotTools {
  38454. private static _PivotCached;
  38455. private static _OldPivotPoint;
  38456. private static _PivotTranslation;
  38457. private static _PivotTmpVector;
  38458. /** @hidden */
  38459. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38460. /** @hidden */
  38461. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38462. }
  38463. }
  38464. declare module BABYLON {
  38465. /**
  38466. * Class containing static functions to help procedurally build meshes
  38467. */
  38468. export class PlaneBuilder {
  38469. /**
  38470. * Creates a plane mesh
  38471. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38472. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38473. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38475. * * 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
  38476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38477. * @param name defines the name of the mesh
  38478. * @param options defines the options used to create the mesh
  38479. * @param scene defines the hosting scene
  38480. * @returns the plane mesh
  38481. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38482. */
  38483. static CreatePlane(name: string, options: {
  38484. size?: number;
  38485. width?: number;
  38486. height?: number;
  38487. sideOrientation?: number;
  38488. frontUVs?: Vector4;
  38489. backUVs?: Vector4;
  38490. updatable?: boolean;
  38491. sourcePlane?: Plane;
  38492. }, scene?: Nullable<Scene>): Mesh;
  38493. }
  38494. }
  38495. declare module BABYLON {
  38496. /**
  38497. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38498. */
  38499. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38500. private static _AnyMouseID;
  38501. /**
  38502. * Abstract mesh the behavior is set on
  38503. */
  38504. attachedNode: AbstractMesh;
  38505. private _dragPlane;
  38506. private _scene;
  38507. private _pointerObserver;
  38508. private _beforeRenderObserver;
  38509. private static _planeScene;
  38510. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38511. /**
  38512. * 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)
  38513. */
  38514. maxDragAngle: number;
  38515. /**
  38516. * @hidden
  38517. */
  38518. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38519. /**
  38520. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38521. */
  38522. currentDraggingPointerID: number;
  38523. /**
  38524. * The last position where the pointer hit the drag plane in world space
  38525. */
  38526. lastDragPosition: Vector3;
  38527. /**
  38528. * If the behavior is currently in a dragging state
  38529. */
  38530. dragging: boolean;
  38531. /**
  38532. * 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)
  38533. */
  38534. dragDeltaRatio: number;
  38535. /**
  38536. * If the drag plane orientation should be updated during the dragging (Default: true)
  38537. */
  38538. updateDragPlane: boolean;
  38539. private _debugMode;
  38540. private _moving;
  38541. /**
  38542. * Fires each time the attached mesh is dragged with the pointer
  38543. * * delta between last drag position and current drag position in world space
  38544. * * dragDistance along the drag axis
  38545. * * dragPlaneNormal normal of the current drag plane used during the drag
  38546. * * dragPlanePoint in world space where the drag intersects the drag plane
  38547. */
  38548. onDragObservable: Observable<{
  38549. delta: Vector3;
  38550. dragPlanePoint: Vector3;
  38551. dragPlaneNormal: Vector3;
  38552. dragDistance: number;
  38553. pointerId: number;
  38554. }>;
  38555. /**
  38556. * Fires each time a drag begins (eg. mouse down on mesh)
  38557. */
  38558. onDragStartObservable: Observable<{
  38559. dragPlanePoint: Vector3;
  38560. pointerId: number;
  38561. }>;
  38562. /**
  38563. * Fires each time a drag ends (eg. mouse release after drag)
  38564. */
  38565. onDragEndObservable: Observable<{
  38566. dragPlanePoint: Vector3;
  38567. pointerId: number;
  38568. }>;
  38569. /**
  38570. * If the attached mesh should be moved when dragged
  38571. */
  38572. moveAttached: boolean;
  38573. /**
  38574. * If the drag behavior will react to drag events (Default: true)
  38575. */
  38576. enabled: boolean;
  38577. /**
  38578. * If pointer events should start and release the drag (Default: true)
  38579. */
  38580. startAndReleaseDragOnPointerEvents: boolean;
  38581. /**
  38582. * If camera controls should be detached during the drag
  38583. */
  38584. detachCameraControls: boolean;
  38585. /**
  38586. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38587. */
  38588. useObjectOrienationForDragging: boolean;
  38589. private _options;
  38590. /**
  38591. * Gets the options used by the behavior
  38592. */
  38593. /**
  38594. * Sets the options used by the behavior
  38595. */
  38596. options: {
  38597. dragAxis?: Vector3;
  38598. dragPlaneNormal?: Vector3;
  38599. };
  38600. /**
  38601. * Creates a pointer drag behavior that can be attached to a mesh
  38602. * @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)
  38603. */
  38604. constructor(options?: {
  38605. dragAxis?: Vector3;
  38606. dragPlaneNormal?: Vector3;
  38607. });
  38608. /**
  38609. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38610. */
  38611. validateDrag: (targetPosition: Vector3) => boolean;
  38612. /**
  38613. * The name of the behavior
  38614. */
  38615. readonly name: string;
  38616. /**
  38617. * Initializes the behavior
  38618. */
  38619. init(): void;
  38620. private _tmpVector;
  38621. private _alternatePickedPoint;
  38622. private _worldDragAxis;
  38623. private _targetPosition;
  38624. private _attachedElement;
  38625. /**
  38626. * Attaches the drag behavior the passed in mesh
  38627. * @param ownerNode The mesh that will be dragged around once attached
  38628. * @param predicate Predicate to use for pick filtering
  38629. */
  38630. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38631. /**
  38632. * Force relase the drag action by code.
  38633. */
  38634. releaseDrag(): void;
  38635. private _startDragRay;
  38636. private _lastPointerRay;
  38637. /**
  38638. * Simulates the start of a pointer drag event on the behavior
  38639. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38640. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38641. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38642. */
  38643. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38644. private _startDrag;
  38645. private _dragDelta;
  38646. private _moveDrag;
  38647. private _pickWithRayOnDragPlane;
  38648. private _pointA;
  38649. private _pointB;
  38650. private _pointC;
  38651. private _lineA;
  38652. private _lineB;
  38653. private _localAxis;
  38654. private _lookAt;
  38655. private _updateDragPlanePosition;
  38656. /**
  38657. * Detaches the behavior from the mesh
  38658. */
  38659. detach(): void;
  38660. }
  38661. }
  38662. declare module BABYLON {
  38663. /**
  38664. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38665. */
  38666. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38667. private _dragBehaviorA;
  38668. private _dragBehaviorB;
  38669. private _startDistance;
  38670. private _initialScale;
  38671. private _targetScale;
  38672. private _ownerNode;
  38673. private _sceneRenderObserver;
  38674. /**
  38675. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38676. */
  38677. constructor();
  38678. /**
  38679. * The name of the behavior
  38680. */
  38681. readonly name: string;
  38682. /**
  38683. * Initializes the behavior
  38684. */
  38685. init(): void;
  38686. private _getCurrentDistance;
  38687. /**
  38688. * Attaches the scale behavior the passed in mesh
  38689. * @param ownerNode The mesh that will be scaled around once attached
  38690. */
  38691. attach(ownerNode: Mesh): void;
  38692. /**
  38693. * Detaches the behavior from the mesh
  38694. */
  38695. detach(): void;
  38696. }
  38697. }
  38698. declare module BABYLON {
  38699. /**
  38700. * 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
  38701. */
  38702. export class SixDofDragBehavior implements Behavior<Mesh> {
  38703. private static _virtualScene;
  38704. private _ownerNode;
  38705. private _sceneRenderObserver;
  38706. private _scene;
  38707. private _targetPosition;
  38708. private _virtualOriginMesh;
  38709. private _virtualDragMesh;
  38710. private _pointerObserver;
  38711. private _moving;
  38712. private _startingOrientation;
  38713. /**
  38714. * 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)
  38715. */
  38716. private zDragFactor;
  38717. /**
  38718. * If the object should rotate to face the drag origin
  38719. */
  38720. rotateDraggedObject: boolean;
  38721. /**
  38722. * If the behavior is currently in a dragging state
  38723. */
  38724. dragging: boolean;
  38725. /**
  38726. * 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)
  38727. */
  38728. dragDeltaRatio: number;
  38729. /**
  38730. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38731. */
  38732. currentDraggingPointerID: number;
  38733. /**
  38734. * If camera controls should be detached during the drag
  38735. */
  38736. detachCameraControls: boolean;
  38737. /**
  38738. * Fires each time a drag starts
  38739. */
  38740. onDragStartObservable: Observable<{}>;
  38741. /**
  38742. * Fires each time a drag ends (eg. mouse release after drag)
  38743. */
  38744. onDragEndObservable: Observable<{}>;
  38745. /**
  38746. * 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
  38747. */
  38748. constructor();
  38749. /**
  38750. * The name of the behavior
  38751. */
  38752. readonly name: string;
  38753. /**
  38754. * Initializes the behavior
  38755. */
  38756. init(): void;
  38757. /**
  38758. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38759. */
  38760. private readonly _pointerCamera;
  38761. /**
  38762. * Attaches the scale behavior the passed in mesh
  38763. * @param ownerNode The mesh that will be scaled around once attached
  38764. */
  38765. attach(ownerNode: Mesh): void;
  38766. /**
  38767. * Detaches the behavior from the mesh
  38768. */
  38769. detach(): void;
  38770. }
  38771. }
  38772. declare module BABYLON {
  38773. /**
  38774. * Class used to apply inverse kinematics to bones
  38775. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38776. */
  38777. export class BoneIKController {
  38778. private static _tmpVecs;
  38779. private static _tmpQuat;
  38780. private static _tmpMats;
  38781. /**
  38782. * Gets or sets the target mesh
  38783. */
  38784. targetMesh: AbstractMesh;
  38785. /** Gets or sets the mesh used as pole */
  38786. poleTargetMesh: AbstractMesh;
  38787. /**
  38788. * Gets or sets the bone used as pole
  38789. */
  38790. poleTargetBone: Nullable<Bone>;
  38791. /**
  38792. * Gets or sets the target position
  38793. */
  38794. targetPosition: Vector3;
  38795. /**
  38796. * Gets or sets the pole target position
  38797. */
  38798. poleTargetPosition: Vector3;
  38799. /**
  38800. * Gets or sets the pole target local offset
  38801. */
  38802. poleTargetLocalOffset: Vector3;
  38803. /**
  38804. * Gets or sets the pole angle
  38805. */
  38806. poleAngle: number;
  38807. /**
  38808. * Gets or sets the mesh associated with the controller
  38809. */
  38810. mesh: AbstractMesh;
  38811. /**
  38812. * 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)
  38813. */
  38814. slerpAmount: number;
  38815. private _bone1Quat;
  38816. private _bone1Mat;
  38817. private _bone2Ang;
  38818. private _bone1;
  38819. private _bone2;
  38820. private _bone1Length;
  38821. private _bone2Length;
  38822. private _maxAngle;
  38823. private _maxReach;
  38824. private _rightHandedSystem;
  38825. private _bendAxis;
  38826. private _slerping;
  38827. private _adjustRoll;
  38828. /**
  38829. * Gets or sets maximum allowed angle
  38830. */
  38831. maxAngle: number;
  38832. /**
  38833. * Creates a new BoneIKController
  38834. * @param mesh defines the mesh to control
  38835. * @param bone defines the bone to control
  38836. * @param options defines options to set up the controller
  38837. */
  38838. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38839. targetMesh?: AbstractMesh;
  38840. poleTargetMesh?: AbstractMesh;
  38841. poleTargetBone?: Bone;
  38842. poleTargetLocalOffset?: Vector3;
  38843. poleAngle?: number;
  38844. bendAxis?: Vector3;
  38845. maxAngle?: number;
  38846. slerpAmount?: number;
  38847. });
  38848. private _setMaxAngle;
  38849. /**
  38850. * Force the controller to update the bones
  38851. */
  38852. update(): void;
  38853. }
  38854. }
  38855. declare module BABYLON {
  38856. /**
  38857. * Class used to make a bone look toward a point in space
  38858. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38859. */
  38860. export class BoneLookController {
  38861. private static _tmpVecs;
  38862. private static _tmpQuat;
  38863. private static _tmpMats;
  38864. /**
  38865. * The target Vector3 that the bone will look at
  38866. */
  38867. target: Vector3;
  38868. /**
  38869. * The mesh that the bone is attached to
  38870. */
  38871. mesh: AbstractMesh;
  38872. /**
  38873. * The bone that will be looking to the target
  38874. */
  38875. bone: Bone;
  38876. /**
  38877. * The up axis of the coordinate system that is used when the bone is rotated
  38878. */
  38879. upAxis: Vector3;
  38880. /**
  38881. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38882. */
  38883. upAxisSpace: Space;
  38884. /**
  38885. * Used to make an adjustment to the yaw of the bone
  38886. */
  38887. adjustYaw: number;
  38888. /**
  38889. * Used to make an adjustment to the pitch of the bone
  38890. */
  38891. adjustPitch: number;
  38892. /**
  38893. * Used to make an adjustment to the roll of the bone
  38894. */
  38895. adjustRoll: number;
  38896. /**
  38897. * 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)
  38898. */
  38899. slerpAmount: number;
  38900. private _minYaw;
  38901. private _maxYaw;
  38902. private _minPitch;
  38903. private _maxPitch;
  38904. private _minYawSin;
  38905. private _minYawCos;
  38906. private _maxYawSin;
  38907. private _maxYawCos;
  38908. private _midYawConstraint;
  38909. private _minPitchTan;
  38910. private _maxPitchTan;
  38911. private _boneQuat;
  38912. private _slerping;
  38913. private _transformYawPitch;
  38914. private _transformYawPitchInv;
  38915. private _firstFrameSkipped;
  38916. private _yawRange;
  38917. private _fowardAxis;
  38918. /**
  38919. * Gets or sets the minimum yaw angle that the bone can look to
  38920. */
  38921. minYaw: number;
  38922. /**
  38923. * Gets or sets the maximum yaw angle that the bone can look to
  38924. */
  38925. maxYaw: number;
  38926. /**
  38927. * Gets or sets the minimum pitch angle that the bone can look to
  38928. */
  38929. minPitch: number;
  38930. /**
  38931. * Gets or sets the maximum pitch angle that the bone can look to
  38932. */
  38933. maxPitch: number;
  38934. /**
  38935. * Create a BoneLookController
  38936. * @param mesh the mesh that the bone belongs to
  38937. * @param bone the bone that will be looking to the target
  38938. * @param target the target Vector3 to look at
  38939. * @param options optional settings:
  38940. * * maxYaw: the maximum angle the bone will yaw to
  38941. * * minYaw: the minimum angle the bone will yaw to
  38942. * * maxPitch: the maximum angle the bone will pitch to
  38943. * * minPitch: the minimum angle the bone will yaw to
  38944. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38945. * * upAxis: the up axis of the coordinate system
  38946. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38947. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38948. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38949. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38950. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38951. * * adjustRoll: used to make an adjustment to the roll of the bone
  38952. **/
  38953. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38954. maxYaw?: number;
  38955. minYaw?: number;
  38956. maxPitch?: number;
  38957. minPitch?: number;
  38958. slerpAmount?: number;
  38959. upAxis?: Vector3;
  38960. upAxisSpace?: Space;
  38961. yawAxis?: Vector3;
  38962. pitchAxis?: Vector3;
  38963. adjustYaw?: number;
  38964. adjustPitch?: number;
  38965. adjustRoll?: number;
  38966. });
  38967. /**
  38968. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38969. */
  38970. update(): void;
  38971. private _getAngleDiff;
  38972. private _getAngleBetween;
  38973. private _isAngleBetween;
  38974. }
  38975. }
  38976. declare module BABYLON {
  38977. /**
  38978. * Manage the gamepad inputs to control an arc rotate camera.
  38979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38980. */
  38981. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38982. /**
  38983. * Defines the camera the input is attached to.
  38984. */
  38985. camera: ArcRotateCamera;
  38986. /**
  38987. * Defines the gamepad the input is gathering event from.
  38988. */
  38989. gamepad: Nullable<Gamepad>;
  38990. /**
  38991. * Defines the gamepad rotation sensiblity.
  38992. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38993. */
  38994. gamepadRotationSensibility: number;
  38995. /**
  38996. * Defines the gamepad move sensiblity.
  38997. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38998. */
  38999. gamepadMoveSensibility: number;
  39000. private _yAxisScale;
  39001. /**
  39002. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39003. */
  39004. invertYAxis: boolean;
  39005. private _onGamepadConnectedObserver;
  39006. private _onGamepadDisconnectedObserver;
  39007. /**
  39008. * Attach the input controls to a specific dom element to get the input from.
  39009. * @param element Defines the element the controls should be listened from
  39010. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39011. */
  39012. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39013. /**
  39014. * Detach the current controls from the specified dom element.
  39015. * @param element Defines the element to stop listening the inputs from
  39016. */
  39017. detachControl(element: Nullable<HTMLElement>): void;
  39018. /**
  39019. * Update the current camera state depending on the inputs that have been used this frame.
  39020. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39021. */
  39022. checkInputs(): void;
  39023. /**
  39024. * Gets the class name of the current intput.
  39025. * @returns the class name
  39026. */
  39027. getClassName(): string;
  39028. /**
  39029. * Get the friendly name associated with the input class.
  39030. * @returns the input friendly name
  39031. */
  39032. getSimpleName(): string;
  39033. }
  39034. }
  39035. declare module BABYLON {
  39036. interface ArcRotateCameraInputsManager {
  39037. /**
  39038. * Add orientation input support to the input manager.
  39039. * @returns the current input manager
  39040. */
  39041. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39042. }
  39043. /**
  39044. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39046. */
  39047. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39048. /**
  39049. * Defines the camera the input is attached to.
  39050. */
  39051. camera: ArcRotateCamera;
  39052. /**
  39053. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39054. */
  39055. alphaCorrection: number;
  39056. /**
  39057. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39058. */
  39059. gammaCorrection: number;
  39060. private _alpha;
  39061. private _gamma;
  39062. private _dirty;
  39063. private _deviceOrientationHandler;
  39064. /**
  39065. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39066. */
  39067. constructor();
  39068. /**
  39069. * Attach the input controls to a specific dom element to get the input from.
  39070. * @param element Defines the element the controls should be listened from
  39071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39072. */
  39073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39074. /** @hidden */
  39075. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39076. /**
  39077. * Update the current camera state depending on the inputs that have been used this frame.
  39078. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39079. */
  39080. checkInputs(): void;
  39081. /**
  39082. * Detach the current controls from the specified dom element.
  39083. * @param element Defines the element to stop listening the inputs from
  39084. */
  39085. detachControl(element: Nullable<HTMLElement>): void;
  39086. /**
  39087. * Gets the class name of the current intput.
  39088. * @returns the class name
  39089. */
  39090. getClassName(): string;
  39091. /**
  39092. * Get the friendly name associated with the input class.
  39093. * @returns the input friendly name
  39094. */
  39095. getSimpleName(): string;
  39096. }
  39097. }
  39098. declare module BABYLON {
  39099. /**
  39100. * Listen to mouse events to control the camera.
  39101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39102. */
  39103. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39104. /**
  39105. * Defines the camera the input is attached to.
  39106. */
  39107. camera: FlyCamera;
  39108. /**
  39109. * Defines if touch is enabled. (Default is true.)
  39110. */
  39111. touchEnabled: boolean;
  39112. /**
  39113. * Defines the buttons associated with the input to handle camera rotation.
  39114. */
  39115. buttons: number[];
  39116. /**
  39117. * Assign buttons for Yaw control.
  39118. */
  39119. buttonsYaw: number[];
  39120. /**
  39121. * Assign buttons for Pitch control.
  39122. */
  39123. buttonsPitch: number[];
  39124. /**
  39125. * Assign buttons for Roll control.
  39126. */
  39127. buttonsRoll: number[];
  39128. /**
  39129. * Detect if any button is being pressed while mouse is moved.
  39130. * -1 = Mouse locked.
  39131. * 0 = Left button.
  39132. * 1 = Middle Button.
  39133. * 2 = Right Button.
  39134. */
  39135. activeButton: number;
  39136. /**
  39137. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39138. * Higher values reduce its sensitivity.
  39139. */
  39140. angularSensibility: number;
  39141. private _mousemoveCallback;
  39142. private _observer;
  39143. private _rollObserver;
  39144. private previousPosition;
  39145. private noPreventDefault;
  39146. private element;
  39147. /**
  39148. * Listen to mouse events to control the camera.
  39149. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39151. */
  39152. constructor(touchEnabled?: boolean);
  39153. /**
  39154. * Attach the mouse control to the HTML DOM element.
  39155. * @param element Defines the element that listens to the input events.
  39156. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39157. */
  39158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39159. /**
  39160. * Detach the current controls from the specified dom element.
  39161. * @param element Defines the element to stop listening the inputs from
  39162. */
  39163. detachControl(element: Nullable<HTMLElement>): void;
  39164. /**
  39165. * Gets the class name of the current input.
  39166. * @returns the class name.
  39167. */
  39168. getClassName(): string;
  39169. /**
  39170. * Get the friendly name associated with the input class.
  39171. * @returns the input's friendly name.
  39172. */
  39173. getSimpleName(): string;
  39174. private _pointerInput;
  39175. private _onMouseMove;
  39176. /**
  39177. * Rotate camera by mouse offset.
  39178. */
  39179. private rotateCamera;
  39180. }
  39181. }
  39182. declare module BABYLON {
  39183. /**
  39184. * Default Inputs manager for the FlyCamera.
  39185. * It groups all the default supported inputs for ease of use.
  39186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39187. */
  39188. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39189. /**
  39190. * Instantiates a new FlyCameraInputsManager.
  39191. * @param camera Defines the camera the inputs belong to.
  39192. */
  39193. constructor(camera: FlyCamera);
  39194. /**
  39195. * Add keyboard input support to the input manager.
  39196. * @returns the new FlyCameraKeyboardMoveInput().
  39197. */
  39198. addKeyboard(): FlyCameraInputsManager;
  39199. /**
  39200. * Add mouse input support to the input manager.
  39201. * @param touchEnabled Enable touch screen support.
  39202. * @returns the new FlyCameraMouseInput().
  39203. */
  39204. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39205. }
  39206. }
  39207. declare module BABYLON {
  39208. /**
  39209. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39210. * such as in a 3D Space Shooter or a Flight Simulator.
  39211. */
  39212. export class FlyCamera extends TargetCamera {
  39213. /**
  39214. * Define the collision ellipsoid of the camera.
  39215. * This is helpful for simulating a camera body, like a player's body.
  39216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39217. */
  39218. ellipsoid: Vector3;
  39219. /**
  39220. * Define an offset for the position of the ellipsoid around the camera.
  39221. * This can be helpful if the camera is attached away from the player's body center,
  39222. * such as at its head.
  39223. */
  39224. ellipsoidOffset: Vector3;
  39225. /**
  39226. * Enable or disable collisions of the camera with the rest of the scene objects.
  39227. */
  39228. checkCollisions: boolean;
  39229. /**
  39230. * Enable or disable gravity on the camera.
  39231. */
  39232. applyGravity: boolean;
  39233. /**
  39234. * Define the current direction the camera is moving to.
  39235. */
  39236. cameraDirection: Vector3;
  39237. /**
  39238. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39239. * This overrides and empties cameraRotation.
  39240. */
  39241. rotationQuaternion: Quaternion;
  39242. /**
  39243. * Track Roll to maintain the wanted Rolling when looking around.
  39244. */
  39245. _trackRoll: number;
  39246. /**
  39247. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39248. */
  39249. rollCorrect: number;
  39250. /**
  39251. * Mimic a banked turn, Rolling the camera when Yawing.
  39252. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39253. */
  39254. bankedTurn: boolean;
  39255. /**
  39256. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39257. */
  39258. bankedTurnLimit: number;
  39259. /**
  39260. * Value of 0 disables the banked Roll.
  39261. * Value of 1 is equal to the Yaw angle in radians.
  39262. */
  39263. bankedTurnMultiplier: number;
  39264. /**
  39265. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39266. */
  39267. inputs: FlyCameraInputsManager;
  39268. /**
  39269. * Gets the input sensibility for mouse input.
  39270. * Higher values reduce sensitivity.
  39271. */
  39272. /**
  39273. * Sets the input sensibility for a mouse input.
  39274. * Higher values reduce sensitivity.
  39275. */
  39276. angularSensibility: number;
  39277. /**
  39278. * Get the keys for camera movement forward.
  39279. */
  39280. /**
  39281. * Set the keys for camera movement forward.
  39282. */
  39283. keysForward: number[];
  39284. /**
  39285. * Get the keys for camera movement backward.
  39286. */
  39287. keysBackward: number[];
  39288. /**
  39289. * Get the keys for camera movement up.
  39290. */
  39291. /**
  39292. * Set the keys for camera movement up.
  39293. */
  39294. keysUp: number[];
  39295. /**
  39296. * Get the keys for camera movement down.
  39297. */
  39298. /**
  39299. * Set the keys for camera movement down.
  39300. */
  39301. keysDown: number[];
  39302. /**
  39303. * Get the keys for camera movement left.
  39304. */
  39305. /**
  39306. * Set the keys for camera movement left.
  39307. */
  39308. keysLeft: number[];
  39309. /**
  39310. * Set the keys for camera movement right.
  39311. */
  39312. /**
  39313. * Set the keys for camera movement right.
  39314. */
  39315. keysRight: number[];
  39316. /**
  39317. * Event raised when the camera collides with a mesh in the scene.
  39318. */
  39319. onCollide: (collidedMesh: AbstractMesh) => void;
  39320. private _collider;
  39321. private _needMoveForGravity;
  39322. private _oldPosition;
  39323. private _diffPosition;
  39324. private _newPosition;
  39325. /** @hidden */
  39326. _localDirection: Vector3;
  39327. /** @hidden */
  39328. _transformedDirection: Vector3;
  39329. /**
  39330. * Instantiates a FlyCamera.
  39331. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39332. * such as in a 3D Space Shooter or a Flight Simulator.
  39333. * @param name Define the name of the camera in the scene.
  39334. * @param position Define the starting position of the camera in the scene.
  39335. * @param scene Define the scene the camera belongs to.
  39336. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39337. */
  39338. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39339. /**
  39340. * Attach a control to the HTML DOM element.
  39341. * @param element Defines the element that listens to the input events.
  39342. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39343. */
  39344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39345. /**
  39346. * Detach a control from the HTML DOM element.
  39347. * The camera will stop reacting to that input.
  39348. * @param element Defines the element that listens to the input events.
  39349. */
  39350. detachControl(element: HTMLElement): void;
  39351. private _collisionMask;
  39352. /**
  39353. * Get the mask that the camera ignores in collision events.
  39354. */
  39355. /**
  39356. * Set the mask that the camera ignores in collision events.
  39357. */
  39358. collisionMask: number;
  39359. /** @hidden */
  39360. _collideWithWorld(displacement: Vector3): void;
  39361. /** @hidden */
  39362. private _onCollisionPositionChange;
  39363. /** @hidden */
  39364. _checkInputs(): void;
  39365. /** @hidden */
  39366. _decideIfNeedsToMove(): boolean;
  39367. /** @hidden */
  39368. _updatePosition(): void;
  39369. /**
  39370. * Restore the Roll to its target value at the rate specified.
  39371. * @param rate - Higher means slower restoring.
  39372. * @hidden
  39373. */
  39374. restoreRoll(rate: number): void;
  39375. /**
  39376. * Destroy the camera and release the current resources held by it.
  39377. */
  39378. dispose(): void;
  39379. /**
  39380. * Get the current object class name.
  39381. * @returns the class name.
  39382. */
  39383. getClassName(): string;
  39384. }
  39385. }
  39386. declare module BABYLON {
  39387. /**
  39388. * Listen to keyboard events to control the camera.
  39389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39390. */
  39391. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39392. /**
  39393. * Defines the camera the input is attached to.
  39394. */
  39395. camera: FlyCamera;
  39396. /**
  39397. * The list of keyboard keys used to control the forward move of the camera.
  39398. */
  39399. keysForward: number[];
  39400. /**
  39401. * The list of keyboard keys used to control the backward move of the camera.
  39402. */
  39403. keysBackward: number[];
  39404. /**
  39405. * The list of keyboard keys used to control the forward move of the camera.
  39406. */
  39407. keysUp: number[];
  39408. /**
  39409. * The list of keyboard keys used to control the backward move of the camera.
  39410. */
  39411. keysDown: number[];
  39412. /**
  39413. * The list of keyboard keys used to control the right strafe move of the camera.
  39414. */
  39415. keysRight: number[];
  39416. /**
  39417. * The list of keyboard keys used to control the left strafe move of the camera.
  39418. */
  39419. keysLeft: number[];
  39420. private _keys;
  39421. private _onCanvasBlurObserver;
  39422. private _onKeyboardObserver;
  39423. private _engine;
  39424. private _scene;
  39425. /**
  39426. * Attach the input controls to a specific dom element to get the input from.
  39427. * @param element Defines the element the controls should be listened from
  39428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39429. */
  39430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39431. /**
  39432. * Detach the current controls from the specified dom element.
  39433. * @param element Defines the element to stop listening the inputs from
  39434. */
  39435. detachControl(element: Nullable<HTMLElement>): void;
  39436. /**
  39437. * Gets the class name of the current intput.
  39438. * @returns the class name
  39439. */
  39440. getClassName(): string;
  39441. /** @hidden */
  39442. _onLostFocus(e: FocusEvent): void;
  39443. /**
  39444. * Get the friendly name associated with the input class.
  39445. * @returns the input friendly name
  39446. */
  39447. getSimpleName(): string;
  39448. /**
  39449. * Update the current camera state depending on the inputs that have been used this frame.
  39450. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39451. */
  39452. checkInputs(): void;
  39453. }
  39454. }
  39455. declare module BABYLON {
  39456. /**
  39457. * Manage the mouse wheel inputs to control a follow camera.
  39458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39459. */
  39460. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39461. /**
  39462. * Defines the camera the input is attached to.
  39463. */
  39464. camera: FollowCamera;
  39465. /**
  39466. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39467. */
  39468. axisControlRadius: boolean;
  39469. /**
  39470. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39471. */
  39472. axisControlHeight: boolean;
  39473. /**
  39474. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39475. */
  39476. axisControlRotation: boolean;
  39477. /**
  39478. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39479. * relation to mouseWheel events.
  39480. */
  39481. wheelPrecision: number;
  39482. /**
  39483. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39484. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39485. */
  39486. wheelDeltaPercentage: number;
  39487. private _wheel;
  39488. private _observer;
  39489. /**
  39490. * Attach the input controls to a specific dom element to get the input from.
  39491. * @param element Defines the element the controls should be listened from
  39492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39493. */
  39494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39495. /**
  39496. * Detach the current controls from the specified dom element.
  39497. * @param element Defines the element to stop listening the inputs from
  39498. */
  39499. detachControl(element: Nullable<HTMLElement>): void;
  39500. /**
  39501. * Gets the class name of the current intput.
  39502. * @returns the class name
  39503. */
  39504. getClassName(): string;
  39505. /**
  39506. * Get the friendly name associated with the input class.
  39507. * @returns the input friendly name
  39508. */
  39509. getSimpleName(): string;
  39510. }
  39511. }
  39512. declare module BABYLON {
  39513. /**
  39514. * Manage the pointers inputs to control an follow camera.
  39515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39516. */
  39517. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39518. /**
  39519. * Defines the camera the input is attached to.
  39520. */
  39521. camera: FollowCamera;
  39522. /**
  39523. * Gets the class name of the current input.
  39524. * @returns the class name
  39525. */
  39526. getClassName(): string;
  39527. /**
  39528. * Defines the pointer angular sensibility along the X axis or how fast is
  39529. * the camera rotating.
  39530. * A negative number will reverse the axis direction.
  39531. */
  39532. angularSensibilityX: number;
  39533. /**
  39534. * Defines the pointer angular sensibility along the Y axis or how fast is
  39535. * the camera rotating.
  39536. * A negative number will reverse the axis direction.
  39537. */
  39538. angularSensibilityY: number;
  39539. /**
  39540. * Defines the pointer pinch precision or how fast is the camera zooming.
  39541. * A negative number will reverse the axis direction.
  39542. */
  39543. pinchPrecision: number;
  39544. /**
  39545. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39546. * from 0.
  39547. * It defines the percentage of current camera.radius to use as delta when
  39548. * pinch zoom is used.
  39549. */
  39550. pinchDeltaPercentage: number;
  39551. /**
  39552. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39553. */
  39554. axisXControlRadius: boolean;
  39555. /**
  39556. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39557. */
  39558. axisXControlHeight: boolean;
  39559. /**
  39560. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39561. */
  39562. axisXControlRotation: boolean;
  39563. /**
  39564. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39565. */
  39566. axisYControlRadius: boolean;
  39567. /**
  39568. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39569. */
  39570. axisYControlHeight: boolean;
  39571. /**
  39572. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39573. */
  39574. axisYControlRotation: boolean;
  39575. /**
  39576. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39577. */
  39578. axisPinchControlRadius: boolean;
  39579. /**
  39580. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39581. */
  39582. axisPinchControlHeight: boolean;
  39583. /**
  39584. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39585. */
  39586. axisPinchControlRotation: boolean;
  39587. /**
  39588. * Log error messages if basic misconfiguration has occurred.
  39589. */
  39590. warningEnable: boolean;
  39591. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39592. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39593. private _warningCounter;
  39594. private _warning;
  39595. }
  39596. }
  39597. declare module BABYLON {
  39598. /**
  39599. * Default Inputs manager for the FollowCamera.
  39600. * It groups all the default supported inputs for ease of use.
  39601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39602. */
  39603. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39604. /**
  39605. * Instantiates a new FollowCameraInputsManager.
  39606. * @param camera Defines the camera the inputs belong to
  39607. */
  39608. constructor(camera: FollowCamera);
  39609. /**
  39610. * Add keyboard input support to the input manager.
  39611. * @returns the current input manager
  39612. */
  39613. addKeyboard(): FollowCameraInputsManager;
  39614. /**
  39615. * Add mouse wheel input support to the input manager.
  39616. * @returns the current input manager
  39617. */
  39618. addMouseWheel(): FollowCameraInputsManager;
  39619. /**
  39620. * Add pointers input support to the input manager.
  39621. * @returns the current input manager
  39622. */
  39623. addPointers(): FollowCameraInputsManager;
  39624. /**
  39625. * Add orientation input support to the input manager.
  39626. * @returns the current input manager
  39627. */
  39628. addVRDeviceOrientation(): FollowCameraInputsManager;
  39629. }
  39630. }
  39631. declare module BABYLON {
  39632. /**
  39633. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39634. * an arc rotate version arcFollowCamera are available.
  39635. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39636. */
  39637. export class FollowCamera extends TargetCamera {
  39638. /**
  39639. * Distance the follow camera should follow an object at
  39640. */
  39641. radius: number;
  39642. /**
  39643. * Minimum allowed distance of the camera to the axis of rotation
  39644. * (The camera can not get closer).
  39645. * This can help limiting how the Camera is able to move in the scene.
  39646. */
  39647. lowerRadiusLimit: Nullable<number>;
  39648. /**
  39649. * Maximum allowed distance of the camera to the axis of rotation
  39650. * (The camera can not get further).
  39651. * This can help limiting how the Camera is able to move in the scene.
  39652. */
  39653. upperRadiusLimit: Nullable<number>;
  39654. /**
  39655. * Define a rotation offset between the camera and the object it follows
  39656. */
  39657. rotationOffset: number;
  39658. /**
  39659. * Minimum allowed angle to camera position relative to target object.
  39660. * This can help limiting how the Camera is able to move in the scene.
  39661. */
  39662. lowerRotationOffsetLimit: Nullable<number>;
  39663. /**
  39664. * Maximum allowed angle to camera position relative to target object.
  39665. * This can help limiting how the Camera is able to move in the scene.
  39666. */
  39667. upperRotationOffsetLimit: Nullable<number>;
  39668. /**
  39669. * Define a height offset between the camera and the object it follows.
  39670. * It can help following an object from the top (like a car chaing a plane)
  39671. */
  39672. heightOffset: number;
  39673. /**
  39674. * Minimum allowed height of camera position relative to target object.
  39675. * This can help limiting how the Camera is able to move in the scene.
  39676. */
  39677. lowerHeightOffsetLimit: Nullable<number>;
  39678. /**
  39679. * Maximum allowed height of camera position relative to target object.
  39680. * This can help limiting how the Camera is able to move in the scene.
  39681. */
  39682. upperHeightOffsetLimit: Nullable<number>;
  39683. /**
  39684. * Define how fast the camera can accelerate to follow it s target.
  39685. */
  39686. cameraAcceleration: number;
  39687. /**
  39688. * Define the speed limit of the camera following an object.
  39689. */
  39690. maxCameraSpeed: number;
  39691. /**
  39692. * Define the target of the camera.
  39693. */
  39694. lockedTarget: Nullable<AbstractMesh>;
  39695. /**
  39696. * Defines the input associated with the camera.
  39697. */
  39698. inputs: FollowCameraInputsManager;
  39699. /**
  39700. * Instantiates the follow camera.
  39701. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39702. * @param name Define the name of the camera in the scene
  39703. * @param position Define the position of the camera
  39704. * @param scene Define the scene the camera belong to
  39705. * @param lockedTarget Define the target of the camera
  39706. */
  39707. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39708. private _follow;
  39709. /**
  39710. * Attached controls to the current camera.
  39711. * @param element Defines the element the controls should be listened from
  39712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39713. */
  39714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39715. /**
  39716. * Detach the current controls from the camera.
  39717. * The camera will stop reacting to inputs.
  39718. * @param element Defines the element to stop listening the inputs from
  39719. */
  39720. detachControl(element: HTMLElement): void;
  39721. /** @hidden */
  39722. _checkInputs(): void;
  39723. private _checkLimits;
  39724. /**
  39725. * Gets the camera class name.
  39726. * @returns the class name
  39727. */
  39728. getClassName(): string;
  39729. }
  39730. /**
  39731. * Arc Rotate version of the follow camera.
  39732. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39733. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39734. */
  39735. export class ArcFollowCamera extends TargetCamera {
  39736. /** The longitudinal angle of the camera */
  39737. alpha: number;
  39738. /** The latitudinal angle of the camera */
  39739. beta: number;
  39740. /** The radius of the camera from its target */
  39741. radius: number;
  39742. /** Define the camera target (the messh it should follow) */
  39743. target: Nullable<AbstractMesh>;
  39744. private _cartesianCoordinates;
  39745. /**
  39746. * Instantiates a new ArcFollowCamera
  39747. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39748. * @param name Define the name of the camera
  39749. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39750. * @param beta Define the rotation angle of the camera around the elevation axis
  39751. * @param radius Define the radius of the camera from its target point
  39752. * @param target Define the target of the camera
  39753. * @param scene Define the scene the camera belongs to
  39754. */
  39755. constructor(name: string,
  39756. /** The longitudinal angle of the camera */
  39757. alpha: number,
  39758. /** The latitudinal angle of the camera */
  39759. beta: number,
  39760. /** The radius of the camera from its target */
  39761. radius: number,
  39762. /** Define the camera target (the messh it should follow) */
  39763. target: Nullable<AbstractMesh>, scene: Scene);
  39764. private _follow;
  39765. /** @hidden */
  39766. _checkInputs(): void;
  39767. /**
  39768. * Returns the class name of the object.
  39769. * It is mostly used internally for serialization purposes.
  39770. */
  39771. getClassName(): string;
  39772. }
  39773. }
  39774. declare module BABYLON {
  39775. /**
  39776. * Manage the keyboard inputs to control the movement of a follow camera.
  39777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39778. */
  39779. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39780. /**
  39781. * Defines the camera the input is attached to.
  39782. */
  39783. camera: FollowCamera;
  39784. /**
  39785. * Defines the list of key codes associated with the up action (increase heightOffset)
  39786. */
  39787. keysHeightOffsetIncr: number[];
  39788. /**
  39789. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39790. */
  39791. keysHeightOffsetDecr: number[];
  39792. /**
  39793. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39794. */
  39795. keysHeightOffsetModifierAlt: boolean;
  39796. /**
  39797. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39798. */
  39799. keysHeightOffsetModifierCtrl: boolean;
  39800. /**
  39801. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39802. */
  39803. keysHeightOffsetModifierShift: boolean;
  39804. /**
  39805. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39806. */
  39807. keysRotationOffsetIncr: number[];
  39808. /**
  39809. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39810. */
  39811. keysRotationOffsetDecr: number[];
  39812. /**
  39813. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39814. */
  39815. keysRotationOffsetModifierAlt: boolean;
  39816. /**
  39817. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39818. */
  39819. keysRotationOffsetModifierCtrl: boolean;
  39820. /**
  39821. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39822. */
  39823. keysRotationOffsetModifierShift: boolean;
  39824. /**
  39825. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39826. */
  39827. keysRadiusIncr: number[];
  39828. /**
  39829. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39830. */
  39831. keysRadiusDecr: number[];
  39832. /**
  39833. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39834. */
  39835. keysRadiusModifierAlt: boolean;
  39836. /**
  39837. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39838. */
  39839. keysRadiusModifierCtrl: boolean;
  39840. /**
  39841. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39842. */
  39843. keysRadiusModifierShift: boolean;
  39844. /**
  39845. * Defines the rate of change of heightOffset.
  39846. */
  39847. heightSensibility: number;
  39848. /**
  39849. * Defines the rate of change of rotationOffset.
  39850. */
  39851. rotationSensibility: number;
  39852. /**
  39853. * Defines the rate of change of radius.
  39854. */
  39855. radiusSensibility: number;
  39856. private _keys;
  39857. private _ctrlPressed;
  39858. private _altPressed;
  39859. private _shiftPressed;
  39860. private _onCanvasBlurObserver;
  39861. private _onKeyboardObserver;
  39862. private _engine;
  39863. private _scene;
  39864. /**
  39865. * Attach the input controls to a specific dom element to get the input from.
  39866. * @param element Defines the element the controls should be listened from
  39867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39868. */
  39869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39870. /**
  39871. * Detach the current controls from the specified dom element.
  39872. * @param element Defines the element to stop listening the inputs from
  39873. */
  39874. detachControl(element: Nullable<HTMLElement>): void;
  39875. /**
  39876. * Update the current camera state depending on the inputs that have been used this frame.
  39877. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39878. */
  39879. checkInputs(): void;
  39880. /**
  39881. * Gets the class name of the current input.
  39882. * @returns the class name
  39883. */
  39884. getClassName(): string;
  39885. /**
  39886. * Get the friendly name associated with the input class.
  39887. * @returns the input friendly name
  39888. */
  39889. getSimpleName(): string;
  39890. /**
  39891. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39892. * allow modification of the heightOffset value.
  39893. */
  39894. private _modifierHeightOffset;
  39895. /**
  39896. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39897. * allow modification of the rotationOffset value.
  39898. */
  39899. private _modifierRotationOffset;
  39900. /**
  39901. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39902. * allow modification of the radius value.
  39903. */
  39904. private _modifierRadius;
  39905. }
  39906. }
  39907. declare module BABYLON {
  39908. interface FreeCameraInputsManager {
  39909. /**
  39910. * @hidden
  39911. */
  39912. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39913. /**
  39914. * Add orientation input support to the input manager.
  39915. * @returns the current input manager
  39916. */
  39917. addDeviceOrientation(): FreeCameraInputsManager;
  39918. }
  39919. /**
  39920. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39921. * Screen rotation is taken into account.
  39922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39923. */
  39924. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39925. private _camera;
  39926. private _screenOrientationAngle;
  39927. private _constantTranform;
  39928. private _screenQuaternion;
  39929. private _alpha;
  39930. private _beta;
  39931. private _gamma;
  39932. /**
  39933. * Can be used to detect if a device orientation sensor is available on a device
  39934. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39935. * @returns a promise that will resolve on orientation change
  39936. */
  39937. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39938. /**
  39939. * @hidden
  39940. */
  39941. _onDeviceOrientationChangedObservable: Observable<void>;
  39942. /**
  39943. * Instantiates a new input
  39944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39945. */
  39946. constructor();
  39947. /**
  39948. * Define the camera controlled by the input.
  39949. */
  39950. camera: FreeCamera;
  39951. /**
  39952. * Attach the input controls to a specific dom element to get the input from.
  39953. * @param element Defines the element the controls should be listened from
  39954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39955. */
  39956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39957. private _orientationChanged;
  39958. private _deviceOrientation;
  39959. /**
  39960. * Detach the current controls from the specified dom element.
  39961. * @param element Defines the element to stop listening the inputs from
  39962. */
  39963. detachControl(element: Nullable<HTMLElement>): void;
  39964. /**
  39965. * Update the current camera state depending on the inputs that have been used this frame.
  39966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39967. */
  39968. checkInputs(): void;
  39969. /**
  39970. * Gets the class name of the current intput.
  39971. * @returns the class name
  39972. */
  39973. getClassName(): string;
  39974. /**
  39975. * Get the friendly name associated with the input class.
  39976. * @returns the input friendly name
  39977. */
  39978. getSimpleName(): string;
  39979. }
  39980. }
  39981. declare module BABYLON {
  39982. /**
  39983. * Manage the gamepad inputs to control a free camera.
  39984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39985. */
  39986. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39987. /**
  39988. * Define the camera the input is attached to.
  39989. */
  39990. camera: FreeCamera;
  39991. /**
  39992. * Define the Gamepad controlling the input
  39993. */
  39994. gamepad: Nullable<Gamepad>;
  39995. /**
  39996. * Defines the gamepad rotation sensiblity.
  39997. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39998. */
  39999. gamepadAngularSensibility: number;
  40000. /**
  40001. * Defines the gamepad move sensiblity.
  40002. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40003. */
  40004. gamepadMoveSensibility: number;
  40005. private _yAxisScale;
  40006. /**
  40007. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40008. */
  40009. invertYAxis: boolean;
  40010. private _onGamepadConnectedObserver;
  40011. private _onGamepadDisconnectedObserver;
  40012. private _cameraTransform;
  40013. private _deltaTransform;
  40014. private _vector3;
  40015. private _vector2;
  40016. /**
  40017. * Attach the input controls to a specific dom element to get the input from.
  40018. * @param element Defines the element the controls should be listened from
  40019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40020. */
  40021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40022. /**
  40023. * Detach the current controls from the specified dom element.
  40024. * @param element Defines the element to stop listening the inputs from
  40025. */
  40026. detachControl(element: Nullable<HTMLElement>): void;
  40027. /**
  40028. * Update the current camera state depending on the inputs that have been used this frame.
  40029. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40030. */
  40031. checkInputs(): void;
  40032. /**
  40033. * Gets the class name of the current intput.
  40034. * @returns the class name
  40035. */
  40036. getClassName(): string;
  40037. /**
  40038. * Get the friendly name associated with the input class.
  40039. * @returns the input friendly name
  40040. */
  40041. getSimpleName(): string;
  40042. }
  40043. }
  40044. declare module BABYLON {
  40045. /**
  40046. * Defines the potential axis of a Joystick
  40047. */
  40048. export enum JoystickAxis {
  40049. /** X axis */
  40050. X = 0,
  40051. /** Y axis */
  40052. Y = 1,
  40053. /** Z axis */
  40054. Z = 2
  40055. }
  40056. /**
  40057. * Class used to define virtual joystick (used in touch mode)
  40058. */
  40059. export class VirtualJoystick {
  40060. /**
  40061. * Gets or sets a boolean indicating that left and right values must be inverted
  40062. */
  40063. reverseLeftRight: boolean;
  40064. /**
  40065. * Gets or sets a boolean indicating that up and down values must be inverted
  40066. */
  40067. reverseUpDown: boolean;
  40068. /**
  40069. * Gets the offset value for the position (ie. the change of the position value)
  40070. */
  40071. deltaPosition: Vector3;
  40072. /**
  40073. * Gets a boolean indicating if the virtual joystick was pressed
  40074. */
  40075. pressed: boolean;
  40076. /**
  40077. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40078. */
  40079. static Canvas: Nullable<HTMLCanvasElement>;
  40080. private static _globalJoystickIndex;
  40081. private static vjCanvasContext;
  40082. private static vjCanvasWidth;
  40083. private static vjCanvasHeight;
  40084. private static halfWidth;
  40085. private _action;
  40086. private _axisTargetedByLeftAndRight;
  40087. private _axisTargetedByUpAndDown;
  40088. private _joystickSensibility;
  40089. private _inversedSensibility;
  40090. private _joystickPointerID;
  40091. private _joystickColor;
  40092. private _joystickPointerPos;
  40093. private _joystickPreviousPointerPos;
  40094. private _joystickPointerStartPos;
  40095. private _deltaJoystickVector;
  40096. private _leftJoystick;
  40097. private _touches;
  40098. private _onPointerDownHandlerRef;
  40099. private _onPointerMoveHandlerRef;
  40100. private _onPointerUpHandlerRef;
  40101. private _onResize;
  40102. /**
  40103. * Creates a new virtual joystick
  40104. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40105. */
  40106. constructor(leftJoystick?: boolean);
  40107. /**
  40108. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40109. * @param newJoystickSensibility defines the new sensibility
  40110. */
  40111. setJoystickSensibility(newJoystickSensibility: number): void;
  40112. private _onPointerDown;
  40113. private _onPointerMove;
  40114. private _onPointerUp;
  40115. /**
  40116. * Change the color of the virtual joystick
  40117. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40118. */
  40119. setJoystickColor(newColor: string): void;
  40120. /**
  40121. * Defines a callback to call when the joystick is touched
  40122. * @param action defines the callback
  40123. */
  40124. setActionOnTouch(action: () => any): void;
  40125. /**
  40126. * Defines which axis you'd like to control for left & right
  40127. * @param axis defines the axis to use
  40128. */
  40129. setAxisForLeftRight(axis: JoystickAxis): void;
  40130. /**
  40131. * Defines which axis you'd like to control for up & down
  40132. * @param axis defines the axis to use
  40133. */
  40134. setAxisForUpDown(axis: JoystickAxis): void;
  40135. private _drawVirtualJoystick;
  40136. /**
  40137. * Release internal HTML canvas
  40138. */
  40139. releaseCanvas(): void;
  40140. }
  40141. }
  40142. declare module BABYLON {
  40143. interface FreeCameraInputsManager {
  40144. /**
  40145. * Add virtual joystick input support to the input manager.
  40146. * @returns the current input manager
  40147. */
  40148. addVirtualJoystick(): FreeCameraInputsManager;
  40149. }
  40150. /**
  40151. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40153. */
  40154. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40155. /**
  40156. * Defines the camera the input is attached to.
  40157. */
  40158. camera: FreeCamera;
  40159. private _leftjoystick;
  40160. private _rightjoystick;
  40161. /**
  40162. * Gets the left stick of the virtual joystick.
  40163. * @returns The virtual Joystick
  40164. */
  40165. getLeftJoystick(): VirtualJoystick;
  40166. /**
  40167. * Gets the right stick of the virtual joystick.
  40168. * @returns The virtual Joystick
  40169. */
  40170. getRightJoystick(): VirtualJoystick;
  40171. /**
  40172. * Update the current camera state depending on the inputs that have been used this frame.
  40173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40174. */
  40175. checkInputs(): void;
  40176. /**
  40177. * Attach the input controls to a specific dom element to get the input from.
  40178. * @param element Defines the element the controls should be listened from
  40179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40180. */
  40181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40182. /**
  40183. * Detach the current controls from the specified dom element.
  40184. * @param element Defines the element to stop listening the inputs from
  40185. */
  40186. detachControl(element: Nullable<HTMLElement>): void;
  40187. /**
  40188. * Gets the class name of the current intput.
  40189. * @returns the class name
  40190. */
  40191. getClassName(): string;
  40192. /**
  40193. * Get the friendly name associated with the input class.
  40194. * @returns the input friendly name
  40195. */
  40196. getSimpleName(): string;
  40197. }
  40198. }
  40199. declare module BABYLON {
  40200. /**
  40201. * This represents a FPS type of camera controlled by touch.
  40202. * This is like a universal camera minus the Gamepad controls.
  40203. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40204. */
  40205. export class TouchCamera extends FreeCamera {
  40206. /**
  40207. * Defines the touch sensibility for rotation.
  40208. * The higher the faster.
  40209. */
  40210. touchAngularSensibility: number;
  40211. /**
  40212. * Defines the touch sensibility for move.
  40213. * The higher the faster.
  40214. */
  40215. touchMoveSensibility: number;
  40216. /**
  40217. * Instantiates a new touch camera.
  40218. * This represents a FPS type of camera controlled by touch.
  40219. * This is like a universal camera minus the Gamepad controls.
  40220. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40221. * @param name Define the name of the camera in the scene
  40222. * @param position Define the start position of the camera in the scene
  40223. * @param scene Define the scene the camera belongs to
  40224. */
  40225. constructor(name: string, position: Vector3, scene: Scene);
  40226. /**
  40227. * Gets the current object class name.
  40228. * @return the class name
  40229. */
  40230. getClassName(): string;
  40231. /** @hidden */
  40232. _setupInputs(): void;
  40233. }
  40234. }
  40235. declare module BABYLON {
  40236. /**
  40237. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40238. * being tilted forward or back and left or right.
  40239. */
  40240. export class DeviceOrientationCamera extends FreeCamera {
  40241. private _initialQuaternion;
  40242. private _quaternionCache;
  40243. private _tmpDragQuaternion;
  40244. private _disablePointerInputWhenUsingDeviceOrientation;
  40245. /**
  40246. * Creates a new device orientation camera
  40247. * @param name The name of the camera
  40248. * @param position The start position camera
  40249. * @param scene The scene the camera belongs to
  40250. */
  40251. constructor(name: string, position: Vector3, scene: Scene);
  40252. /**
  40253. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40254. */
  40255. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40256. private _dragFactor;
  40257. /**
  40258. * Enabled turning on the y axis when the orientation sensor is active
  40259. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40260. */
  40261. enableHorizontalDragging(dragFactor?: number): void;
  40262. /**
  40263. * Gets the current instance class name ("DeviceOrientationCamera").
  40264. * This helps avoiding instanceof at run time.
  40265. * @returns the class name
  40266. */
  40267. getClassName(): string;
  40268. /**
  40269. * @hidden
  40270. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40271. */
  40272. _checkInputs(): void;
  40273. /**
  40274. * Reset the camera to its default orientation on the specified axis only.
  40275. * @param axis The axis to reset
  40276. */
  40277. resetToCurrentRotation(axis?: Axis): void;
  40278. }
  40279. }
  40280. declare module BABYLON {
  40281. /**
  40282. * Defines supported buttons for XBox360 compatible gamepads
  40283. */
  40284. export enum Xbox360Button {
  40285. /** A */
  40286. A = 0,
  40287. /** B */
  40288. B = 1,
  40289. /** X */
  40290. X = 2,
  40291. /** Y */
  40292. Y = 3,
  40293. /** Start */
  40294. Start = 4,
  40295. /** Back */
  40296. Back = 5,
  40297. /** Left button */
  40298. LB = 6,
  40299. /** Right button */
  40300. RB = 7,
  40301. /** Left stick */
  40302. LeftStick = 8,
  40303. /** Right stick */
  40304. RightStick = 9
  40305. }
  40306. /** Defines values for XBox360 DPad */
  40307. export enum Xbox360Dpad {
  40308. /** Up */
  40309. Up = 0,
  40310. /** Down */
  40311. Down = 1,
  40312. /** Left */
  40313. Left = 2,
  40314. /** Right */
  40315. Right = 3
  40316. }
  40317. /**
  40318. * Defines a XBox360 gamepad
  40319. */
  40320. export class Xbox360Pad extends Gamepad {
  40321. private _leftTrigger;
  40322. private _rightTrigger;
  40323. private _onlefttriggerchanged;
  40324. private _onrighttriggerchanged;
  40325. private _onbuttondown;
  40326. private _onbuttonup;
  40327. private _ondpaddown;
  40328. private _ondpadup;
  40329. /** Observable raised when a button is pressed */
  40330. onButtonDownObservable: Observable<Xbox360Button>;
  40331. /** Observable raised when a button is released */
  40332. onButtonUpObservable: Observable<Xbox360Button>;
  40333. /** Observable raised when a pad is pressed */
  40334. onPadDownObservable: Observable<Xbox360Dpad>;
  40335. /** Observable raised when a pad is released */
  40336. onPadUpObservable: Observable<Xbox360Dpad>;
  40337. private _buttonA;
  40338. private _buttonB;
  40339. private _buttonX;
  40340. private _buttonY;
  40341. private _buttonBack;
  40342. private _buttonStart;
  40343. private _buttonLB;
  40344. private _buttonRB;
  40345. private _buttonLeftStick;
  40346. private _buttonRightStick;
  40347. private _dPadUp;
  40348. private _dPadDown;
  40349. private _dPadLeft;
  40350. private _dPadRight;
  40351. private _isXboxOnePad;
  40352. /**
  40353. * Creates a new XBox360 gamepad object
  40354. * @param id defines the id of this gamepad
  40355. * @param index defines its index
  40356. * @param gamepad defines the internal HTML gamepad object
  40357. * @param xboxOne defines if it is a XBox One gamepad
  40358. */
  40359. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40360. /**
  40361. * Defines the callback to call when left trigger is pressed
  40362. * @param callback defines the callback to use
  40363. */
  40364. onlefttriggerchanged(callback: (value: number) => void): void;
  40365. /**
  40366. * Defines the callback to call when right trigger is pressed
  40367. * @param callback defines the callback to use
  40368. */
  40369. onrighttriggerchanged(callback: (value: number) => void): void;
  40370. /**
  40371. * Gets the left trigger value
  40372. */
  40373. /**
  40374. * Sets the left trigger value
  40375. */
  40376. leftTrigger: number;
  40377. /**
  40378. * Gets the right trigger value
  40379. */
  40380. /**
  40381. * Sets the right trigger value
  40382. */
  40383. rightTrigger: number;
  40384. /**
  40385. * Defines the callback to call when a button is pressed
  40386. * @param callback defines the callback to use
  40387. */
  40388. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40389. /**
  40390. * Defines the callback to call when a button is released
  40391. * @param callback defines the callback to use
  40392. */
  40393. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40394. /**
  40395. * Defines the callback to call when a pad is pressed
  40396. * @param callback defines the callback to use
  40397. */
  40398. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40399. /**
  40400. * Defines the callback to call when a pad is released
  40401. * @param callback defines the callback to use
  40402. */
  40403. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40404. private _setButtonValue;
  40405. private _setDPadValue;
  40406. /**
  40407. * Gets the value of the `A` button
  40408. */
  40409. /**
  40410. * Sets the value of the `A` button
  40411. */
  40412. buttonA: number;
  40413. /**
  40414. * Gets the value of the `B` button
  40415. */
  40416. /**
  40417. * Sets the value of the `B` button
  40418. */
  40419. buttonB: number;
  40420. /**
  40421. * Gets the value of the `X` button
  40422. */
  40423. /**
  40424. * Sets the value of the `X` button
  40425. */
  40426. buttonX: number;
  40427. /**
  40428. * Gets the value of the `Y` button
  40429. */
  40430. /**
  40431. * Sets the value of the `Y` button
  40432. */
  40433. buttonY: number;
  40434. /**
  40435. * Gets the value of the `Start` button
  40436. */
  40437. /**
  40438. * Sets the value of the `Start` button
  40439. */
  40440. buttonStart: number;
  40441. /**
  40442. * Gets the value of the `Back` button
  40443. */
  40444. /**
  40445. * Sets the value of the `Back` button
  40446. */
  40447. buttonBack: number;
  40448. /**
  40449. * Gets the value of the `Left` button
  40450. */
  40451. /**
  40452. * Sets the value of the `Left` button
  40453. */
  40454. buttonLB: number;
  40455. /**
  40456. * Gets the value of the `Right` button
  40457. */
  40458. /**
  40459. * Sets the value of the `Right` button
  40460. */
  40461. buttonRB: number;
  40462. /**
  40463. * Gets the value of the Left joystick
  40464. */
  40465. /**
  40466. * Sets the value of the Left joystick
  40467. */
  40468. buttonLeftStick: number;
  40469. /**
  40470. * Gets the value of the Right joystick
  40471. */
  40472. /**
  40473. * Sets the value of the Right joystick
  40474. */
  40475. buttonRightStick: number;
  40476. /**
  40477. * Gets the value of D-pad up
  40478. */
  40479. /**
  40480. * Sets the value of D-pad up
  40481. */
  40482. dPadUp: number;
  40483. /**
  40484. * Gets the value of D-pad down
  40485. */
  40486. /**
  40487. * Sets the value of D-pad down
  40488. */
  40489. dPadDown: number;
  40490. /**
  40491. * Gets the value of D-pad left
  40492. */
  40493. /**
  40494. * Sets the value of D-pad left
  40495. */
  40496. dPadLeft: number;
  40497. /**
  40498. * Gets the value of D-pad right
  40499. */
  40500. /**
  40501. * Sets the value of D-pad right
  40502. */
  40503. dPadRight: number;
  40504. /**
  40505. * Force the gamepad to synchronize with device values
  40506. */
  40507. update(): void;
  40508. /**
  40509. * Disposes the gamepad
  40510. */
  40511. dispose(): void;
  40512. }
  40513. }
  40514. declare module BABYLON {
  40515. /**
  40516. * Defines supported buttons for DualShock compatible gamepads
  40517. */
  40518. export enum DualShockButton {
  40519. /** Cross */
  40520. Cross = 0,
  40521. /** Circle */
  40522. Circle = 1,
  40523. /** Square */
  40524. Square = 2,
  40525. /** Triangle */
  40526. Triangle = 3,
  40527. /** Options */
  40528. Options = 4,
  40529. /** Share */
  40530. Share = 5,
  40531. /** L1 */
  40532. L1 = 6,
  40533. /** R1 */
  40534. R1 = 7,
  40535. /** Left stick */
  40536. LeftStick = 8,
  40537. /** Right stick */
  40538. RightStick = 9
  40539. }
  40540. /** Defines values for DualShock DPad */
  40541. export enum DualShockDpad {
  40542. /** Up */
  40543. Up = 0,
  40544. /** Down */
  40545. Down = 1,
  40546. /** Left */
  40547. Left = 2,
  40548. /** Right */
  40549. Right = 3
  40550. }
  40551. /**
  40552. * Defines a DualShock gamepad
  40553. */
  40554. export class DualShockPad extends Gamepad {
  40555. private _leftTrigger;
  40556. private _rightTrigger;
  40557. private _onlefttriggerchanged;
  40558. private _onrighttriggerchanged;
  40559. private _onbuttondown;
  40560. private _onbuttonup;
  40561. private _ondpaddown;
  40562. private _ondpadup;
  40563. /** Observable raised when a button is pressed */
  40564. onButtonDownObservable: Observable<DualShockButton>;
  40565. /** Observable raised when a button is released */
  40566. onButtonUpObservable: Observable<DualShockButton>;
  40567. /** Observable raised when a pad is pressed */
  40568. onPadDownObservable: Observable<DualShockDpad>;
  40569. /** Observable raised when a pad is released */
  40570. onPadUpObservable: Observable<DualShockDpad>;
  40571. private _buttonCross;
  40572. private _buttonCircle;
  40573. private _buttonSquare;
  40574. private _buttonTriangle;
  40575. private _buttonShare;
  40576. private _buttonOptions;
  40577. private _buttonL1;
  40578. private _buttonR1;
  40579. private _buttonLeftStick;
  40580. private _buttonRightStick;
  40581. private _dPadUp;
  40582. private _dPadDown;
  40583. private _dPadLeft;
  40584. private _dPadRight;
  40585. /**
  40586. * Creates a new DualShock gamepad object
  40587. * @param id defines the id of this gamepad
  40588. * @param index defines its index
  40589. * @param gamepad defines the internal HTML gamepad object
  40590. */
  40591. constructor(id: string, index: number, gamepad: any);
  40592. /**
  40593. * Defines the callback to call when left trigger is pressed
  40594. * @param callback defines the callback to use
  40595. */
  40596. onlefttriggerchanged(callback: (value: number) => void): void;
  40597. /**
  40598. * Defines the callback to call when right trigger is pressed
  40599. * @param callback defines the callback to use
  40600. */
  40601. onrighttriggerchanged(callback: (value: number) => void): void;
  40602. /**
  40603. * Gets the left trigger value
  40604. */
  40605. /**
  40606. * Sets the left trigger value
  40607. */
  40608. leftTrigger: number;
  40609. /**
  40610. * Gets the right trigger value
  40611. */
  40612. /**
  40613. * Sets the right trigger value
  40614. */
  40615. rightTrigger: number;
  40616. /**
  40617. * Defines the callback to call when a button is pressed
  40618. * @param callback defines the callback to use
  40619. */
  40620. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40621. /**
  40622. * Defines the callback to call when a button is released
  40623. * @param callback defines the callback to use
  40624. */
  40625. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40626. /**
  40627. * Defines the callback to call when a pad is pressed
  40628. * @param callback defines the callback to use
  40629. */
  40630. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40631. /**
  40632. * Defines the callback to call when a pad is released
  40633. * @param callback defines the callback to use
  40634. */
  40635. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40636. private _setButtonValue;
  40637. private _setDPadValue;
  40638. /**
  40639. * Gets the value of the `Cross` button
  40640. */
  40641. /**
  40642. * Sets the value of the `Cross` button
  40643. */
  40644. buttonCross: number;
  40645. /**
  40646. * Gets the value of the `Circle` button
  40647. */
  40648. /**
  40649. * Sets the value of the `Circle` button
  40650. */
  40651. buttonCircle: number;
  40652. /**
  40653. * Gets the value of the `Square` button
  40654. */
  40655. /**
  40656. * Sets the value of the `Square` button
  40657. */
  40658. buttonSquare: number;
  40659. /**
  40660. * Gets the value of the `Triangle` button
  40661. */
  40662. /**
  40663. * Sets the value of the `Triangle` button
  40664. */
  40665. buttonTriangle: number;
  40666. /**
  40667. * Gets the value of the `Options` button
  40668. */
  40669. /**
  40670. * Sets the value of the `Options` button
  40671. */
  40672. buttonOptions: number;
  40673. /**
  40674. * Gets the value of the `Share` button
  40675. */
  40676. /**
  40677. * Sets the value of the `Share` button
  40678. */
  40679. buttonShare: number;
  40680. /**
  40681. * Gets the value of the `L1` button
  40682. */
  40683. /**
  40684. * Sets the value of the `L1` button
  40685. */
  40686. buttonL1: number;
  40687. /**
  40688. * Gets the value of the `R1` button
  40689. */
  40690. /**
  40691. * Sets the value of the `R1` button
  40692. */
  40693. buttonR1: number;
  40694. /**
  40695. * Gets the value of the Left joystick
  40696. */
  40697. /**
  40698. * Sets the value of the Left joystick
  40699. */
  40700. buttonLeftStick: number;
  40701. /**
  40702. * Gets the value of the Right joystick
  40703. */
  40704. /**
  40705. * Sets the value of the Right joystick
  40706. */
  40707. buttonRightStick: number;
  40708. /**
  40709. * Gets the value of D-pad up
  40710. */
  40711. /**
  40712. * Sets the value of D-pad up
  40713. */
  40714. dPadUp: number;
  40715. /**
  40716. * Gets the value of D-pad down
  40717. */
  40718. /**
  40719. * Sets the value of D-pad down
  40720. */
  40721. dPadDown: number;
  40722. /**
  40723. * Gets the value of D-pad left
  40724. */
  40725. /**
  40726. * Sets the value of D-pad left
  40727. */
  40728. dPadLeft: number;
  40729. /**
  40730. * Gets the value of D-pad right
  40731. */
  40732. /**
  40733. * Sets the value of D-pad right
  40734. */
  40735. dPadRight: number;
  40736. /**
  40737. * Force the gamepad to synchronize with device values
  40738. */
  40739. update(): void;
  40740. /**
  40741. * Disposes the gamepad
  40742. */
  40743. dispose(): void;
  40744. }
  40745. }
  40746. declare module BABYLON {
  40747. /**
  40748. * Manager for handling gamepads
  40749. */
  40750. export class GamepadManager {
  40751. private _scene?;
  40752. private _babylonGamepads;
  40753. private _oneGamepadConnected;
  40754. /** @hidden */
  40755. _isMonitoring: boolean;
  40756. private _gamepadEventSupported;
  40757. private _gamepadSupport;
  40758. /**
  40759. * observable to be triggered when the gamepad controller has been connected
  40760. */
  40761. onGamepadConnectedObservable: Observable<Gamepad>;
  40762. /**
  40763. * observable to be triggered when the gamepad controller has been disconnected
  40764. */
  40765. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40766. private _onGamepadConnectedEvent;
  40767. private _onGamepadDisconnectedEvent;
  40768. /**
  40769. * Initializes the gamepad manager
  40770. * @param _scene BabylonJS scene
  40771. */
  40772. constructor(_scene?: Scene | undefined);
  40773. /**
  40774. * The gamepads in the game pad manager
  40775. */
  40776. readonly gamepads: Gamepad[];
  40777. /**
  40778. * Get the gamepad controllers based on type
  40779. * @param type The type of gamepad controller
  40780. * @returns Nullable gamepad
  40781. */
  40782. getGamepadByType(type?: number): Nullable<Gamepad>;
  40783. /**
  40784. * Disposes the gamepad manager
  40785. */
  40786. dispose(): void;
  40787. private _addNewGamepad;
  40788. private _startMonitoringGamepads;
  40789. private _stopMonitoringGamepads;
  40790. /** @hidden */
  40791. _checkGamepadsStatus(): void;
  40792. private _updateGamepadObjects;
  40793. }
  40794. }
  40795. declare module BABYLON {
  40796. interface Scene {
  40797. /** @hidden */
  40798. _gamepadManager: Nullable<GamepadManager>;
  40799. /**
  40800. * Gets the gamepad manager associated with the scene
  40801. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40802. */
  40803. gamepadManager: GamepadManager;
  40804. }
  40805. /**
  40806. * Interface representing a free camera inputs manager
  40807. */
  40808. interface FreeCameraInputsManager {
  40809. /**
  40810. * Adds gamepad input support to the FreeCameraInputsManager.
  40811. * @returns the FreeCameraInputsManager
  40812. */
  40813. addGamepad(): FreeCameraInputsManager;
  40814. }
  40815. /**
  40816. * Interface representing an arc rotate camera inputs manager
  40817. */
  40818. interface ArcRotateCameraInputsManager {
  40819. /**
  40820. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40821. * @returns the camera inputs manager
  40822. */
  40823. addGamepad(): ArcRotateCameraInputsManager;
  40824. }
  40825. /**
  40826. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40827. */
  40828. export class GamepadSystemSceneComponent implements ISceneComponent {
  40829. /**
  40830. * The component name helpfull to identify the component in the list of scene components.
  40831. */
  40832. readonly name: string;
  40833. /**
  40834. * The scene the component belongs to.
  40835. */
  40836. scene: Scene;
  40837. /**
  40838. * Creates a new instance of the component for the given scene
  40839. * @param scene Defines the scene to register the component in
  40840. */
  40841. constructor(scene: Scene);
  40842. /**
  40843. * Registers the component in a given scene
  40844. */
  40845. register(): void;
  40846. /**
  40847. * Rebuilds the elements related to this component in case of
  40848. * context lost for instance.
  40849. */
  40850. rebuild(): void;
  40851. /**
  40852. * Disposes the component and the associated ressources
  40853. */
  40854. dispose(): void;
  40855. private _beforeCameraUpdate;
  40856. }
  40857. }
  40858. declare module BABYLON {
  40859. /**
  40860. * 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,
  40861. * which still works and will still be found in many Playgrounds.
  40862. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40863. */
  40864. export class UniversalCamera extends TouchCamera {
  40865. /**
  40866. * Defines the gamepad rotation sensiblity.
  40867. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40868. */
  40869. gamepadAngularSensibility: number;
  40870. /**
  40871. * Defines the gamepad move sensiblity.
  40872. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40873. */
  40874. gamepadMoveSensibility: number;
  40875. /**
  40876. * 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,
  40877. * which still works and will still be found in many Playgrounds.
  40878. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40879. * @param name Define the name of the camera in the scene
  40880. * @param position Define the start position of the camera in the scene
  40881. * @param scene Define the scene the camera belongs to
  40882. */
  40883. constructor(name: string, position: Vector3, scene: Scene);
  40884. /**
  40885. * Gets the current object class name.
  40886. * @return the class name
  40887. */
  40888. getClassName(): string;
  40889. }
  40890. }
  40891. declare module BABYLON {
  40892. /**
  40893. * This represents a FPS type of camera. This is only here for back compat purpose.
  40894. * Please use the UniversalCamera instead as both are identical.
  40895. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40896. */
  40897. export class GamepadCamera extends UniversalCamera {
  40898. /**
  40899. * Instantiates a new Gamepad Camera
  40900. * This represents a FPS type of camera. This is only here for back compat purpose.
  40901. * Please use the UniversalCamera instead as both are identical.
  40902. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40903. * @param name Define the name of the camera in the scene
  40904. * @param position Define the start position of the camera in the scene
  40905. * @param scene Define the scene the camera belongs to
  40906. */
  40907. constructor(name: string, position: Vector3, scene: Scene);
  40908. /**
  40909. * Gets the current object class name.
  40910. * @return the class name
  40911. */
  40912. getClassName(): string;
  40913. }
  40914. }
  40915. declare module BABYLON {
  40916. /** @hidden */
  40917. export var passPixelShader: {
  40918. name: string;
  40919. shader: string;
  40920. };
  40921. }
  40922. declare module BABYLON {
  40923. /** @hidden */
  40924. export var passCubePixelShader: {
  40925. name: string;
  40926. shader: string;
  40927. };
  40928. }
  40929. declare module BABYLON {
  40930. /**
  40931. * PassPostProcess which produces an output the same as it's input
  40932. */
  40933. export class PassPostProcess extends PostProcess {
  40934. /**
  40935. * Creates the PassPostProcess
  40936. * @param name The name of the effect.
  40937. * @param options The required width/height ratio to downsize to before computing the render pass.
  40938. * @param camera The camera to apply the render pass to.
  40939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40940. * @param engine The engine which the post process will be applied. (default: current engine)
  40941. * @param reusable If the post process can be reused on the same frame. (default: false)
  40942. * @param textureType The type of texture to be used when performing the post processing.
  40943. * @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)
  40944. */
  40945. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40946. }
  40947. /**
  40948. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40949. */
  40950. export class PassCubePostProcess extends PostProcess {
  40951. private _face;
  40952. /**
  40953. * Gets or sets the cube face to display.
  40954. * * 0 is +X
  40955. * * 1 is -X
  40956. * * 2 is +Y
  40957. * * 3 is -Y
  40958. * * 4 is +Z
  40959. * * 5 is -Z
  40960. */
  40961. face: number;
  40962. /**
  40963. * Creates the PassCubePostProcess
  40964. * @param name The name of the effect.
  40965. * @param options The required width/height ratio to downsize to before computing the render pass.
  40966. * @param camera The camera to apply the render pass to.
  40967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40968. * @param engine The engine which the post process will be applied. (default: current engine)
  40969. * @param reusable If the post process can be reused on the same frame. (default: false)
  40970. * @param textureType The type of texture to be used when performing the post processing.
  40971. * @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)
  40972. */
  40973. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40974. }
  40975. }
  40976. declare module BABYLON {
  40977. /** @hidden */
  40978. export var anaglyphPixelShader: {
  40979. name: string;
  40980. shader: string;
  40981. };
  40982. }
  40983. declare module BABYLON {
  40984. /**
  40985. * Postprocess used to generate anaglyphic rendering
  40986. */
  40987. export class AnaglyphPostProcess extends PostProcess {
  40988. private _passedProcess;
  40989. /**
  40990. * Creates a new AnaglyphPostProcess
  40991. * @param name defines postprocess name
  40992. * @param options defines creation options or target ratio scale
  40993. * @param rigCameras defines cameras using this postprocess
  40994. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40995. * @param engine defines hosting engine
  40996. * @param reusable defines if the postprocess will be reused multiple times per frame
  40997. */
  40998. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40999. }
  41000. }
  41001. declare module BABYLON {
  41002. /**
  41003. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41004. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41005. */
  41006. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41007. /**
  41008. * Creates a new AnaglyphArcRotateCamera
  41009. * @param name defines camera name
  41010. * @param alpha defines alpha angle (in radians)
  41011. * @param beta defines beta angle (in radians)
  41012. * @param radius defines radius
  41013. * @param target defines camera target
  41014. * @param interaxialDistance defines distance between each color axis
  41015. * @param scene defines the hosting scene
  41016. */
  41017. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41018. /**
  41019. * Gets camera class name
  41020. * @returns AnaglyphArcRotateCamera
  41021. */
  41022. getClassName(): string;
  41023. }
  41024. }
  41025. declare module BABYLON {
  41026. /**
  41027. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41028. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41029. */
  41030. export class AnaglyphFreeCamera extends FreeCamera {
  41031. /**
  41032. * Creates a new AnaglyphFreeCamera
  41033. * @param name defines camera name
  41034. * @param position defines initial position
  41035. * @param interaxialDistance defines distance between each color axis
  41036. * @param scene defines the hosting scene
  41037. */
  41038. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41039. /**
  41040. * Gets camera class name
  41041. * @returns AnaglyphFreeCamera
  41042. */
  41043. getClassName(): string;
  41044. }
  41045. }
  41046. declare module BABYLON {
  41047. /**
  41048. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41049. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41050. */
  41051. export class AnaglyphGamepadCamera extends GamepadCamera {
  41052. /**
  41053. * Creates a new AnaglyphGamepadCamera
  41054. * @param name defines camera name
  41055. * @param position defines initial position
  41056. * @param interaxialDistance defines distance between each color axis
  41057. * @param scene defines the hosting scene
  41058. */
  41059. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41060. /**
  41061. * Gets camera class name
  41062. * @returns AnaglyphGamepadCamera
  41063. */
  41064. getClassName(): string;
  41065. }
  41066. }
  41067. declare module BABYLON {
  41068. /**
  41069. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41070. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41071. */
  41072. export class AnaglyphUniversalCamera extends UniversalCamera {
  41073. /**
  41074. * Creates a new AnaglyphUniversalCamera
  41075. * @param name defines camera name
  41076. * @param position defines initial position
  41077. * @param interaxialDistance defines distance between each color axis
  41078. * @param scene defines the hosting scene
  41079. */
  41080. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41081. /**
  41082. * Gets camera class name
  41083. * @returns AnaglyphUniversalCamera
  41084. */
  41085. getClassName(): string;
  41086. }
  41087. }
  41088. declare module BABYLON {
  41089. /** @hidden */
  41090. export var stereoscopicInterlacePixelShader: {
  41091. name: string;
  41092. shader: string;
  41093. };
  41094. }
  41095. declare module BABYLON {
  41096. /**
  41097. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41098. */
  41099. export class StereoscopicInterlacePostProcess extends PostProcess {
  41100. private _stepSize;
  41101. private _passedProcess;
  41102. /**
  41103. * Initializes a StereoscopicInterlacePostProcess
  41104. * @param name The name of the effect.
  41105. * @param rigCameras The rig cameras to be appled to the post process
  41106. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41108. * @param engine The engine which the post process will be applied. (default: current engine)
  41109. * @param reusable If the post process can be reused on the same frame. (default: false)
  41110. */
  41111. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41112. }
  41113. }
  41114. declare module BABYLON {
  41115. /**
  41116. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41117. * @see http://doc.babylonjs.com/features/cameras
  41118. */
  41119. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41120. /**
  41121. * Creates a new StereoscopicArcRotateCamera
  41122. * @param name defines camera name
  41123. * @param alpha defines alpha angle (in radians)
  41124. * @param beta defines beta angle (in radians)
  41125. * @param radius defines radius
  41126. * @param target defines camera target
  41127. * @param interaxialDistance defines distance between each color axis
  41128. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41129. * @param scene defines the hosting scene
  41130. */
  41131. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41132. /**
  41133. * Gets camera class name
  41134. * @returns StereoscopicArcRotateCamera
  41135. */
  41136. getClassName(): string;
  41137. }
  41138. }
  41139. declare module BABYLON {
  41140. /**
  41141. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41142. * @see http://doc.babylonjs.com/features/cameras
  41143. */
  41144. export class StereoscopicFreeCamera extends FreeCamera {
  41145. /**
  41146. * Creates a new StereoscopicFreeCamera
  41147. * @param name defines camera name
  41148. * @param position defines initial position
  41149. * @param interaxialDistance defines distance between each color axis
  41150. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41151. * @param scene defines the hosting scene
  41152. */
  41153. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41154. /**
  41155. * Gets camera class name
  41156. * @returns StereoscopicFreeCamera
  41157. */
  41158. getClassName(): string;
  41159. }
  41160. }
  41161. declare module BABYLON {
  41162. /**
  41163. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41164. * @see http://doc.babylonjs.com/features/cameras
  41165. */
  41166. export class StereoscopicGamepadCamera extends GamepadCamera {
  41167. /**
  41168. * Creates a new StereoscopicGamepadCamera
  41169. * @param name defines camera name
  41170. * @param position defines initial position
  41171. * @param interaxialDistance defines distance between each color axis
  41172. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41173. * @param scene defines the hosting scene
  41174. */
  41175. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41176. /**
  41177. * Gets camera class name
  41178. * @returns StereoscopicGamepadCamera
  41179. */
  41180. getClassName(): string;
  41181. }
  41182. }
  41183. declare module BABYLON {
  41184. /**
  41185. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41186. * @see http://doc.babylonjs.com/features/cameras
  41187. */
  41188. export class StereoscopicUniversalCamera extends UniversalCamera {
  41189. /**
  41190. * Creates a new StereoscopicUniversalCamera
  41191. * @param name defines camera name
  41192. * @param position defines initial position
  41193. * @param interaxialDistance defines distance between each color axis
  41194. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41195. * @param scene defines the hosting scene
  41196. */
  41197. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41198. /**
  41199. * Gets camera class name
  41200. * @returns StereoscopicUniversalCamera
  41201. */
  41202. getClassName(): string;
  41203. }
  41204. }
  41205. declare module BABYLON {
  41206. /**
  41207. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41208. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41209. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41210. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41211. */
  41212. export class VirtualJoysticksCamera extends FreeCamera {
  41213. /**
  41214. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41215. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41216. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41217. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41218. * @param name Define the name of the camera in the scene
  41219. * @param position Define the start position of the camera in the scene
  41220. * @param scene Define the scene the camera belongs to
  41221. */
  41222. constructor(name: string, position: Vector3, scene: Scene);
  41223. /**
  41224. * Gets the current object class name.
  41225. * @return the class name
  41226. */
  41227. getClassName(): string;
  41228. }
  41229. }
  41230. declare module BABYLON {
  41231. /**
  41232. * This represents all the required metrics to create a VR camera.
  41233. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41234. */
  41235. export class VRCameraMetrics {
  41236. /**
  41237. * Define the horizontal resolution off the screen.
  41238. */
  41239. hResolution: number;
  41240. /**
  41241. * Define the vertical resolution off the screen.
  41242. */
  41243. vResolution: number;
  41244. /**
  41245. * Define the horizontal screen size.
  41246. */
  41247. hScreenSize: number;
  41248. /**
  41249. * Define the vertical screen size.
  41250. */
  41251. vScreenSize: number;
  41252. /**
  41253. * Define the vertical screen center position.
  41254. */
  41255. vScreenCenter: number;
  41256. /**
  41257. * Define the distance of the eyes to the screen.
  41258. */
  41259. eyeToScreenDistance: number;
  41260. /**
  41261. * Define the distance between both lenses
  41262. */
  41263. lensSeparationDistance: number;
  41264. /**
  41265. * Define the distance between both viewer's eyes.
  41266. */
  41267. interpupillaryDistance: number;
  41268. /**
  41269. * Define the distortion factor of the VR postprocess.
  41270. * Please, touch with care.
  41271. */
  41272. distortionK: number[];
  41273. /**
  41274. * Define the chromatic aberration correction factors for the VR post process.
  41275. */
  41276. chromaAbCorrection: number[];
  41277. /**
  41278. * Define the scale factor of the post process.
  41279. * The smaller the better but the slower.
  41280. */
  41281. postProcessScaleFactor: number;
  41282. /**
  41283. * Define an offset for the lens center.
  41284. */
  41285. lensCenterOffset: number;
  41286. /**
  41287. * Define if the current vr camera should compensate the distortion of the lense or not.
  41288. */
  41289. compensateDistortion: boolean;
  41290. /**
  41291. * Defines if multiview should be enabled when rendering (Default: false)
  41292. */
  41293. multiviewEnabled: boolean;
  41294. /**
  41295. * Gets the rendering aspect ratio based on the provided resolutions.
  41296. */
  41297. readonly aspectRatio: number;
  41298. /**
  41299. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41300. */
  41301. readonly aspectRatioFov: number;
  41302. /**
  41303. * @hidden
  41304. */
  41305. readonly leftHMatrix: Matrix;
  41306. /**
  41307. * @hidden
  41308. */
  41309. readonly rightHMatrix: Matrix;
  41310. /**
  41311. * @hidden
  41312. */
  41313. readonly leftPreViewMatrix: Matrix;
  41314. /**
  41315. * @hidden
  41316. */
  41317. readonly rightPreViewMatrix: Matrix;
  41318. /**
  41319. * Get the default VRMetrics based on the most generic setup.
  41320. * @returns the default vr metrics
  41321. */
  41322. static GetDefault(): VRCameraMetrics;
  41323. }
  41324. }
  41325. declare module BABYLON {
  41326. /** @hidden */
  41327. export var vrDistortionCorrectionPixelShader: {
  41328. name: string;
  41329. shader: string;
  41330. };
  41331. }
  41332. declare module BABYLON {
  41333. /**
  41334. * VRDistortionCorrectionPostProcess used for mobile VR
  41335. */
  41336. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41337. private _isRightEye;
  41338. private _distortionFactors;
  41339. private _postProcessScaleFactor;
  41340. private _lensCenterOffset;
  41341. private _scaleIn;
  41342. private _scaleFactor;
  41343. private _lensCenter;
  41344. /**
  41345. * Initializes the VRDistortionCorrectionPostProcess
  41346. * @param name The name of the effect.
  41347. * @param camera The camera to apply the render pass to.
  41348. * @param isRightEye If this is for the right eye distortion
  41349. * @param vrMetrics All the required metrics for the VR camera
  41350. */
  41351. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41352. }
  41353. }
  41354. declare module BABYLON {
  41355. /**
  41356. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41357. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41358. */
  41359. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41360. /**
  41361. * Creates a new VRDeviceOrientationArcRotateCamera
  41362. * @param name defines camera name
  41363. * @param alpha defines the camera rotation along the logitudinal axis
  41364. * @param beta defines the camera rotation along the latitudinal axis
  41365. * @param radius defines the camera distance from its target
  41366. * @param target defines the camera target
  41367. * @param scene defines the scene the camera belongs to
  41368. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41369. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41370. */
  41371. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41372. /**
  41373. * Gets camera class name
  41374. * @returns VRDeviceOrientationArcRotateCamera
  41375. */
  41376. getClassName(): string;
  41377. }
  41378. }
  41379. declare module BABYLON {
  41380. /**
  41381. * Camera used to simulate VR rendering (based on FreeCamera)
  41382. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41383. */
  41384. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41385. /**
  41386. * Creates a new VRDeviceOrientationFreeCamera
  41387. * @param name defines camera name
  41388. * @param position defines the start position of the camera
  41389. * @param scene defines the scene the camera belongs to
  41390. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41391. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41392. */
  41393. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41394. /**
  41395. * Gets camera class name
  41396. * @returns VRDeviceOrientationFreeCamera
  41397. */
  41398. getClassName(): string;
  41399. }
  41400. }
  41401. declare module BABYLON {
  41402. /**
  41403. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41404. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41405. */
  41406. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41407. /**
  41408. * Creates a new VRDeviceOrientationGamepadCamera
  41409. * @param name defines camera name
  41410. * @param position defines the start position of the camera
  41411. * @param scene defines the scene the camera belongs to
  41412. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41413. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41414. */
  41415. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41416. /**
  41417. * Gets camera class name
  41418. * @returns VRDeviceOrientationGamepadCamera
  41419. */
  41420. getClassName(): string;
  41421. }
  41422. }
  41423. declare module BABYLON {
  41424. /** @hidden */
  41425. export var imageProcessingPixelShader: {
  41426. name: string;
  41427. shader: string;
  41428. };
  41429. }
  41430. declare module BABYLON {
  41431. /**
  41432. * ImageProcessingPostProcess
  41433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41434. */
  41435. export class ImageProcessingPostProcess extends PostProcess {
  41436. /**
  41437. * Default configuration related to image processing available in the PBR Material.
  41438. */
  41439. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41440. /**
  41441. * Gets the image processing configuration used either in this material.
  41442. */
  41443. /**
  41444. * Sets the Default image processing configuration used either in the this material.
  41445. *
  41446. * If sets to null, the scene one is in use.
  41447. */
  41448. imageProcessingConfiguration: ImageProcessingConfiguration;
  41449. /**
  41450. * Keep track of the image processing observer to allow dispose and replace.
  41451. */
  41452. private _imageProcessingObserver;
  41453. /**
  41454. * Attaches a new image processing configuration to the PBR Material.
  41455. * @param configuration
  41456. */
  41457. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41458. /**
  41459. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41460. */
  41461. /**
  41462. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41463. */
  41464. colorCurves: Nullable<ColorCurves>;
  41465. /**
  41466. * Gets wether the color curves effect is enabled.
  41467. */
  41468. /**
  41469. * Sets wether the color curves effect is enabled.
  41470. */
  41471. colorCurvesEnabled: boolean;
  41472. /**
  41473. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41474. */
  41475. /**
  41476. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41477. */
  41478. colorGradingTexture: Nullable<BaseTexture>;
  41479. /**
  41480. * Gets wether the color grading effect is enabled.
  41481. */
  41482. /**
  41483. * Gets wether the color grading effect is enabled.
  41484. */
  41485. colorGradingEnabled: boolean;
  41486. /**
  41487. * Gets exposure used in the effect.
  41488. */
  41489. /**
  41490. * Sets exposure used in the effect.
  41491. */
  41492. exposure: number;
  41493. /**
  41494. * Gets wether tonemapping is enabled or not.
  41495. */
  41496. /**
  41497. * Sets wether tonemapping is enabled or not
  41498. */
  41499. toneMappingEnabled: boolean;
  41500. /**
  41501. * Gets the type of tone mapping effect.
  41502. */
  41503. /**
  41504. * Sets the type of tone mapping effect.
  41505. */
  41506. toneMappingType: number;
  41507. /**
  41508. * Gets contrast used in the effect.
  41509. */
  41510. /**
  41511. * Sets contrast used in the effect.
  41512. */
  41513. contrast: number;
  41514. /**
  41515. * Gets Vignette stretch size.
  41516. */
  41517. /**
  41518. * Sets Vignette stretch size.
  41519. */
  41520. vignetteStretch: number;
  41521. /**
  41522. * Gets Vignette centre X Offset.
  41523. */
  41524. /**
  41525. * Sets Vignette centre X Offset.
  41526. */
  41527. vignetteCentreX: number;
  41528. /**
  41529. * Gets Vignette centre Y Offset.
  41530. */
  41531. /**
  41532. * Sets Vignette centre Y Offset.
  41533. */
  41534. vignetteCentreY: number;
  41535. /**
  41536. * Gets Vignette weight or intensity of the vignette effect.
  41537. */
  41538. /**
  41539. * Sets Vignette weight or intensity of the vignette effect.
  41540. */
  41541. vignetteWeight: number;
  41542. /**
  41543. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41544. * if vignetteEnabled is set to true.
  41545. */
  41546. /**
  41547. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41548. * if vignetteEnabled is set to true.
  41549. */
  41550. vignetteColor: Color4;
  41551. /**
  41552. * Gets Camera field of view used by the Vignette effect.
  41553. */
  41554. /**
  41555. * Sets Camera field of view used by the Vignette effect.
  41556. */
  41557. vignetteCameraFov: number;
  41558. /**
  41559. * Gets the vignette blend mode allowing different kind of effect.
  41560. */
  41561. /**
  41562. * Sets the vignette blend mode allowing different kind of effect.
  41563. */
  41564. vignetteBlendMode: number;
  41565. /**
  41566. * Gets wether the vignette effect is enabled.
  41567. */
  41568. /**
  41569. * Sets wether the vignette effect is enabled.
  41570. */
  41571. vignetteEnabled: boolean;
  41572. private _fromLinearSpace;
  41573. /**
  41574. * Gets wether the input of the processing is in Gamma or Linear Space.
  41575. */
  41576. /**
  41577. * Sets wether the input of the processing is in Gamma or Linear Space.
  41578. */
  41579. fromLinearSpace: boolean;
  41580. /**
  41581. * Defines cache preventing GC.
  41582. */
  41583. private _defines;
  41584. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41585. /**
  41586. * "ImageProcessingPostProcess"
  41587. * @returns "ImageProcessingPostProcess"
  41588. */
  41589. getClassName(): string;
  41590. protected _updateParameters(): void;
  41591. dispose(camera?: Camera): void;
  41592. }
  41593. }
  41594. declare module BABYLON {
  41595. /**
  41596. * Class containing static functions to help procedurally build meshes
  41597. */
  41598. export class GroundBuilder {
  41599. /**
  41600. * Creates a ground mesh
  41601. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41602. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41604. * @param name defines the name of the mesh
  41605. * @param options defines the options used to create the mesh
  41606. * @param scene defines the hosting scene
  41607. * @returns the ground mesh
  41608. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41609. */
  41610. static CreateGround(name: string, options: {
  41611. width?: number;
  41612. height?: number;
  41613. subdivisions?: number;
  41614. subdivisionsX?: number;
  41615. subdivisionsY?: number;
  41616. updatable?: boolean;
  41617. }, scene: any): Mesh;
  41618. /**
  41619. * Creates a tiled ground mesh
  41620. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41621. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41622. * * 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
  41623. * * 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
  41624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41625. * @param name defines the name of the mesh
  41626. * @param options defines the options used to create the mesh
  41627. * @param scene defines the hosting scene
  41628. * @returns the tiled ground mesh
  41629. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41630. */
  41631. static CreateTiledGround(name: string, options: {
  41632. xmin: number;
  41633. zmin: number;
  41634. xmax: number;
  41635. zmax: number;
  41636. subdivisions?: {
  41637. w: number;
  41638. h: number;
  41639. };
  41640. precision?: {
  41641. w: number;
  41642. h: number;
  41643. };
  41644. updatable?: boolean;
  41645. }, scene?: Nullable<Scene>): Mesh;
  41646. /**
  41647. * Creates a ground mesh from a height map
  41648. * * The parameter `url` sets the URL of the height map image resource.
  41649. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41650. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41651. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41652. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41653. * * 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.
  41654. * * 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).
  41655. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41657. * @param name defines the name of the mesh
  41658. * @param url defines the url to the height map
  41659. * @param options defines the options used to create the mesh
  41660. * @param scene defines the hosting scene
  41661. * @returns the ground mesh
  41662. * @see https://doc.babylonjs.com/babylon101/height_map
  41663. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41664. */
  41665. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41666. width?: number;
  41667. height?: number;
  41668. subdivisions?: number;
  41669. minHeight?: number;
  41670. maxHeight?: number;
  41671. colorFilter?: Color3;
  41672. alphaFilter?: number;
  41673. updatable?: boolean;
  41674. onReady?: (mesh: GroundMesh) => void;
  41675. }, scene?: Nullable<Scene>): GroundMesh;
  41676. }
  41677. }
  41678. declare module BABYLON {
  41679. /**
  41680. * Class containing static functions to help procedurally build meshes
  41681. */
  41682. export class TorusBuilder {
  41683. /**
  41684. * Creates a torus mesh
  41685. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41686. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41687. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41689. * * 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
  41690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41691. * @param name defines the name of the mesh
  41692. * @param options defines the options used to create the mesh
  41693. * @param scene defines the hosting scene
  41694. * @returns the torus mesh
  41695. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41696. */
  41697. static CreateTorus(name: string, options: {
  41698. diameter?: number;
  41699. thickness?: number;
  41700. tessellation?: number;
  41701. updatable?: boolean;
  41702. sideOrientation?: number;
  41703. frontUVs?: Vector4;
  41704. backUVs?: Vector4;
  41705. }, scene: any): Mesh;
  41706. }
  41707. }
  41708. declare module BABYLON {
  41709. /**
  41710. * Class containing static functions to help procedurally build meshes
  41711. */
  41712. export class CylinderBuilder {
  41713. /**
  41714. * Creates a cylinder or a cone mesh
  41715. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41716. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41717. * * 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.
  41718. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41719. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41720. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41721. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41722. * * 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).
  41723. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41724. * * 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).
  41725. * * 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
  41726. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41727. * * 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
  41728. * * 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.
  41729. * * If `enclose` is false, a ring surface is one element.
  41730. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41731. * * 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
  41732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41733. * * 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
  41734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41735. * @param name defines the name of the mesh
  41736. * @param options defines the options used to create the mesh
  41737. * @param scene defines the hosting scene
  41738. * @returns the cylinder mesh
  41739. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41740. */
  41741. static CreateCylinder(name: string, options: {
  41742. height?: number;
  41743. diameterTop?: number;
  41744. diameterBottom?: number;
  41745. diameter?: number;
  41746. tessellation?: number;
  41747. subdivisions?: number;
  41748. arc?: number;
  41749. faceColors?: Color4[];
  41750. faceUV?: Vector4[];
  41751. updatable?: boolean;
  41752. hasRings?: boolean;
  41753. enclose?: boolean;
  41754. cap?: number;
  41755. sideOrientation?: number;
  41756. frontUVs?: Vector4;
  41757. backUVs?: Vector4;
  41758. }, scene: any): Mesh;
  41759. }
  41760. }
  41761. declare module BABYLON {
  41762. /**
  41763. * States of the webXR experience
  41764. */
  41765. export enum WebXRState {
  41766. /**
  41767. * Transitioning to being in XR mode
  41768. */
  41769. ENTERING_XR = 0,
  41770. /**
  41771. * Transitioning to non XR mode
  41772. */
  41773. EXITING_XR = 1,
  41774. /**
  41775. * In XR mode and presenting
  41776. */
  41777. IN_XR = 2,
  41778. /**
  41779. * Not entered XR mode
  41780. */
  41781. NOT_IN_XR = 3
  41782. }
  41783. /**
  41784. * Abstraction of the XR render target
  41785. */
  41786. export interface WebXRRenderTarget extends IDisposable {
  41787. /**
  41788. * xrpresent context of the canvas which can be used to display/mirror xr content
  41789. */
  41790. canvasContext: WebGLRenderingContext;
  41791. /**
  41792. * xr layer for the canvas
  41793. */
  41794. xrLayer: Nullable<XRWebGLLayer>;
  41795. /**
  41796. * Initializes the xr layer for the session
  41797. * @param xrSession xr session
  41798. * @returns a promise that will resolve once the XR Layer has been created
  41799. */
  41800. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41801. }
  41802. }
  41803. declare module BABYLON {
  41804. /**
  41805. * COnfiguration object for WebXR output canvas
  41806. */
  41807. export class WebXRManagedOutputCanvasOptions {
  41808. /**
  41809. * Options for this XR Layer output
  41810. */
  41811. canvasOptions: XRWebGLLayerOptions;
  41812. /**
  41813. * CSS styling for a newly created canvas (if not provided)
  41814. */
  41815. newCanvasCssStyle?: string;
  41816. /**
  41817. * Get the default values of the configuration object
  41818. * @returns default values of this configuration object
  41819. */
  41820. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  41821. }
  41822. /**
  41823. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41824. */
  41825. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41826. private configuration;
  41827. private _engine;
  41828. private _canvas;
  41829. /**
  41830. * xrpresent context of the canvas which can be used to display/mirror xr content
  41831. */
  41832. canvasContext: WebGLRenderingContext;
  41833. /**
  41834. * xr layer for the canvas
  41835. */
  41836. xrLayer: Nullable<XRWebGLLayer>;
  41837. /**
  41838. * Initializes the xr layer for the session
  41839. * @param xrSession xr session
  41840. * @returns a promise that will resolve once the XR Layer has been created
  41841. */
  41842. initializeXRLayerAsync(xrSession: any): any;
  41843. /**
  41844. * Initializes the canvas to be added/removed upon entering/exiting xr
  41845. * @param engine the Babylon engine
  41846. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41847. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41848. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  41849. */
  41850. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  41851. /**
  41852. * Disposes of the object
  41853. */
  41854. dispose(): void;
  41855. private _setManagedOutputCanvas;
  41856. private _addCanvas;
  41857. private _removeCanvas;
  41858. }
  41859. }
  41860. declare module BABYLON {
  41861. /**
  41862. * Manages an XRSession to work with Babylon's engine
  41863. * @see https://doc.babylonjs.com/how_to/webxr
  41864. */
  41865. export class WebXRSessionManager implements IDisposable {
  41866. /** The scene which the session should be created for */
  41867. scene: Scene;
  41868. /**
  41869. * Fires every time a new xrFrame arrives which can be used to update the camera
  41870. */
  41871. onXRFrameObservable: Observable<XRFrame>;
  41872. /**
  41873. * Fires when the xr session is ended either by the device or manually done
  41874. */
  41875. onXRSessionEnded: Observable<any>;
  41876. /**
  41877. * Fires when the xr session is ended either by the device or manually done
  41878. */
  41879. onXRSessionInit: Observable<XRSession>;
  41880. /**
  41881. * Underlying xr session
  41882. */
  41883. session: XRSession;
  41884. /**
  41885. * Type of reference space used when creating the session
  41886. */
  41887. referenceSpace: XRReferenceSpace;
  41888. /**
  41889. * Current XR frame
  41890. */
  41891. currentFrame: Nullable<XRFrame>;
  41892. /** WebXR timestamp updated every frame */
  41893. currentTimestamp: number;
  41894. private _xrNavigator;
  41895. private baseLayer;
  41896. private _rttProvider;
  41897. private _sessionEnded;
  41898. /**
  41899. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41900. * @param scene The scene which the session should be created for
  41901. */
  41902. constructor(
  41903. /** The scene which the session should be created for */
  41904. scene: Scene);
  41905. /**
  41906. * Initializes the manager
  41907. * After initialization enterXR can be called to start an XR session
  41908. * @returns Promise which resolves after it is initialized
  41909. */
  41910. initializeAsync(): Promise<void>;
  41911. /**
  41912. * Initializes an xr session
  41913. * @param xrSessionMode mode to initialize
  41914. * @param optionalFeatures defines optional values to pass to the session builder
  41915. * @returns a promise which will resolve once the session has been initialized
  41916. */
  41917. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  41918. /**
  41919. * Sets the reference space on the xr session
  41920. * @param referenceSpace space to set
  41921. * @returns a promise that will resolve once the reference space has been set
  41922. */
  41923. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41924. /**
  41925. * Updates the render state of the session
  41926. * @param state state to set
  41927. * @returns a promise that resolves once the render state has been updated
  41928. */
  41929. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41930. /**
  41931. * Starts rendering to the xr layer
  41932. * @returns a promise that will resolve once rendering has started
  41933. */
  41934. startRenderingToXRAsync(): Promise<void>;
  41935. /**
  41936. * Gets the correct render target texture to be rendered this frame for this eye
  41937. * @param eye the eye for which to get the render target
  41938. * @returns the render target for the specified eye
  41939. */
  41940. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41941. /**
  41942. * Stops the xrSession and restores the renderloop
  41943. * @returns Promise which resolves after it exits XR
  41944. */
  41945. exitXRAsync(): Promise<void>;
  41946. /**
  41947. * Checks if a session would be supported for the creation options specified
  41948. * @param sessionMode session mode to check if supported eg. immersive-vr
  41949. * @returns true if supported
  41950. */
  41951. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41952. /**
  41953. * Creates a WebXRRenderTarget object for the XR session
  41954. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41955. * @param options optional options to provide when creating a new render target
  41956. * @returns a WebXR render target to which the session can render
  41957. */
  41958. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  41959. /**
  41960. * @hidden
  41961. * Converts the render layer of xrSession to a render target
  41962. * @param session session to create render target for
  41963. * @param scene scene the new render target should be created for
  41964. * @param baseLayer the webgl layer to create the render target for
  41965. */
  41966. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41967. /**
  41968. * Disposes of the session manager
  41969. */
  41970. dispose(): void;
  41971. /**
  41972. * Gets a promise returning true when fullfiled if the given session mode is supported
  41973. * @param sessionMode defines the session to test
  41974. * @returns a promise
  41975. */
  41976. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41977. }
  41978. }
  41979. declare module BABYLON {
  41980. /**
  41981. * WebXR Camera which holds the views for the xrSession
  41982. * @see https://doc.babylonjs.com/how_to/webxr
  41983. */
  41984. export class WebXRCamera extends FreeCamera {
  41985. /**
  41986. * Is the camera in debug mode. Used when using an emulator
  41987. */
  41988. debugMode: boolean;
  41989. /**
  41990. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41991. * @param name the name of the camera
  41992. * @param scene the scene to add the camera to
  41993. */
  41994. constructor(name: string, scene: Scene);
  41995. private _updateNumberOfRigCameras;
  41996. /** @hidden */
  41997. _updateForDualEyeDebugging(): void;
  41998. /**
  41999. * Updates the cameras position from the current pose information of the XR session
  42000. * @param xrSessionManager the session containing pose information
  42001. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42002. */
  42003. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42004. }
  42005. }
  42006. declare module BABYLON {
  42007. /**
  42008. * Defining the interface required for a (webxr) feature
  42009. */
  42010. export interface IWebXRFeature extends IDisposable {
  42011. /**
  42012. * Attach the feature to the session
  42013. * Will usually be called by the features manager
  42014. *
  42015. * @returns true if successful.
  42016. */
  42017. attach(): boolean;
  42018. /**
  42019. * Detach the feature from the session
  42020. * Will usually be called by the features manager
  42021. *
  42022. * @returns true if successful.
  42023. */
  42024. detach(): boolean;
  42025. }
  42026. /**
  42027. * Defining the constructor of a feature. Used to register the modules.
  42028. */
  42029. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42030. /**
  42031. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42032. * It is mainly used in AR sessions.
  42033. *
  42034. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42035. */
  42036. export class WebXRFeaturesManager implements IDisposable {
  42037. private _xrSessionManager;
  42038. private static readonly _AvailableFeatures;
  42039. /**
  42040. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42041. * Mainly used internally.
  42042. *
  42043. * @param featureName the name of the feature to register
  42044. * @param constructorFunction the function used to construct the module
  42045. * @param version the (babylon) version of the module
  42046. * @param stable is that a stable version of this module
  42047. */
  42048. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42049. /**
  42050. * Returns a constructor of a specific feature.
  42051. *
  42052. * @param featureName the name of the feature to construct
  42053. * @param version the version of the feature to load
  42054. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42055. * @param options optional options provided to the module.
  42056. * @returns a function that, when called, will return a new instance of this feature
  42057. */
  42058. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42059. /**
  42060. * Return the latest unstable version of this feature
  42061. * @param featureName the name of the feature to search
  42062. * @returns the version number. if not found will return -1
  42063. */
  42064. static GetLatestVersionOfFeature(featureName: string): number;
  42065. /**
  42066. * Return the latest stable version of this feature
  42067. * @param featureName the name of the feature to search
  42068. * @returns the version number. if not found will return -1
  42069. */
  42070. static GetStableVersionOfFeature(featureName: string): number;
  42071. /**
  42072. * Can be used to return the list of features currently registered
  42073. *
  42074. * @returns an Array of available features
  42075. */
  42076. static GetAvailableFeatures(): string[];
  42077. /**
  42078. * Gets the versions available for a specific feature
  42079. * @param featureName the name of the feature
  42080. * @returns an array with the available versions
  42081. */
  42082. static GetAvailableVersions(featureName: string): string[];
  42083. private _features;
  42084. /**
  42085. * constructs a new features manages.
  42086. *
  42087. * @param _xrSessionManager an instance of WebXRSessionManager
  42088. */
  42089. constructor(_xrSessionManager: WebXRSessionManager);
  42090. /**
  42091. * 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.
  42092. *
  42093. * @param featureName the name of the feature to load or the class of the feature
  42094. * @param version optional version to load. if not provided the latest version will be enabled
  42095. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42096. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42097. * @returns a new constructed feature or throws an error if feature not found.
  42098. */
  42099. enableFeature(featureName: string | {
  42100. Name: string;
  42101. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42102. /**
  42103. * Used to disable an already-enabled feature
  42104. * @param featureName the feature to disable
  42105. * @returns true if disable was successful
  42106. */
  42107. disableFeature(featureName: string | {
  42108. Name: string;
  42109. }): boolean;
  42110. /**
  42111. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42112. * Can be used during a session to start a feature
  42113. * @param featureName the name of feature to attach
  42114. */
  42115. attachFeature(featureName: string): void;
  42116. /**
  42117. * Can be used inside a session or when the session ends to detach a specific feature
  42118. * @param featureName the name of the feature to detach
  42119. */
  42120. detachFeature(featureName: string): void;
  42121. /**
  42122. * Get the list of enabled features
  42123. * @returns an array of enabled features
  42124. */
  42125. getEnabledFeatures(): string[];
  42126. /**
  42127. * get the implementation of an enabled feature.
  42128. * @param featureName the name of the feature to load
  42129. * @returns the feature class, if found
  42130. */
  42131. getEnabledFeature(featureName: string): IWebXRFeature;
  42132. /**
  42133. * dispose this features manager
  42134. */
  42135. dispose(): void;
  42136. }
  42137. }
  42138. declare module BABYLON {
  42139. /**
  42140. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42141. * @see https://doc.babylonjs.com/how_to/webxr
  42142. */
  42143. export class WebXRExperienceHelper implements IDisposable {
  42144. private scene;
  42145. /**
  42146. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42147. */
  42148. container: AbstractMesh;
  42149. /**
  42150. * Camera used to render xr content
  42151. */
  42152. camera: WebXRCamera;
  42153. /**
  42154. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42155. */
  42156. state: WebXRState;
  42157. private _setState;
  42158. private static _TmpVector;
  42159. /**
  42160. * Fires when the state of the experience helper has changed
  42161. */
  42162. onStateChangedObservable: Observable<WebXRState>;
  42163. /** Session manager used to keep track of xr session */
  42164. sessionManager: WebXRSessionManager;
  42165. /** A features manager for this xr session */
  42166. featuresManager: WebXRFeaturesManager;
  42167. private _nonVRCamera;
  42168. private _originalSceneAutoClear;
  42169. private _supported;
  42170. /**
  42171. * Creates the experience helper
  42172. * @param scene the scene to attach the experience helper to
  42173. * @returns a promise for the experience helper
  42174. */
  42175. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42176. /**
  42177. * Creates a WebXRExperienceHelper
  42178. * @param scene The scene the helper should be created in
  42179. */
  42180. private constructor();
  42181. /**
  42182. * Exits XR mode and returns the scene to its original state
  42183. * @returns promise that resolves after xr mode has exited
  42184. */
  42185. exitXRAsync(): Promise<void>;
  42186. /**
  42187. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42188. * @param sessionMode options for the XR session
  42189. * @param referenceSpaceType frame of reference of the XR session
  42190. * @param renderTarget the output canvas that will be used to enter XR mode
  42191. * @returns promise that resolves after xr mode has entered
  42192. */
  42193. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42194. /**
  42195. * Updates the global position of the camera by moving the camera's container
  42196. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42197. * @param position The desired global position of the camera
  42198. */
  42199. setPositionOfCameraUsingContainer(position: Vector3): void;
  42200. /**
  42201. * Rotates the xr camera by rotating the camera's container around the camera's position
  42202. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42203. * @param rotation the desired quaternion rotation to apply to the camera
  42204. */
  42205. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42206. /**
  42207. * Disposes of the experience helper
  42208. */
  42209. dispose(): void;
  42210. }
  42211. }
  42212. declare module BABYLON {
  42213. /**
  42214. * Represents an XR input
  42215. */
  42216. export class WebXRController {
  42217. private scene;
  42218. /** The underlying input source for the controller */
  42219. inputSource: XRInputSource;
  42220. private parentContainer;
  42221. /**
  42222. * 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
  42223. */
  42224. grip?: AbstractMesh;
  42225. /**
  42226. * Pointer which can be used to select objects or attach a visible laser to
  42227. */
  42228. pointer: AbstractMesh;
  42229. private _gamepadMode;
  42230. /**
  42231. * If available, this is the gamepad object related to this controller.
  42232. * Using this object it is possible to get click events and trackpad changes of the
  42233. * webxr controller that is currently being used.
  42234. */
  42235. gamepadController?: WebVRController;
  42236. /**
  42237. * Event that fires when the controller is removed/disposed
  42238. */
  42239. onDisposeObservable: Observable<{}>;
  42240. private _tmpQuaternion;
  42241. private _tmpVector;
  42242. /**
  42243. * Creates the controller
  42244. * @see https://doc.babylonjs.com/how_to/webxr
  42245. * @param scene the scene which the controller should be associated to
  42246. * @param inputSource the underlying input source for the controller
  42247. * @param parentContainer parent that the controller meshes should be children of
  42248. */
  42249. constructor(scene: Scene,
  42250. /** The underlying input source for the controller */
  42251. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42252. /**
  42253. * Updates the controller pose based on the given XRFrame
  42254. * @param xrFrame xr frame to update the pose with
  42255. * @param referenceSpace reference space to use
  42256. */
  42257. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42258. /**
  42259. * Gets a world space ray coming from the controller
  42260. * @param result the resulting ray
  42261. */
  42262. getWorldPointerRayToRef(result: Ray): void;
  42263. /**
  42264. * Get the scene associated with this controller
  42265. * @returns the scene object
  42266. */
  42267. getScene(): Scene;
  42268. /**
  42269. * Disposes of the object
  42270. */
  42271. dispose(): void;
  42272. }
  42273. }
  42274. declare module BABYLON {
  42275. /**
  42276. * XR input used to track XR inputs such as controllers/rays
  42277. */
  42278. export class WebXRInput implements IDisposable {
  42279. /**
  42280. * Base experience the input listens to
  42281. */
  42282. baseExperience: WebXRExperienceHelper;
  42283. /**
  42284. * XR controllers being tracked
  42285. */
  42286. controllers: Array<WebXRController>;
  42287. private _frameObserver;
  42288. private _stateObserver;
  42289. /**
  42290. * Event when a controller has been connected/added
  42291. */
  42292. onControllerAddedObservable: Observable<WebXRController>;
  42293. /**
  42294. * Event when a controller has been removed/disconnected
  42295. */
  42296. onControllerRemovedObservable: Observable<WebXRController>;
  42297. /**
  42298. * Initializes the WebXRInput
  42299. * @param baseExperience experience helper which the input should be created for
  42300. */
  42301. constructor(
  42302. /**
  42303. * Base experience the input listens to
  42304. */
  42305. baseExperience: WebXRExperienceHelper);
  42306. private _onInputSourcesChange;
  42307. private _addAndRemoveControllers;
  42308. /**
  42309. * Disposes of the object
  42310. */
  42311. dispose(): void;
  42312. }
  42313. }
  42314. declare module BABYLON {
  42315. /**
  42316. * Class used to represent data loading progression
  42317. */
  42318. export class SceneLoaderProgressEvent {
  42319. /** defines if data length to load can be evaluated */
  42320. readonly lengthComputable: boolean;
  42321. /** defines the loaded data length */
  42322. readonly loaded: number;
  42323. /** defines the data length to load */
  42324. readonly total: number;
  42325. /**
  42326. * Create a new progress event
  42327. * @param lengthComputable defines if data length to load can be evaluated
  42328. * @param loaded defines the loaded data length
  42329. * @param total defines the data length to load
  42330. */
  42331. constructor(
  42332. /** defines if data length to load can be evaluated */
  42333. lengthComputable: boolean,
  42334. /** defines the loaded data length */
  42335. loaded: number,
  42336. /** defines the data length to load */
  42337. total: number);
  42338. /**
  42339. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42340. * @param event defines the source event
  42341. * @returns a new SceneLoaderProgressEvent
  42342. */
  42343. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42344. }
  42345. /**
  42346. * Interface used by SceneLoader plugins to define supported file extensions
  42347. */
  42348. export interface ISceneLoaderPluginExtensions {
  42349. /**
  42350. * Defines the list of supported extensions
  42351. */
  42352. [extension: string]: {
  42353. isBinary: boolean;
  42354. };
  42355. }
  42356. /**
  42357. * Interface used by SceneLoader plugin factory
  42358. */
  42359. export interface ISceneLoaderPluginFactory {
  42360. /**
  42361. * Defines the name of the factory
  42362. */
  42363. name: string;
  42364. /**
  42365. * Function called to create a new plugin
  42366. * @return the new plugin
  42367. */
  42368. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42369. /**
  42370. * The callback that returns true if the data can be directly loaded.
  42371. * @param data string containing the file data
  42372. * @returns if the data can be loaded directly
  42373. */
  42374. canDirectLoad?(data: string): boolean;
  42375. }
  42376. /**
  42377. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42378. */
  42379. export interface ISceneLoaderPluginBase {
  42380. /**
  42381. * The friendly name of this plugin.
  42382. */
  42383. name: string;
  42384. /**
  42385. * The file extensions supported by this plugin.
  42386. */
  42387. extensions: string | ISceneLoaderPluginExtensions;
  42388. /**
  42389. * The callback called when loading from a url.
  42390. * @param scene scene loading this url
  42391. * @param url url to load
  42392. * @param onSuccess callback called when the file successfully loads
  42393. * @param onProgress callback called while file is loading (if the server supports this mode)
  42394. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42395. * @param onError callback called when the file fails to load
  42396. * @returns a file request object
  42397. */
  42398. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42399. /**
  42400. * The callback called when loading from a file object.
  42401. * @param scene scene loading this file
  42402. * @param file defines the file to load
  42403. * @param onSuccess defines the callback to call when data is loaded
  42404. * @param onProgress defines the callback to call during loading process
  42405. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42406. * @param onError defines the callback to call when an error occurs
  42407. * @returns a file request object
  42408. */
  42409. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42410. /**
  42411. * The callback that returns true if the data can be directly loaded.
  42412. * @param data string containing the file data
  42413. * @returns if the data can be loaded directly
  42414. */
  42415. canDirectLoad?(data: string): boolean;
  42416. /**
  42417. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42418. * @param scene scene loading this data
  42419. * @param data string containing the data
  42420. * @returns data to pass to the plugin
  42421. */
  42422. directLoad?(scene: Scene, data: string): any;
  42423. /**
  42424. * The callback that allows custom handling of the root url based on the response url.
  42425. * @param rootUrl the original root url
  42426. * @param responseURL the response url if available
  42427. * @returns the new root url
  42428. */
  42429. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42430. }
  42431. /**
  42432. * Interface used to define a SceneLoader plugin
  42433. */
  42434. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42435. /**
  42436. * Import meshes into a scene.
  42437. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42438. * @param scene The scene to import into
  42439. * @param data The data to import
  42440. * @param rootUrl The root url for scene and resources
  42441. * @param meshes The meshes array to import into
  42442. * @param particleSystems The particle systems array to import into
  42443. * @param skeletons The skeletons array to import into
  42444. * @param onError The callback when import fails
  42445. * @returns True if successful or false otherwise
  42446. */
  42447. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42448. /**
  42449. * Load into a scene.
  42450. * @param scene The scene to load into
  42451. * @param data The data to import
  42452. * @param rootUrl The root url for scene and resources
  42453. * @param onError The callback when import fails
  42454. * @returns True if successful or false otherwise
  42455. */
  42456. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42457. /**
  42458. * Load into an asset container.
  42459. * @param scene The scene to load into
  42460. * @param data The data to import
  42461. * @param rootUrl The root url for scene and resources
  42462. * @param onError The callback when import fails
  42463. * @returns The loaded asset container
  42464. */
  42465. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42466. }
  42467. /**
  42468. * Interface used to define an async SceneLoader plugin
  42469. */
  42470. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42471. /**
  42472. * Import meshes into a scene.
  42473. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42474. * @param scene The scene to import into
  42475. * @param data The data to import
  42476. * @param rootUrl The root url for scene and resources
  42477. * @param onProgress The callback when the load progresses
  42478. * @param fileName Defines the name of the file to load
  42479. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42480. */
  42481. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42482. meshes: AbstractMesh[];
  42483. particleSystems: IParticleSystem[];
  42484. skeletons: Skeleton[];
  42485. animationGroups: AnimationGroup[];
  42486. }>;
  42487. /**
  42488. * Load into a scene.
  42489. * @param scene The scene to load into
  42490. * @param data The data to import
  42491. * @param rootUrl The root url for scene and resources
  42492. * @param onProgress The callback when the load progresses
  42493. * @param fileName Defines the name of the file to load
  42494. * @returns Nothing
  42495. */
  42496. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42497. /**
  42498. * Load into an asset container.
  42499. * @param scene The scene to load into
  42500. * @param data The data to import
  42501. * @param rootUrl The root url for scene and resources
  42502. * @param onProgress The callback when the load progresses
  42503. * @param fileName Defines the name of the file to load
  42504. * @returns The loaded asset container
  42505. */
  42506. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42507. }
  42508. /**
  42509. * Mode that determines how to handle old animation groups before loading new ones.
  42510. */
  42511. export enum SceneLoaderAnimationGroupLoadingMode {
  42512. /**
  42513. * Reset all old animations to initial state then dispose them.
  42514. */
  42515. Clean = 0,
  42516. /**
  42517. * Stop all old animations.
  42518. */
  42519. Stop = 1,
  42520. /**
  42521. * Restart old animations from first frame.
  42522. */
  42523. Sync = 2,
  42524. /**
  42525. * Old animations remains untouched.
  42526. */
  42527. NoSync = 3
  42528. }
  42529. /**
  42530. * Class used to load scene from various file formats using registered plugins
  42531. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42532. */
  42533. export class SceneLoader {
  42534. /**
  42535. * No logging while loading
  42536. */
  42537. static readonly NO_LOGGING: number;
  42538. /**
  42539. * Minimal logging while loading
  42540. */
  42541. static readonly MINIMAL_LOGGING: number;
  42542. /**
  42543. * Summary logging while loading
  42544. */
  42545. static readonly SUMMARY_LOGGING: number;
  42546. /**
  42547. * Detailled logging while loading
  42548. */
  42549. static readonly DETAILED_LOGGING: number;
  42550. /**
  42551. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42552. */
  42553. static ForceFullSceneLoadingForIncremental: boolean;
  42554. /**
  42555. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42556. */
  42557. static ShowLoadingScreen: boolean;
  42558. /**
  42559. * Defines the current logging level (while loading the scene)
  42560. * @ignorenaming
  42561. */
  42562. static loggingLevel: number;
  42563. /**
  42564. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42565. */
  42566. static CleanBoneMatrixWeights: boolean;
  42567. /**
  42568. * Event raised when a plugin is used to load a scene
  42569. */
  42570. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42571. private static _registeredPlugins;
  42572. private static _getDefaultPlugin;
  42573. private static _getPluginForExtension;
  42574. private static _getPluginForDirectLoad;
  42575. private static _getPluginForFilename;
  42576. private static _getDirectLoad;
  42577. private static _loadData;
  42578. private static _getFileInfo;
  42579. /**
  42580. * Gets a plugin that can load the given extension
  42581. * @param extension defines the extension to load
  42582. * @returns a plugin or null if none works
  42583. */
  42584. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42585. /**
  42586. * Gets a boolean indicating that the given extension can be loaded
  42587. * @param extension defines the extension to load
  42588. * @returns true if the extension is supported
  42589. */
  42590. static IsPluginForExtensionAvailable(extension: string): boolean;
  42591. /**
  42592. * Adds a new plugin to the list of registered plugins
  42593. * @param plugin defines the plugin to add
  42594. */
  42595. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42596. /**
  42597. * Import meshes into a scene
  42598. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42599. * @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)
  42600. * @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)
  42601. * @param scene the instance of BABYLON.Scene to append to
  42602. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42603. * @param onProgress a callback with a progress event for each file being loaded
  42604. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42605. * @param pluginExtension the extension used to determine the plugin
  42606. * @returns The loaded plugin
  42607. */
  42608. 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>;
  42609. /**
  42610. * Import meshes into a scene
  42611. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42612. * @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)
  42613. * @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)
  42614. * @param scene the instance of BABYLON.Scene to append to
  42615. * @param onProgress a callback with a progress event for each file being loaded
  42616. * @param pluginExtension the extension used to determine the plugin
  42617. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42618. */
  42619. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42620. meshes: AbstractMesh[];
  42621. particleSystems: IParticleSystem[];
  42622. skeletons: Skeleton[];
  42623. animationGroups: AnimationGroup[];
  42624. }>;
  42625. /**
  42626. * Load a scene
  42627. * @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)
  42628. * @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)
  42629. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42630. * @param onSuccess a callback with the scene when import succeeds
  42631. * @param onProgress a callback with a progress event for each file being loaded
  42632. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42633. * @param pluginExtension the extension used to determine the plugin
  42634. * @returns The loaded plugin
  42635. */
  42636. 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>;
  42637. /**
  42638. * Load a scene
  42639. * @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)
  42640. * @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)
  42641. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42642. * @param onProgress a callback with a progress event for each file being loaded
  42643. * @param pluginExtension the extension used to determine the plugin
  42644. * @returns The loaded scene
  42645. */
  42646. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42647. /**
  42648. * Append a scene
  42649. * @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)
  42650. * @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)
  42651. * @param scene is the instance of BABYLON.Scene to append to
  42652. * @param onSuccess a callback with the scene when import succeeds
  42653. * @param onProgress a callback with a progress event for each file being loaded
  42654. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42655. * @param pluginExtension the extension used to determine the plugin
  42656. * @returns The loaded plugin
  42657. */
  42658. 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>;
  42659. /**
  42660. * Append a scene
  42661. * @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)
  42662. * @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)
  42663. * @param scene is the instance of BABYLON.Scene to append to
  42664. * @param onProgress a callback with a progress event for each file being loaded
  42665. * @param pluginExtension the extension used to determine the plugin
  42666. * @returns The given scene
  42667. */
  42668. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42669. /**
  42670. * Load a scene into an asset container
  42671. * @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)
  42672. * @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)
  42673. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42674. * @param onSuccess a callback with the scene when import succeeds
  42675. * @param onProgress a callback with a progress event for each file being loaded
  42676. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42677. * @param pluginExtension the extension used to determine the plugin
  42678. * @returns The loaded plugin
  42679. */
  42680. 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>;
  42681. /**
  42682. * Load a scene into an asset container
  42683. * @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)
  42684. * @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)
  42685. * @param scene is the instance of Scene to append to
  42686. * @param onProgress a callback with a progress event for each file being loaded
  42687. * @param pluginExtension the extension used to determine the plugin
  42688. * @returns The loaded asset container
  42689. */
  42690. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42691. /**
  42692. * Import animations from a file into a scene
  42693. * @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)
  42694. * @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)
  42695. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42696. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  42697. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  42698. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  42699. * @param onSuccess a callback with the scene when import succeeds
  42700. * @param onProgress a callback with a progress event for each file being loaded
  42701. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42702. */
  42703. 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;
  42704. /**
  42705. * Import animations from a file into a scene
  42706. * @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)
  42707. * @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)
  42708. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42709. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  42710. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  42711. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  42712. * @param onSuccess a callback with the scene when import succeeds
  42713. * @param onProgress a callback with a progress event for each file being loaded
  42714. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42715. * @returns the updated scene with imported animations
  42716. */
  42717. 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>;
  42718. }
  42719. }
  42720. declare module BABYLON {
  42721. /**
  42722. * Generic Controller
  42723. */
  42724. export class GenericController extends WebVRController {
  42725. /**
  42726. * Base Url for the controller model.
  42727. */
  42728. static readonly MODEL_BASE_URL: string;
  42729. /**
  42730. * File name for the controller model.
  42731. */
  42732. static readonly MODEL_FILENAME: string;
  42733. /**
  42734. * Creates a new GenericController from a gamepad
  42735. * @param vrGamepad the gamepad that the controller should be created from
  42736. */
  42737. constructor(vrGamepad: any);
  42738. /**
  42739. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42740. * @param scene scene in which to add meshes
  42741. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42742. */
  42743. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42744. /**
  42745. * Called once for each button that changed state since the last frame
  42746. * @param buttonIdx Which button index changed
  42747. * @param state New state of the button
  42748. * @param changes Which properties on the state changed since last frame
  42749. */
  42750. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42751. }
  42752. }
  42753. declare module BABYLON {
  42754. /**
  42755. * Defines the WindowsMotionController object that the state of the windows motion controller
  42756. */
  42757. export class WindowsMotionController extends WebVRController {
  42758. /**
  42759. * The base url used to load the left and right controller models
  42760. */
  42761. static MODEL_BASE_URL: string;
  42762. /**
  42763. * The name of the left controller model file
  42764. */
  42765. static MODEL_LEFT_FILENAME: string;
  42766. /**
  42767. * The name of the right controller model file
  42768. */
  42769. static MODEL_RIGHT_FILENAME: string;
  42770. /**
  42771. * The controller name prefix for this controller type
  42772. */
  42773. static readonly GAMEPAD_ID_PREFIX: string;
  42774. /**
  42775. * The controller id pattern for this controller type
  42776. */
  42777. private static readonly GAMEPAD_ID_PATTERN;
  42778. private _loadedMeshInfo;
  42779. protected readonly _mapping: {
  42780. buttons: string[];
  42781. buttonMeshNames: {
  42782. 'trigger': string;
  42783. 'menu': string;
  42784. 'grip': string;
  42785. 'thumbstick': string;
  42786. 'trackpad': string;
  42787. };
  42788. buttonObservableNames: {
  42789. 'trigger': string;
  42790. 'menu': string;
  42791. 'grip': string;
  42792. 'thumbstick': string;
  42793. 'trackpad': string;
  42794. };
  42795. axisMeshNames: string[];
  42796. pointingPoseMeshName: string;
  42797. };
  42798. /**
  42799. * Fired when the trackpad on this controller is clicked
  42800. */
  42801. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42802. /**
  42803. * Fired when the trackpad on this controller is modified
  42804. */
  42805. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42806. /**
  42807. * The current x and y values of this controller's trackpad
  42808. */
  42809. trackpad: StickValues;
  42810. /**
  42811. * Creates a new WindowsMotionController from a gamepad
  42812. * @param vrGamepad the gamepad that the controller should be created from
  42813. */
  42814. constructor(vrGamepad: any);
  42815. /**
  42816. * Fired when the trigger on this controller is modified
  42817. */
  42818. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42819. /**
  42820. * Fired when the menu button on this controller is modified
  42821. */
  42822. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42823. /**
  42824. * Fired when the grip button on this controller is modified
  42825. */
  42826. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42827. /**
  42828. * Fired when the thumbstick button on this controller is modified
  42829. */
  42830. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42831. /**
  42832. * Fired when the touchpad button on this controller is modified
  42833. */
  42834. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42835. /**
  42836. * Fired when the touchpad values on this controller are modified
  42837. */
  42838. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42839. protected _updateTrackpad(): void;
  42840. /**
  42841. * Called once per frame by the engine.
  42842. */
  42843. update(): void;
  42844. /**
  42845. * Called once for each button that changed state since the last frame
  42846. * @param buttonIdx Which button index changed
  42847. * @param state New state of the button
  42848. * @param changes Which properties on the state changed since last frame
  42849. */
  42850. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42851. /**
  42852. * Moves the buttons on the controller mesh based on their current state
  42853. * @param buttonName the name of the button to move
  42854. * @param buttonValue the value of the button which determines the buttons new position
  42855. */
  42856. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42857. /**
  42858. * Moves the axis on the controller mesh based on its current state
  42859. * @param axis the index of the axis
  42860. * @param axisValue the value of the axis which determines the meshes new position
  42861. * @hidden
  42862. */
  42863. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42864. /**
  42865. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42866. * @param scene scene in which to add meshes
  42867. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42868. */
  42869. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42870. /**
  42871. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42872. * can be transformed by button presses and axes values, based on this._mapping.
  42873. *
  42874. * @param scene scene in which the meshes exist
  42875. * @param meshes list of meshes that make up the controller model to process
  42876. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42877. */
  42878. private processModel;
  42879. private createMeshInfo;
  42880. /**
  42881. * Gets the ray of the controller in the direction the controller is pointing
  42882. * @param length the length the resulting ray should be
  42883. * @returns a ray in the direction the controller is pointing
  42884. */
  42885. getForwardRay(length?: number): Ray;
  42886. /**
  42887. * Disposes of the controller
  42888. */
  42889. dispose(): void;
  42890. }
  42891. /**
  42892. * This class represents a new windows motion controller in XR.
  42893. */
  42894. export class XRWindowsMotionController extends WindowsMotionController {
  42895. /**
  42896. * Changing the original WIndowsMotionController mapping to fir the new mapping
  42897. */
  42898. protected readonly _mapping: {
  42899. buttons: string[];
  42900. buttonMeshNames: {
  42901. 'trigger': string;
  42902. 'menu': string;
  42903. 'grip': string;
  42904. 'thumbstick': string;
  42905. 'trackpad': string;
  42906. };
  42907. buttonObservableNames: {
  42908. 'trigger': string;
  42909. 'menu': string;
  42910. 'grip': string;
  42911. 'thumbstick': string;
  42912. 'trackpad': string;
  42913. };
  42914. axisMeshNames: string[];
  42915. pointingPoseMeshName: string;
  42916. };
  42917. /**
  42918. * Construct a new XR-Based windows motion controller
  42919. *
  42920. * @param gamepadInfo the gamepad object from the browser
  42921. */
  42922. constructor(gamepadInfo: any);
  42923. /**
  42924. * holds the thumbstick values (X,Y)
  42925. */
  42926. thumbstickValues: StickValues;
  42927. /**
  42928. * Fired when the thumbstick on this controller is clicked
  42929. */
  42930. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  42931. /**
  42932. * Fired when the thumbstick on this controller is modified
  42933. */
  42934. onThumbstickValuesChangedObservable: Observable<StickValues>;
  42935. /**
  42936. * Fired when the touchpad button on this controller is modified
  42937. */
  42938. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42939. /**
  42940. * Fired when the touchpad values on this controller are modified
  42941. */
  42942. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42943. /**
  42944. * Fired when the thumbstick button on this controller is modified
  42945. * here to prevent breaking changes
  42946. */
  42947. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42948. /**
  42949. * updating the thumbstick(!) and not the trackpad.
  42950. * This is named this way due to the difference between WebVR and XR and to avoid
  42951. * changing the parent class.
  42952. */
  42953. protected _updateTrackpad(): void;
  42954. /**
  42955. * Disposes the class with joy
  42956. */
  42957. dispose(): void;
  42958. }
  42959. }
  42960. declare module BABYLON {
  42961. /**
  42962. * Oculus Touch Controller
  42963. */
  42964. export class OculusTouchController extends WebVRController {
  42965. /**
  42966. * Base Url for the controller model.
  42967. */
  42968. static MODEL_BASE_URL: string;
  42969. /**
  42970. * File name for the left controller model.
  42971. */
  42972. static MODEL_LEFT_FILENAME: string;
  42973. /**
  42974. * File name for the right controller model.
  42975. */
  42976. static MODEL_RIGHT_FILENAME: string;
  42977. /**
  42978. * Base Url for the Quest controller model.
  42979. */
  42980. static QUEST_MODEL_BASE_URL: string;
  42981. /**
  42982. * @hidden
  42983. * If the controllers are running on a device that needs the updated Quest controller models
  42984. */
  42985. static _IsQuest: boolean;
  42986. /**
  42987. * Fired when the secondary trigger on this controller is modified
  42988. */
  42989. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42990. /**
  42991. * Fired when the thumb rest on this controller is modified
  42992. */
  42993. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42994. /**
  42995. * Creates a new OculusTouchController from a gamepad
  42996. * @param vrGamepad the gamepad that the controller should be created from
  42997. */
  42998. constructor(vrGamepad: any);
  42999. /**
  43000. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43001. * @param scene scene in which to add meshes
  43002. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43003. */
  43004. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43005. /**
  43006. * Fired when the A button on this controller is modified
  43007. */
  43008. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43009. /**
  43010. * Fired when the B button on this controller is modified
  43011. */
  43012. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43013. /**
  43014. * Fired when the X button on this controller is modified
  43015. */
  43016. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43017. /**
  43018. * Fired when the Y button on this controller is modified
  43019. */
  43020. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43021. /**
  43022. * Called once for each button that changed state since the last frame
  43023. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43024. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43025. * 2) secondary trigger (same)
  43026. * 3) A (right) X (left), touch, pressed = value
  43027. * 4) B / Y
  43028. * 5) thumb rest
  43029. * @param buttonIdx Which button index changed
  43030. * @param state New state of the button
  43031. * @param changes Which properties on the state changed since last frame
  43032. */
  43033. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43034. }
  43035. }
  43036. declare module BABYLON {
  43037. /**
  43038. * Vive Controller
  43039. */
  43040. export class ViveController extends WebVRController {
  43041. /**
  43042. * Base Url for the controller model.
  43043. */
  43044. static MODEL_BASE_URL: string;
  43045. /**
  43046. * File name for the controller model.
  43047. */
  43048. static MODEL_FILENAME: string;
  43049. /**
  43050. * Creates a new ViveController from a gamepad
  43051. * @param vrGamepad the gamepad that the controller should be created from
  43052. */
  43053. constructor(vrGamepad: any);
  43054. /**
  43055. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43056. * @param scene scene in which to add meshes
  43057. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43058. */
  43059. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43060. /**
  43061. * Fired when the left button on this controller is modified
  43062. */
  43063. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43064. /**
  43065. * Fired when the right button on this controller is modified
  43066. */
  43067. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43068. /**
  43069. * Fired when the menu button on this controller is modified
  43070. */
  43071. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43072. /**
  43073. * Called once for each button that changed state since the last frame
  43074. * Vive mapping:
  43075. * 0: touchpad
  43076. * 1: trigger
  43077. * 2: left AND right buttons
  43078. * 3: menu button
  43079. * @param buttonIdx Which button index changed
  43080. * @param state New state of the button
  43081. * @param changes Which properties on the state changed since last frame
  43082. */
  43083. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43084. }
  43085. }
  43086. declare module BABYLON {
  43087. /**
  43088. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43089. */
  43090. export class WebXRControllerModelLoader {
  43091. /**
  43092. * an observable that triggers when a new model (the mesh itself) was initialized.
  43093. * To know when the mesh was loaded use the controller's own modelLoaded() method
  43094. */
  43095. onControllerModelLoaded: Observable<WebXRController>;
  43096. /**
  43097. * Creates the WebXRControllerModelLoader
  43098. * @param input xr input that creates the controllers
  43099. */
  43100. constructor(input: WebXRInput);
  43101. }
  43102. }
  43103. declare module BABYLON {
  43104. /**
  43105. * Handles pointer input automatically for the pointer of XR controllers
  43106. */
  43107. export class WebXRControllerPointerSelection {
  43108. private static _idCounter;
  43109. private _tmpRay;
  43110. /**
  43111. * Creates a WebXRControllerPointerSelection
  43112. * @param input input manager to setup pointer selection
  43113. */
  43114. constructor(input: WebXRInput);
  43115. private _convertNormalToDirectionOfRay;
  43116. private _updatePointerDistance;
  43117. }
  43118. }
  43119. declare module BABYLON {
  43120. /**
  43121. * Enables teleportation
  43122. */
  43123. export class WebXRControllerTeleportation {
  43124. private _teleportationFillColor;
  43125. private _teleportationBorderColor;
  43126. private _tmpRay;
  43127. private _tmpVector;
  43128. /**
  43129. * when set to true (default) teleportation will wait for thumbstick changes.
  43130. * When set to false teleportation will be disabled.
  43131. *
  43132. * If set to false while teleporting results can be unexpected.
  43133. */
  43134. enabled: boolean;
  43135. /**
  43136. * Creates a WebXRControllerTeleportation
  43137. * @param input input manager to add teleportation to
  43138. * @param floorMeshes floormeshes which can be teleported to
  43139. */
  43140. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43141. }
  43142. }
  43143. declare module BABYLON {
  43144. /**
  43145. * Button which can be used to enter a different mode of XR
  43146. */
  43147. export class WebXREnterExitUIButton {
  43148. /** button element */
  43149. element: HTMLElement;
  43150. /** XR initialization options for the button */
  43151. sessionMode: XRSessionMode;
  43152. /** Reference space type */
  43153. referenceSpaceType: XRReferenceSpaceType;
  43154. /**
  43155. * Creates a WebXREnterExitUIButton
  43156. * @param element button element
  43157. * @param sessionMode XR initialization session mode
  43158. * @param referenceSpaceType the type of reference space to be used
  43159. */
  43160. constructor(
  43161. /** button element */
  43162. element: HTMLElement,
  43163. /** XR initialization options for the button */
  43164. sessionMode: XRSessionMode,
  43165. /** Reference space type */
  43166. referenceSpaceType: XRReferenceSpaceType);
  43167. /**
  43168. * Overwritable function which can be used to update the button's visuals when the state changes
  43169. * @param activeButton the current active button in the UI
  43170. */
  43171. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43172. }
  43173. /**
  43174. * Options to create the webXR UI
  43175. */
  43176. export class WebXREnterExitUIOptions {
  43177. /**
  43178. * Context to enter xr with
  43179. */
  43180. renderTarget?: Nullable<WebXRRenderTarget>;
  43181. /**
  43182. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43183. */
  43184. customButtons?: Array<WebXREnterExitUIButton>;
  43185. /**
  43186. * A session mode to use when creating the default button.
  43187. * Default is immersive-vr
  43188. */
  43189. sessionMode?: XRSessionMode;
  43190. /**
  43191. * A reference space type to use when creating the default button.
  43192. * Default is local-floor
  43193. */
  43194. referenceSpaceType?: XRReferenceSpaceType;
  43195. }
  43196. /**
  43197. * UI to allow the user to enter/exit XR mode
  43198. */
  43199. export class WebXREnterExitUI implements IDisposable {
  43200. private scene;
  43201. /** version of the options passed to this UI */
  43202. options: WebXREnterExitUIOptions;
  43203. private _overlay;
  43204. private _buttons;
  43205. private _activeButton;
  43206. /**
  43207. * Fired every time the active button is changed.
  43208. *
  43209. * When xr is entered via a button that launches xr that button will be the callback parameter
  43210. *
  43211. * When exiting xr the callback parameter will be null)
  43212. */
  43213. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43214. /**
  43215. * Creates UI to allow the user to enter/exit XR mode
  43216. * @param scene the scene to add the ui to
  43217. * @param helper the xr experience helper to enter/exit xr with
  43218. * @param options options to configure the UI
  43219. * @returns the created ui
  43220. */
  43221. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43222. /**
  43223. *
  43224. * @param scene babylon scene object to use
  43225. * @param options (read-only) version of the options passed to this UI
  43226. */
  43227. private constructor();
  43228. private _updateButtons;
  43229. /**
  43230. * Disposes of the object
  43231. */
  43232. dispose(): void;
  43233. }
  43234. }
  43235. declare module BABYLON {
  43236. /**
  43237. * Options for the default xr helper
  43238. */
  43239. export class WebXRDefaultExperienceOptions {
  43240. /**
  43241. * Floor meshes that should be used for teleporting
  43242. */
  43243. floorMeshes: Array<AbstractMesh>;
  43244. /**
  43245. * Enable or disable default UI to enter XR
  43246. */
  43247. disableDefaultUI?: boolean;
  43248. /**
  43249. * optional configuration for the output canvas
  43250. */
  43251. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43252. /**
  43253. * optional UI options. This can be used among other to change session mode and reference space type
  43254. */
  43255. uiOptions?: WebXREnterExitUIOptions;
  43256. }
  43257. /**
  43258. * Default experience which provides a similar setup to the previous webVRExperience
  43259. */
  43260. export class WebXRDefaultExperience {
  43261. /**
  43262. * Base experience
  43263. */
  43264. baseExperience: WebXRExperienceHelper;
  43265. /**
  43266. * Input experience extension
  43267. */
  43268. input: WebXRInput;
  43269. /**
  43270. * Loads the controller models
  43271. */
  43272. controllerModelLoader: WebXRControllerModelLoader;
  43273. /**
  43274. * Enables laser pointer and selection
  43275. */
  43276. pointerSelection: WebXRControllerPointerSelection;
  43277. /**
  43278. * Enables teleportation
  43279. */
  43280. teleportation: WebXRControllerTeleportation;
  43281. /**
  43282. * Enables ui for entering/exiting xr
  43283. */
  43284. enterExitUI: WebXREnterExitUI;
  43285. /**
  43286. * Default target xr should render to
  43287. */
  43288. renderTarget: WebXRRenderTarget;
  43289. /**
  43290. * Creates the default xr experience
  43291. * @param scene scene
  43292. * @param options options for basic configuration
  43293. * @returns resulting WebXRDefaultExperience
  43294. */
  43295. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43296. private constructor();
  43297. /**
  43298. * DIsposes of the experience helper
  43299. */
  43300. dispose(): void;
  43301. }
  43302. }
  43303. declare module BABYLON {
  43304. /**
  43305. * Options to modify the vr teleportation behavior.
  43306. */
  43307. export interface VRTeleportationOptions {
  43308. /**
  43309. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43310. */
  43311. floorMeshName?: string;
  43312. /**
  43313. * A list of meshes to be used as the teleportation floor. (default: empty)
  43314. */
  43315. floorMeshes?: Mesh[];
  43316. /**
  43317. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43318. */
  43319. teleportationMode?: number;
  43320. /**
  43321. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43322. */
  43323. teleportationTime?: number;
  43324. /**
  43325. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43326. */
  43327. teleportationSpeed?: number;
  43328. /**
  43329. * The easing function used in the animation or null for Linear. (default CircleEase)
  43330. */
  43331. easingFunction?: EasingFunction;
  43332. }
  43333. /**
  43334. * Options to modify the vr experience helper's behavior.
  43335. */
  43336. export interface VRExperienceHelperOptions extends WebVROptions {
  43337. /**
  43338. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43339. */
  43340. createDeviceOrientationCamera?: boolean;
  43341. /**
  43342. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43343. */
  43344. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43345. /**
  43346. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43347. */
  43348. laserToggle?: boolean;
  43349. /**
  43350. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43351. */
  43352. floorMeshes?: Mesh[];
  43353. /**
  43354. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43355. */
  43356. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43357. /**
  43358. * Defines if WebXR should be used instead of WebVR (if available)
  43359. */
  43360. useXR?: boolean;
  43361. }
  43362. /**
  43363. * Event containing information after VR has been entered
  43364. */
  43365. export class OnAfterEnteringVRObservableEvent {
  43366. /**
  43367. * If entering vr was successful
  43368. */
  43369. success: boolean;
  43370. }
  43371. /**
  43372. * Helps to quickly add VR support to an existing scene.
  43373. * See http://doc.babylonjs.com/how_to/webvr_helper
  43374. */
  43375. export class VRExperienceHelper {
  43376. /** Options to modify the vr experience helper's behavior. */
  43377. webVROptions: VRExperienceHelperOptions;
  43378. private _scene;
  43379. private _position;
  43380. private _btnVR;
  43381. private _btnVRDisplayed;
  43382. private _webVRsupported;
  43383. private _webVRready;
  43384. private _webVRrequesting;
  43385. private _webVRpresenting;
  43386. private _hasEnteredVR;
  43387. private _fullscreenVRpresenting;
  43388. private _inputElement;
  43389. private _webVRCamera;
  43390. private _vrDeviceOrientationCamera;
  43391. private _deviceOrientationCamera;
  43392. private _existingCamera;
  43393. private _onKeyDown;
  43394. private _onVrDisplayPresentChange;
  43395. private _onVRDisplayChanged;
  43396. private _onVRRequestPresentStart;
  43397. private _onVRRequestPresentComplete;
  43398. /**
  43399. * 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)
  43400. */
  43401. enableGazeEvenWhenNoPointerLock: boolean;
  43402. /**
  43403. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43404. */
  43405. exitVROnDoubleTap: boolean;
  43406. /**
  43407. * Observable raised right before entering VR.
  43408. */
  43409. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43410. /**
  43411. * Observable raised when entering VR has completed.
  43412. */
  43413. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43414. /**
  43415. * Observable raised when exiting VR.
  43416. */
  43417. onExitingVRObservable: Observable<VRExperienceHelper>;
  43418. /**
  43419. * Observable raised when controller mesh is loaded.
  43420. */
  43421. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43422. /** Return this.onEnteringVRObservable
  43423. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43424. */
  43425. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43426. /** Return this.onExitingVRObservable
  43427. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43428. */
  43429. readonly onExitingVR: Observable<VRExperienceHelper>;
  43430. /** Return this.onControllerMeshLoadedObservable
  43431. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43432. */
  43433. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43434. private _rayLength;
  43435. private _useCustomVRButton;
  43436. private _teleportationRequested;
  43437. private _teleportActive;
  43438. private _floorMeshName;
  43439. private _floorMeshesCollection;
  43440. private _teleportationMode;
  43441. private _teleportationTime;
  43442. private _teleportationSpeed;
  43443. private _teleportationEasing;
  43444. private _rotationAllowed;
  43445. private _teleportBackwardsVector;
  43446. private _teleportationTarget;
  43447. private _isDefaultTeleportationTarget;
  43448. private _postProcessMove;
  43449. private _teleportationFillColor;
  43450. private _teleportationBorderColor;
  43451. private _rotationAngle;
  43452. private _haloCenter;
  43453. private _cameraGazer;
  43454. private _padSensibilityUp;
  43455. private _padSensibilityDown;
  43456. private _leftController;
  43457. private _rightController;
  43458. /**
  43459. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43460. */
  43461. onNewMeshSelected: Observable<AbstractMesh>;
  43462. /**
  43463. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43464. * This observable will provide the mesh and the controller used to select the mesh
  43465. */
  43466. onMeshSelectedWithController: Observable<{
  43467. mesh: AbstractMesh;
  43468. controller: WebVRController;
  43469. }>;
  43470. /**
  43471. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43472. */
  43473. onNewMeshPicked: Observable<PickingInfo>;
  43474. private _circleEase;
  43475. /**
  43476. * Observable raised before camera teleportation
  43477. */
  43478. onBeforeCameraTeleport: Observable<Vector3>;
  43479. /**
  43480. * Observable raised after camera teleportation
  43481. */
  43482. onAfterCameraTeleport: Observable<Vector3>;
  43483. /**
  43484. * Observable raised when current selected mesh gets unselected
  43485. */
  43486. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43487. private _raySelectionPredicate;
  43488. /**
  43489. * To be optionaly changed by user to define custom ray selection
  43490. */
  43491. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43492. /**
  43493. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43494. */
  43495. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43496. /**
  43497. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43498. */
  43499. teleportationEnabled: boolean;
  43500. private _defaultHeight;
  43501. private _teleportationInitialized;
  43502. private _interactionsEnabled;
  43503. private _interactionsRequested;
  43504. private _displayGaze;
  43505. private _displayLaserPointer;
  43506. /**
  43507. * The mesh used to display where the user is going to teleport.
  43508. */
  43509. /**
  43510. * Sets the mesh to be used to display where the user is going to teleport.
  43511. */
  43512. teleportationTarget: Mesh;
  43513. /**
  43514. * 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
  43515. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43516. * See http://doc.babylonjs.com/resources/baking_transformations
  43517. */
  43518. gazeTrackerMesh: Mesh;
  43519. /**
  43520. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43521. */
  43522. updateGazeTrackerScale: boolean;
  43523. /**
  43524. * If the gaze trackers color should be updated when selecting meshes
  43525. */
  43526. updateGazeTrackerColor: boolean;
  43527. /**
  43528. * If the controller laser color should be updated when selecting meshes
  43529. */
  43530. updateControllerLaserColor: boolean;
  43531. /**
  43532. * The gaze tracking mesh corresponding to the left controller
  43533. */
  43534. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43535. /**
  43536. * The gaze tracking mesh corresponding to the right controller
  43537. */
  43538. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43539. /**
  43540. * If the ray of the gaze should be displayed.
  43541. */
  43542. /**
  43543. * Sets if the ray of the gaze should be displayed.
  43544. */
  43545. displayGaze: boolean;
  43546. /**
  43547. * If the ray of the LaserPointer should be displayed.
  43548. */
  43549. /**
  43550. * Sets if the ray of the LaserPointer should be displayed.
  43551. */
  43552. displayLaserPointer: boolean;
  43553. /**
  43554. * The deviceOrientationCamera used as the camera when not in VR.
  43555. */
  43556. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43557. /**
  43558. * Based on the current WebVR support, returns the current VR camera used.
  43559. */
  43560. readonly currentVRCamera: Nullable<Camera>;
  43561. /**
  43562. * The webVRCamera which is used when in VR.
  43563. */
  43564. readonly webVRCamera: WebVRFreeCamera;
  43565. /**
  43566. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43567. */
  43568. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43569. /**
  43570. * The html button that is used to trigger entering into VR.
  43571. */
  43572. readonly vrButton: Nullable<HTMLButtonElement>;
  43573. private readonly _teleportationRequestInitiated;
  43574. /**
  43575. * Defines wether or not Pointer lock should be requested when switching to
  43576. * full screen.
  43577. */
  43578. requestPointerLockOnFullScreen: boolean;
  43579. /**
  43580. * If asking to force XR, this will be populated with the default xr experience
  43581. */
  43582. xr: WebXRDefaultExperience;
  43583. /**
  43584. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  43585. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  43586. */
  43587. xrTestDone: boolean;
  43588. /**
  43589. * Instantiates a VRExperienceHelper.
  43590. * Helps to quickly add VR support to an existing scene.
  43591. * @param scene The scene the VRExperienceHelper belongs to.
  43592. * @param webVROptions Options to modify the vr experience helper's behavior.
  43593. */
  43594. constructor(scene: Scene,
  43595. /** Options to modify the vr experience helper's behavior. */
  43596. webVROptions?: VRExperienceHelperOptions);
  43597. private completeVRInit;
  43598. private _onDefaultMeshLoaded;
  43599. private _onResize;
  43600. private _onFullscreenChange;
  43601. /**
  43602. * Gets a value indicating if we are currently in VR mode.
  43603. */
  43604. readonly isInVRMode: boolean;
  43605. private onVrDisplayPresentChange;
  43606. private onVRDisplayChanged;
  43607. private moveButtonToBottomRight;
  43608. private displayVRButton;
  43609. private updateButtonVisibility;
  43610. private _cachedAngularSensibility;
  43611. /**
  43612. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43613. * Otherwise, will use the fullscreen API.
  43614. */
  43615. enterVR(): void;
  43616. /**
  43617. * Attempt to exit VR, or fullscreen.
  43618. */
  43619. exitVR(): void;
  43620. /**
  43621. * The position of the vr experience helper.
  43622. */
  43623. /**
  43624. * Sets the position of the vr experience helper.
  43625. */
  43626. position: Vector3;
  43627. /**
  43628. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43629. */
  43630. enableInteractions(): void;
  43631. private readonly _noControllerIsActive;
  43632. private beforeRender;
  43633. private _isTeleportationFloor;
  43634. /**
  43635. * Adds a floor mesh to be used for teleportation.
  43636. * @param floorMesh the mesh to be used for teleportation.
  43637. */
  43638. addFloorMesh(floorMesh: Mesh): void;
  43639. /**
  43640. * Removes a floor mesh from being used for teleportation.
  43641. * @param floorMesh the mesh to be removed.
  43642. */
  43643. removeFloorMesh(floorMesh: Mesh): void;
  43644. /**
  43645. * Enables interactions and teleportation using the VR controllers and gaze.
  43646. * @param vrTeleportationOptions options to modify teleportation behavior.
  43647. */
  43648. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43649. private _onNewGamepadConnected;
  43650. private _tryEnableInteractionOnController;
  43651. private _onNewGamepadDisconnected;
  43652. private _enableInteractionOnController;
  43653. private _checkTeleportWithRay;
  43654. private _checkRotate;
  43655. private _checkTeleportBackwards;
  43656. private _enableTeleportationOnController;
  43657. private _createTeleportationCircles;
  43658. private _displayTeleportationTarget;
  43659. private _hideTeleportationTarget;
  43660. private _rotateCamera;
  43661. private _moveTeleportationSelectorTo;
  43662. private _workingVector;
  43663. private _workingQuaternion;
  43664. private _workingMatrix;
  43665. /**
  43666. * Time Constant Teleportation Mode
  43667. */
  43668. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  43669. /**
  43670. * Speed Constant Teleportation Mode
  43671. */
  43672. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  43673. /**
  43674. * Teleports the users feet to the desired location
  43675. * @param location The location where the user's feet should be placed
  43676. */
  43677. teleportCamera(location: Vector3): void;
  43678. private _convertNormalToDirectionOfRay;
  43679. private _castRayAndSelectObject;
  43680. private _notifySelectedMeshUnselected;
  43681. /**
  43682. * Sets the color of the laser ray from the vr controllers.
  43683. * @param color new color for the ray.
  43684. */
  43685. changeLaserColor(color: Color3): void;
  43686. /**
  43687. * Sets the color of the ray from the vr headsets gaze.
  43688. * @param color new color for the ray.
  43689. */
  43690. changeGazeColor(color: Color3): void;
  43691. /**
  43692. * Exits VR and disposes of the vr experience helper
  43693. */
  43694. dispose(): void;
  43695. /**
  43696. * Gets the name of the VRExperienceHelper class
  43697. * @returns "VRExperienceHelper"
  43698. */
  43699. getClassName(): string;
  43700. }
  43701. }
  43702. declare module BABYLON {
  43703. /**
  43704. * Options used for hit testing
  43705. */
  43706. export interface IWebXRHitTestOptions {
  43707. /**
  43708. * Only test when user interacted with the scene. Default - hit test every frame
  43709. */
  43710. testOnPointerDownOnly?: boolean;
  43711. /**
  43712. * The node to use to transform the local results to world coordinates
  43713. */
  43714. worldParentNode?: TransformNode;
  43715. }
  43716. /**
  43717. * Interface defining the babylon result of raycasting/hit-test
  43718. */
  43719. export interface IWebXRHitResult {
  43720. /**
  43721. * The native hit test result
  43722. */
  43723. xrHitResult: XRHitResult;
  43724. /**
  43725. * Transformation matrix that can be applied to a node that will put it in the hit point location
  43726. */
  43727. transformationMatrix: Matrix;
  43728. }
  43729. /**
  43730. * The currently-working hit-test module.
  43731. * Hit test (or raycasting) is used to interact with the real world.
  43732. * For further information read here - https://github.com/immersive-web/hit-test
  43733. */
  43734. export class WebXRHitTestLegacy implements IWebXRFeature {
  43735. private _xrSessionManager;
  43736. /**
  43737. * options to use when constructing this feature
  43738. */
  43739. readonly options: IWebXRHitTestOptions;
  43740. /**
  43741. * The module's name
  43742. */
  43743. static readonly Name: string;
  43744. /**
  43745. * The (Babylon) version of this module.
  43746. * This is an integer representing the implementation version.
  43747. * This number does not correspond to the webxr specs version
  43748. */
  43749. static readonly Version: number;
  43750. /**
  43751. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  43752. * @param event the (select) event to use to select with
  43753. * @param referenceSpace the reference space to use for this hit test
  43754. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  43755. */
  43756. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  43757. /**
  43758. * execute a hit test with an XR Ray
  43759. *
  43760. * @param xrSession a native xrSession that will execute this hit test
  43761. * @param xrRay the ray (position and direction) to use for raycasting
  43762. * @param referenceSpace native XR reference space to use for the hit-test
  43763. * @param filter filter function that will filter the results
  43764. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  43765. */
  43766. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  43767. /**
  43768. * Triggered when new babylon (transformed) hit test results are available
  43769. */
  43770. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  43771. /**
  43772. * Creates a new instance of the (legacy version) hit test feature
  43773. * @param _xrSessionManager an instance of WebXRSessionManager
  43774. * @param options options to use when constructing this feature
  43775. */
  43776. constructor(_xrSessionManager: WebXRSessionManager,
  43777. /**
  43778. * options to use when constructing this feature
  43779. */
  43780. options?: IWebXRHitTestOptions);
  43781. private _onSelectEnabled;
  43782. private _xrFrameObserver;
  43783. private _attached;
  43784. /**
  43785. * Populated with the last native XR Hit Results
  43786. */
  43787. lastNativeXRHitResults: XRHitResult[];
  43788. /**
  43789. * attach this feature
  43790. * Will usually be called by the features manager
  43791. *
  43792. * @returns true if successful.
  43793. */
  43794. attach(): boolean;
  43795. /**
  43796. * detach this feature.
  43797. * Will usually be called by the features manager
  43798. *
  43799. * @returns true if successful.
  43800. */
  43801. detach(): boolean;
  43802. private _onHitTestResults;
  43803. private _onSelect;
  43804. /**
  43805. * Dispose this feature and all of the resources attached
  43806. */
  43807. dispose(): void;
  43808. }
  43809. }
  43810. declare module BABYLON {
  43811. /**
  43812. * Options used in the plane detector module
  43813. */
  43814. export interface IWebXRPlaneDetectorOptions {
  43815. /**
  43816. * The node to use to transform the local results to world coordinates
  43817. */
  43818. worldParentNode?: TransformNode;
  43819. }
  43820. /**
  43821. * A babylon interface for a webxr plane.
  43822. * A Plane is actually a polygon, built from N points in space
  43823. */
  43824. export interface IWebXRPlane {
  43825. /**
  43826. * a babylon-assigned ID for this polygon
  43827. */
  43828. id: number;
  43829. /**
  43830. * the native xr-plane object
  43831. */
  43832. xrPlane: XRPlane;
  43833. /**
  43834. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  43835. */
  43836. polygonDefinition: Array<Vector3>;
  43837. /**
  43838. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  43839. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  43840. */
  43841. transformationMatrix: Matrix;
  43842. }
  43843. /**
  43844. * The plane detector is used to detect planes in the real world when in AR
  43845. * For more information see https://github.com/immersive-web/real-world-geometry/
  43846. */
  43847. export class WebXRPlaneDetector implements IWebXRFeature {
  43848. private _xrSessionManager;
  43849. private _options;
  43850. /**
  43851. * The module's name
  43852. */
  43853. static readonly Name: string;
  43854. /**
  43855. * The (Babylon) version of this module.
  43856. * This is an integer representing the implementation version.
  43857. * This number does not correspond to the webxr specs version
  43858. */
  43859. static readonly Version: number;
  43860. /**
  43861. * Observers registered here will be executed when a new plane was added to the session
  43862. */
  43863. onPlaneAddedObservable: Observable<IWebXRPlane>;
  43864. /**
  43865. * Observers registered here will be executed when a plane is no longer detected in the session
  43866. */
  43867. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  43868. /**
  43869. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  43870. * This can execute N times every frame
  43871. */
  43872. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  43873. private _enabled;
  43874. private _attached;
  43875. private _detectedPlanes;
  43876. private _lastFrameDetected;
  43877. private _observerTracked;
  43878. /**
  43879. * construct a new Plane Detector
  43880. * @param _xrSessionManager an instance of xr Session manager
  43881. * @param _options configuration to use when constructing this feature
  43882. */
  43883. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  43884. /**
  43885. * attach this feature
  43886. * Will usually be called by the features manager
  43887. *
  43888. * @returns true if successful.
  43889. */
  43890. attach(): boolean;
  43891. /**
  43892. * detach this feature.
  43893. * Will usually be called by the features manager
  43894. *
  43895. * @returns true if successful.
  43896. */
  43897. detach(): boolean;
  43898. /**
  43899. * Dispose this feature and all of the resources attached
  43900. */
  43901. dispose(): void;
  43902. private _updatePlaneWithXRPlane;
  43903. /**
  43904. * avoiding using Array.find for global support.
  43905. * @param xrPlane the plane to find in the array
  43906. */
  43907. private findIndexInPlaneArray;
  43908. }
  43909. }
  43910. declare module BABYLON {
  43911. /**
  43912. * Configuration options of the anchor system
  43913. */
  43914. export interface IWebXRAnchorSystemOptions {
  43915. /**
  43916. * a node that will be used to convert local to world coordinates
  43917. */
  43918. worldParentNode?: TransformNode;
  43919. /**
  43920. * should the anchor system use plane detection.
  43921. * If set to true, the plane-detection feature should be set using setPlaneDetector
  43922. */
  43923. usePlaneDetection?: boolean;
  43924. /**
  43925. * Should a new anchor be added every time a select event is triggered
  43926. */
  43927. addAnchorOnSelect?: boolean;
  43928. }
  43929. /**
  43930. * A babylon container for an XR Anchor
  43931. */
  43932. export interface IWebXRAnchor {
  43933. /**
  43934. * A babylon-assigned ID for this anchor
  43935. */
  43936. id: number;
  43937. /**
  43938. * The native anchor object
  43939. */
  43940. xrAnchor: XRAnchor;
  43941. /**
  43942. * Transformation matrix to apply to an object attached to this anchor
  43943. */
  43944. transformationMatrix: Matrix;
  43945. }
  43946. /**
  43947. * An implementation of the anchor system of WebXR.
  43948. * Note that the current documented implementation is not available in any browser. Future implementations
  43949. * will use the frame to create an anchor and not the session or a detected plane
  43950. * For further information see https://github.com/immersive-web/anchors/
  43951. */
  43952. export class WebXRAnchorSystem implements IWebXRFeature {
  43953. private _xrSessionManager;
  43954. private _options;
  43955. /**
  43956. * The module's name
  43957. */
  43958. static readonly Name: string;
  43959. /**
  43960. * The (Babylon) version of this module.
  43961. * This is an integer representing the implementation version.
  43962. * This number does not correspond to the webxr specs version
  43963. */
  43964. static readonly Version: number;
  43965. /**
  43966. * Observers registered here will be executed when a new anchor was added to the session
  43967. */
  43968. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  43969. /**
  43970. * Observers registered here will be executed when an existing anchor updates
  43971. * This can execute N times every frame
  43972. */
  43973. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  43974. /**
  43975. * Observers registered here will be executed when an anchor was removed from the session
  43976. */
  43977. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  43978. private _planeDetector;
  43979. private _hitTestModule;
  43980. private _enabled;
  43981. private _attached;
  43982. private _trackedAnchors;
  43983. private _lastFrameDetected;
  43984. private _observerTracked;
  43985. /**
  43986. * constructs a new anchor system
  43987. * @param _xrSessionManager an instance of WebXRSessionManager
  43988. * @param _options configuration object for this feature
  43989. */
  43990. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  43991. /**
  43992. * set the plane detector to use in order to create anchors from frames
  43993. * @param planeDetector the plane-detector module to use
  43994. * @param enable enable plane-anchors. default is true
  43995. */
  43996. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  43997. /**
  43998. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  43999. * @param hitTestModule the hit-test module to use.
  44000. */
  44001. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  44002. /**
  44003. * attach this feature
  44004. * Will usually be called by the features manager
  44005. *
  44006. * @returns true if successful.
  44007. */
  44008. attach(): boolean;
  44009. /**
  44010. * detach this feature.
  44011. * Will usually be called by the features manager
  44012. *
  44013. * @returns true if successful.
  44014. */
  44015. detach(): boolean;
  44016. /**
  44017. * Dispose this feature and all of the resources attached
  44018. */
  44019. dispose(): void;
  44020. private _onSelect;
  44021. /**
  44022. * Add anchor at a specific XR point.
  44023. *
  44024. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  44025. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  44026. * @returns a promise the fulfills when the anchor was created
  44027. */
  44028. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  44029. private _updateAnchorWithXRFrame;
  44030. /**
  44031. * avoiding using Array.find for global support.
  44032. * @param xrAnchor the plane to find in the array
  44033. */
  44034. private _findIndexInAnchorArray;
  44035. }
  44036. }
  44037. declare module BABYLON {
  44038. /**
  44039. * Options interface for the background remover plugin
  44040. */
  44041. export interface IWebXRBackgroundRemoverOptions {
  44042. /**
  44043. * don't disable the environment helper
  44044. */
  44045. ignoreEnvironmentHelper?: boolean;
  44046. /**
  44047. * flags to configure the removal of the environment helper.
  44048. * If not set, the entire background will be removed. If set, flags should be set as well.
  44049. */
  44050. environmentHelperRemovalFlags?: {
  44051. /**
  44052. * Should the skybox be removed (default false)
  44053. */
  44054. skyBox?: boolean;
  44055. /**
  44056. * Should the ground be removed (default false)
  44057. */
  44058. ground?: boolean;
  44059. };
  44060. /**
  44061. * Further background meshes to disable when entering AR
  44062. */
  44063. backgroundMeshes?: AbstractMesh[];
  44064. }
  44065. /**
  44066. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  44067. */
  44068. export class WebXRBackgroundRemover implements IWebXRFeature {
  44069. private _xrSessionManager;
  44070. /**
  44071. * read-only options to be used in this module
  44072. */
  44073. readonly options: IWebXRBackgroundRemoverOptions;
  44074. /**
  44075. * The module's name
  44076. */
  44077. static readonly Name: string;
  44078. /**
  44079. * The (Babylon) version of this module.
  44080. * This is an integer representing the implementation version.
  44081. * This number does not correspond to the webxr specs version
  44082. */
  44083. static readonly Version: number;
  44084. /**
  44085. * registered observers will be triggered when the background state changes
  44086. */
  44087. onBackgroundStateChangedObservable: Observable<boolean>;
  44088. /**
  44089. * constructs a new background remover module
  44090. * @param _xrSessionManager the session manager for this module
  44091. * @param options read-only options to be used in this module
  44092. */
  44093. constructor(_xrSessionManager: WebXRSessionManager,
  44094. /**
  44095. * read-only options to be used in this module
  44096. */
  44097. options?: IWebXRBackgroundRemoverOptions);
  44098. /**
  44099. * attach this feature
  44100. * Will usually be called by the features manager
  44101. *
  44102. * @returns true if successful.
  44103. */
  44104. attach(): boolean;
  44105. /**
  44106. * detach this feature.
  44107. * Will usually be called by the features manager
  44108. *
  44109. * @returns true if successful.
  44110. */
  44111. detach(): boolean;
  44112. private _setBackgroundState;
  44113. /**
  44114. * Dispose this feature and all of the resources attached
  44115. */
  44116. dispose(): void;
  44117. }
  44118. }
  44119. declare module BABYLON {
  44120. /**
  44121. * Contains an array of blocks representing the octree
  44122. */
  44123. export interface IOctreeContainer<T> {
  44124. /**
  44125. * Blocks within the octree
  44126. */
  44127. blocks: Array<OctreeBlock<T>>;
  44128. }
  44129. /**
  44130. * Class used to store a cell in an octree
  44131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44132. */
  44133. export class OctreeBlock<T> {
  44134. /**
  44135. * Gets the content of the current block
  44136. */
  44137. entries: T[];
  44138. /**
  44139. * Gets the list of block children
  44140. */
  44141. blocks: Array<OctreeBlock<T>>;
  44142. private _depth;
  44143. private _maxDepth;
  44144. private _capacity;
  44145. private _minPoint;
  44146. private _maxPoint;
  44147. private _boundingVectors;
  44148. private _creationFunc;
  44149. /**
  44150. * Creates a new block
  44151. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44152. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44153. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44154. * @param depth defines the current depth of this block in the octree
  44155. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44156. * @param creationFunc defines a callback to call when an element is added to the block
  44157. */
  44158. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44159. /**
  44160. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44161. */
  44162. readonly capacity: number;
  44163. /**
  44164. * Gets the minimum vector (in world space) of the block's bounding box
  44165. */
  44166. readonly minPoint: Vector3;
  44167. /**
  44168. * Gets the maximum vector (in world space) of the block's bounding box
  44169. */
  44170. readonly maxPoint: Vector3;
  44171. /**
  44172. * Add a new element to this block
  44173. * @param entry defines the element to add
  44174. */
  44175. addEntry(entry: T): void;
  44176. /**
  44177. * Remove an element from this block
  44178. * @param entry defines the element to remove
  44179. */
  44180. removeEntry(entry: T): void;
  44181. /**
  44182. * Add an array of elements to this block
  44183. * @param entries defines the array of elements to add
  44184. */
  44185. addEntries(entries: T[]): void;
  44186. /**
  44187. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44188. * @param frustumPlanes defines the frustum planes to test
  44189. * @param selection defines the array to store current content if selection is positive
  44190. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44191. */
  44192. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44193. /**
  44194. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44195. * @param sphereCenter defines the bounding sphere center
  44196. * @param sphereRadius defines the bounding sphere radius
  44197. * @param selection defines the array to store current content if selection is positive
  44198. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44199. */
  44200. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44201. /**
  44202. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44203. * @param ray defines the ray to test with
  44204. * @param selection defines the array to store current content if selection is positive
  44205. */
  44206. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44207. /**
  44208. * Subdivide the content into child blocks (this block will then be empty)
  44209. */
  44210. createInnerBlocks(): void;
  44211. /**
  44212. * @hidden
  44213. */
  44214. 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;
  44215. }
  44216. }
  44217. declare module BABYLON {
  44218. /**
  44219. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44220. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44221. */
  44222. export class Octree<T> {
  44223. /** 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.) */
  44224. maxDepth: number;
  44225. /**
  44226. * Blocks within the octree containing objects
  44227. */
  44228. blocks: Array<OctreeBlock<T>>;
  44229. /**
  44230. * Content stored in the octree
  44231. */
  44232. dynamicContent: T[];
  44233. private _maxBlockCapacity;
  44234. private _selectionContent;
  44235. private _creationFunc;
  44236. /**
  44237. * Creates a octree
  44238. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44239. * @param creationFunc function to be used to instatiate the octree
  44240. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44241. * @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.)
  44242. */
  44243. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44244. /** 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.) */
  44245. maxDepth?: number);
  44246. /**
  44247. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44248. * @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);
  44249. * @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);
  44250. * @param entries meshes to be added to the octree blocks
  44251. */
  44252. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44253. /**
  44254. * Adds a mesh to the octree
  44255. * @param entry Mesh to add to the octree
  44256. */
  44257. addMesh(entry: T): void;
  44258. /**
  44259. * Remove an element from the octree
  44260. * @param entry defines the element to remove
  44261. */
  44262. removeMesh(entry: T): void;
  44263. /**
  44264. * Selects an array of meshes within the frustum
  44265. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44266. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44267. * @returns array of meshes within the frustum
  44268. */
  44269. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44270. /**
  44271. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44272. * @param sphereCenter defines the bounding sphere center
  44273. * @param sphereRadius defines the bounding sphere radius
  44274. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44275. * @returns an array of objects that intersect the sphere
  44276. */
  44277. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44278. /**
  44279. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44280. * @param ray defines the ray to test with
  44281. * @returns array of intersected objects
  44282. */
  44283. intersectsRay(ray: Ray): SmartArray<T>;
  44284. /**
  44285. * Adds a mesh into the octree block if it intersects the block
  44286. */
  44287. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44288. /**
  44289. * Adds a submesh into the octree block if it intersects the block
  44290. */
  44291. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44292. }
  44293. }
  44294. declare module BABYLON {
  44295. interface Scene {
  44296. /**
  44297. * @hidden
  44298. * Backing Filed
  44299. */
  44300. _selectionOctree: Octree<AbstractMesh>;
  44301. /**
  44302. * Gets the octree used to boost mesh selection (picking)
  44303. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44304. */
  44305. selectionOctree: Octree<AbstractMesh>;
  44306. /**
  44307. * Creates or updates the octree used to boost selection (picking)
  44308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44309. * @param maxCapacity defines the maximum capacity per leaf
  44310. * @param maxDepth defines the maximum depth of the octree
  44311. * @returns an octree of AbstractMesh
  44312. */
  44313. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44314. }
  44315. interface AbstractMesh {
  44316. /**
  44317. * @hidden
  44318. * Backing Field
  44319. */
  44320. _submeshesOctree: Octree<SubMesh>;
  44321. /**
  44322. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44323. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44324. * @param maxCapacity defines the maximum size of each block (64 by default)
  44325. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44326. * @returns the new octree
  44327. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44328. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44329. */
  44330. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44331. }
  44332. /**
  44333. * Defines the octree scene component responsible to manage any octrees
  44334. * in a given scene.
  44335. */
  44336. export class OctreeSceneComponent {
  44337. /**
  44338. * The component name help to identify the component in the list of scene components.
  44339. */
  44340. readonly name: string;
  44341. /**
  44342. * The scene the component belongs to.
  44343. */
  44344. scene: Scene;
  44345. /**
  44346. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44347. */
  44348. readonly checksIsEnabled: boolean;
  44349. /**
  44350. * Creates a new instance of the component for the given scene
  44351. * @param scene Defines the scene to register the component in
  44352. */
  44353. constructor(scene: Scene);
  44354. /**
  44355. * Registers the component in a given scene
  44356. */
  44357. register(): void;
  44358. /**
  44359. * Return the list of active meshes
  44360. * @returns the list of active meshes
  44361. */
  44362. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44363. /**
  44364. * Return the list of active sub meshes
  44365. * @param mesh The mesh to get the candidates sub meshes from
  44366. * @returns the list of active sub meshes
  44367. */
  44368. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44369. private _tempRay;
  44370. /**
  44371. * Return the list of sub meshes intersecting with a given local ray
  44372. * @param mesh defines the mesh to find the submesh for
  44373. * @param localRay defines the ray in local space
  44374. * @returns the list of intersecting sub meshes
  44375. */
  44376. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44377. /**
  44378. * Return the list of sub meshes colliding with a collider
  44379. * @param mesh defines the mesh to find the submesh for
  44380. * @param collider defines the collider to evaluate the collision against
  44381. * @returns the list of colliding sub meshes
  44382. */
  44383. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44384. /**
  44385. * Rebuilds the elements related to this component in case of
  44386. * context lost for instance.
  44387. */
  44388. rebuild(): void;
  44389. /**
  44390. * Disposes the component and the associated ressources.
  44391. */
  44392. dispose(): void;
  44393. }
  44394. }
  44395. declare module BABYLON {
  44396. /**
  44397. * Renders a layer on top of an existing scene
  44398. */
  44399. export class UtilityLayerRenderer implements IDisposable {
  44400. /** the original scene that will be rendered on top of */
  44401. originalScene: Scene;
  44402. private _pointerCaptures;
  44403. private _lastPointerEvents;
  44404. private static _DefaultUtilityLayer;
  44405. private static _DefaultKeepDepthUtilityLayer;
  44406. private _sharedGizmoLight;
  44407. private _renderCamera;
  44408. /**
  44409. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44410. * @returns the camera that is used when rendering the utility layer
  44411. */
  44412. getRenderCamera(): Nullable<Camera>;
  44413. /**
  44414. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44415. * @param cam the camera that should be used when rendering the utility layer
  44416. */
  44417. setRenderCamera(cam: Nullable<Camera>): void;
  44418. /**
  44419. * @hidden
  44420. * Light which used by gizmos to get light shading
  44421. */
  44422. _getSharedGizmoLight(): HemisphericLight;
  44423. /**
  44424. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44425. */
  44426. pickUtilitySceneFirst: boolean;
  44427. /**
  44428. * 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)
  44429. */
  44430. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44431. /**
  44432. * 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)
  44433. */
  44434. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44435. /**
  44436. * The scene that is rendered on top of the original scene
  44437. */
  44438. utilityLayerScene: Scene;
  44439. /**
  44440. * If the utility layer should automatically be rendered on top of existing scene
  44441. */
  44442. shouldRender: boolean;
  44443. /**
  44444. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44445. */
  44446. onlyCheckPointerDownEvents: boolean;
  44447. /**
  44448. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44449. */
  44450. processAllEvents: boolean;
  44451. /**
  44452. * Observable raised when the pointer move from the utility layer scene to the main scene
  44453. */
  44454. onPointerOutObservable: Observable<number>;
  44455. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44456. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44457. private _afterRenderObserver;
  44458. private _sceneDisposeObserver;
  44459. private _originalPointerObserver;
  44460. /**
  44461. * Instantiates a UtilityLayerRenderer
  44462. * @param originalScene the original scene that will be rendered on top of
  44463. * @param handleEvents boolean indicating if the utility layer should handle events
  44464. */
  44465. constructor(
  44466. /** the original scene that will be rendered on top of */
  44467. originalScene: Scene, handleEvents?: boolean);
  44468. private _notifyObservers;
  44469. /**
  44470. * Renders the utility layers scene on top of the original scene
  44471. */
  44472. render(): void;
  44473. /**
  44474. * Disposes of the renderer
  44475. */
  44476. dispose(): void;
  44477. private _updateCamera;
  44478. }
  44479. }
  44480. declare module BABYLON {
  44481. /**
  44482. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44483. */
  44484. export class Gizmo implements IDisposable {
  44485. /** The utility layer the gizmo will be added to */
  44486. gizmoLayer: UtilityLayerRenderer;
  44487. /**
  44488. * The root mesh of the gizmo
  44489. */
  44490. _rootMesh: Mesh;
  44491. private _attachedMesh;
  44492. /**
  44493. * Ratio for the scale of the gizmo (Default: 1)
  44494. */
  44495. scaleRatio: number;
  44496. /**
  44497. * If a custom mesh has been set (Default: false)
  44498. */
  44499. protected _customMeshSet: boolean;
  44500. /**
  44501. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44502. * * When set, interactions will be enabled
  44503. */
  44504. attachedMesh: Nullable<AbstractMesh>;
  44505. /**
  44506. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44507. * @param mesh The mesh to replace the default mesh of the gizmo
  44508. */
  44509. setCustomMesh(mesh: Mesh): void;
  44510. /**
  44511. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44512. */
  44513. updateGizmoRotationToMatchAttachedMesh: boolean;
  44514. /**
  44515. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44516. */
  44517. updateGizmoPositionToMatchAttachedMesh: boolean;
  44518. /**
  44519. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44520. */
  44521. updateScale: boolean;
  44522. protected _interactionsEnabled: boolean;
  44523. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44524. private _beforeRenderObserver;
  44525. private _tempVector;
  44526. /**
  44527. * Creates a gizmo
  44528. * @param gizmoLayer The utility layer the gizmo will be added to
  44529. */
  44530. constructor(
  44531. /** The utility layer the gizmo will be added to */
  44532. gizmoLayer?: UtilityLayerRenderer);
  44533. /**
  44534. * Updates the gizmo to match the attached mesh's position/rotation
  44535. */
  44536. protected _update(): void;
  44537. /**
  44538. * Disposes of the gizmo
  44539. */
  44540. dispose(): void;
  44541. }
  44542. }
  44543. declare module BABYLON {
  44544. /**
  44545. * Single plane drag gizmo
  44546. */
  44547. export class PlaneDragGizmo extends Gizmo {
  44548. /**
  44549. * Drag behavior responsible for the gizmos dragging interactions
  44550. */
  44551. dragBehavior: PointerDragBehavior;
  44552. private _pointerObserver;
  44553. /**
  44554. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44555. */
  44556. snapDistance: number;
  44557. /**
  44558. * Event that fires each time the gizmo snaps to a new location.
  44559. * * snapDistance is the the change in distance
  44560. */
  44561. onSnapObservable: Observable<{
  44562. snapDistance: number;
  44563. }>;
  44564. private _plane;
  44565. private _coloredMaterial;
  44566. private _hoverMaterial;
  44567. private _isEnabled;
  44568. private _parent;
  44569. /** @hidden */
  44570. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44571. /** @hidden */
  44572. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44573. /**
  44574. * Creates a PlaneDragGizmo
  44575. * @param gizmoLayer The utility layer the gizmo will be added to
  44576. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44577. * @param color The color of the gizmo
  44578. */
  44579. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44580. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44581. /**
  44582. * If the gizmo is enabled
  44583. */
  44584. isEnabled: boolean;
  44585. /**
  44586. * Disposes of the gizmo
  44587. */
  44588. dispose(): void;
  44589. }
  44590. }
  44591. declare module BABYLON {
  44592. /**
  44593. * Gizmo that enables dragging a mesh along 3 axis
  44594. */
  44595. export class PositionGizmo extends Gizmo {
  44596. /**
  44597. * Internal gizmo used for interactions on the x axis
  44598. */
  44599. xGizmo: AxisDragGizmo;
  44600. /**
  44601. * Internal gizmo used for interactions on the y axis
  44602. */
  44603. yGizmo: AxisDragGizmo;
  44604. /**
  44605. * Internal gizmo used for interactions on the z axis
  44606. */
  44607. zGizmo: AxisDragGizmo;
  44608. /**
  44609. * Internal gizmo used for interactions on the yz plane
  44610. */
  44611. xPlaneGizmo: PlaneDragGizmo;
  44612. /**
  44613. * Internal gizmo used for interactions on the xz plane
  44614. */
  44615. yPlaneGizmo: PlaneDragGizmo;
  44616. /**
  44617. * Internal gizmo used for interactions on the xy plane
  44618. */
  44619. zPlaneGizmo: PlaneDragGizmo;
  44620. /**
  44621. * private variables
  44622. */
  44623. private _meshAttached;
  44624. private _updateGizmoRotationToMatchAttachedMesh;
  44625. private _snapDistance;
  44626. private _scaleRatio;
  44627. /** Fires an event when any of it's sub gizmos are dragged */
  44628. onDragStartObservable: Observable<unknown>;
  44629. /** Fires an event when any of it's sub gizmos are released from dragging */
  44630. onDragEndObservable: Observable<unknown>;
  44631. /**
  44632. * If set to true, planar drag is enabled
  44633. */
  44634. private _planarGizmoEnabled;
  44635. attachedMesh: Nullable<AbstractMesh>;
  44636. /**
  44637. * Creates a PositionGizmo
  44638. * @param gizmoLayer The utility layer the gizmo will be added to
  44639. */
  44640. constructor(gizmoLayer?: UtilityLayerRenderer);
  44641. /**
  44642. * If the planar drag gizmo is enabled
  44643. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44644. */
  44645. planarGizmoEnabled: boolean;
  44646. updateGizmoRotationToMatchAttachedMesh: boolean;
  44647. /**
  44648. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44649. */
  44650. snapDistance: number;
  44651. /**
  44652. * Ratio for the scale of the gizmo (Default: 1)
  44653. */
  44654. scaleRatio: number;
  44655. /**
  44656. * Disposes of the gizmo
  44657. */
  44658. dispose(): void;
  44659. /**
  44660. * CustomMeshes are not supported by this gizmo
  44661. * @param mesh The mesh to replace the default mesh of the gizmo
  44662. */
  44663. setCustomMesh(mesh: Mesh): void;
  44664. }
  44665. }
  44666. declare module BABYLON {
  44667. /**
  44668. * Single axis drag gizmo
  44669. */
  44670. export class AxisDragGizmo extends Gizmo {
  44671. /**
  44672. * Drag behavior responsible for the gizmos dragging interactions
  44673. */
  44674. dragBehavior: PointerDragBehavior;
  44675. private _pointerObserver;
  44676. /**
  44677. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44678. */
  44679. snapDistance: number;
  44680. /**
  44681. * Event that fires each time the gizmo snaps to a new location.
  44682. * * snapDistance is the the change in distance
  44683. */
  44684. onSnapObservable: Observable<{
  44685. snapDistance: number;
  44686. }>;
  44687. private _isEnabled;
  44688. private _parent;
  44689. private _arrow;
  44690. private _coloredMaterial;
  44691. private _hoverMaterial;
  44692. /** @hidden */
  44693. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44694. /** @hidden */
  44695. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44696. /**
  44697. * Creates an AxisDragGizmo
  44698. * @param gizmoLayer The utility layer the gizmo will be added to
  44699. * @param dragAxis The axis which the gizmo will be able to drag on
  44700. * @param color The color of the gizmo
  44701. */
  44702. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44703. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44704. /**
  44705. * If the gizmo is enabled
  44706. */
  44707. isEnabled: boolean;
  44708. /**
  44709. * Disposes of the gizmo
  44710. */
  44711. dispose(): void;
  44712. }
  44713. }
  44714. declare module BABYLON.Debug {
  44715. /**
  44716. * The Axes viewer will show 3 axes in a specific point in space
  44717. */
  44718. export class AxesViewer {
  44719. private _xAxis;
  44720. private _yAxis;
  44721. private _zAxis;
  44722. private _scaleLinesFactor;
  44723. private _instanced;
  44724. /**
  44725. * Gets the hosting scene
  44726. */
  44727. scene: Scene;
  44728. /**
  44729. * Gets or sets a number used to scale line length
  44730. */
  44731. scaleLines: number;
  44732. /** Gets the node hierarchy used to render x-axis */
  44733. readonly xAxis: TransformNode;
  44734. /** Gets the node hierarchy used to render y-axis */
  44735. readonly yAxis: TransformNode;
  44736. /** Gets the node hierarchy used to render z-axis */
  44737. readonly zAxis: TransformNode;
  44738. /**
  44739. * Creates a new AxesViewer
  44740. * @param scene defines the hosting scene
  44741. * @param scaleLines defines a number used to scale line length (1 by default)
  44742. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44743. * @param xAxis defines the node hierarchy used to render the x-axis
  44744. * @param yAxis defines the node hierarchy used to render the y-axis
  44745. * @param zAxis defines the node hierarchy used to render the z-axis
  44746. */
  44747. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44748. /**
  44749. * Force the viewer to update
  44750. * @param position defines the position of the viewer
  44751. * @param xaxis defines the x axis of the viewer
  44752. * @param yaxis defines the y axis of the viewer
  44753. * @param zaxis defines the z axis of the viewer
  44754. */
  44755. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44756. /**
  44757. * Creates an instance of this axes viewer.
  44758. * @returns a new axes viewer with instanced meshes
  44759. */
  44760. createInstance(): AxesViewer;
  44761. /** Releases resources */
  44762. dispose(): void;
  44763. private static _SetRenderingGroupId;
  44764. }
  44765. }
  44766. declare module BABYLON.Debug {
  44767. /**
  44768. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44769. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44770. */
  44771. export class BoneAxesViewer extends AxesViewer {
  44772. /**
  44773. * Gets or sets the target mesh where to display the axes viewer
  44774. */
  44775. mesh: Nullable<Mesh>;
  44776. /**
  44777. * Gets or sets the target bone where to display the axes viewer
  44778. */
  44779. bone: Nullable<Bone>;
  44780. /** Gets current position */
  44781. pos: Vector3;
  44782. /** Gets direction of X axis */
  44783. xaxis: Vector3;
  44784. /** Gets direction of Y axis */
  44785. yaxis: Vector3;
  44786. /** Gets direction of Z axis */
  44787. zaxis: Vector3;
  44788. /**
  44789. * Creates a new BoneAxesViewer
  44790. * @param scene defines the hosting scene
  44791. * @param bone defines the target bone
  44792. * @param mesh defines the target mesh
  44793. * @param scaleLines defines a scaling factor for line length (1 by default)
  44794. */
  44795. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44796. /**
  44797. * Force the viewer to update
  44798. */
  44799. update(): void;
  44800. /** Releases resources */
  44801. dispose(): void;
  44802. }
  44803. }
  44804. declare module BABYLON {
  44805. /**
  44806. * Interface used to define scene explorer extensibility option
  44807. */
  44808. export interface IExplorerExtensibilityOption {
  44809. /**
  44810. * Define the option label
  44811. */
  44812. label: string;
  44813. /**
  44814. * Defines the action to execute on click
  44815. */
  44816. action: (entity: any) => void;
  44817. }
  44818. /**
  44819. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44820. */
  44821. export interface IExplorerExtensibilityGroup {
  44822. /**
  44823. * Defines a predicate to test if a given type mut be extended
  44824. */
  44825. predicate: (entity: any) => boolean;
  44826. /**
  44827. * Gets the list of options added to a type
  44828. */
  44829. entries: IExplorerExtensibilityOption[];
  44830. }
  44831. /**
  44832. * Interface used to define the options to use to create the Inspector
  44833. */
  44834. export interface IInspectorOptions {
  44835. /**
  44836. * Display in overlay mode (default: false)
  44837. */
  44838. overlay?: boolean;
  44839. /**
  44840. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44841. */
  44842. globalRoot?: HTMLElement;
  44843. /**
  44844. * Display the Scene explorer
  44845. */
  44846. showExplorer?: boolean;
  44847. /**
  44848. * Display the property inspector
  44849. */
  44850. showInspector?: boolean;
  44851. /**
  44852. * Display in embed mode (both panes on the right)
  44853. */
  44854. embedMode?: boolean;
  44855. /**
  44856. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44857. */
  44858. handleResize?: boolean;
  44859. /**
  44860. * Allow the panes to popup (default: true)
  44861. */
  44862. enablePopup?: boolean;
  44863. /**
  44864. * Allow the panes to be closed by users (default: true)
  44865. */
  44866. enableClose?: boolean;
  44867. /**
  44868. * Optional list of extensibility entries
  44869. */
  44870. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44871. /**
  44872. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44873. */
  44874. inspectorURL?: string;
  44875. /**
  44876. * Optional initial tab (default to DebugLayerTab.Properties)
  44877. */
  44878. initialTab?: DebugLayerTab;
  44879. }
  44880. interface Scene {
  44881. /**
  44882. * @hidden
  44883. * Backing field
  44884. */
  44885. _debugLayer: DebugLayer;
  44886. /**
  44887. * Gets the debug layer (aka Inspector) associated with the scene
  44888. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44889. */
  44890. debugLayer: DebugLayer;
  44891. }
  44892. /**
  44893. * Enum of inspector action tab
  44894. */
  44895. export enum DebugLayerTab {
  44896. /**
  44897. * Properties tag (default)
  44898. */
  44899. Properties = 0,
  44900. /**
  44901. * Debug tab
  44902. */
  44903. Debug = 1,
  44904. /**
  44905. * Statistics tab
  44906. */
  44907. Statistics = 2,
  44908. /**
  44909. * Tools tab
  44910. */
  44911. Tools = 3,
  44912. /**
  44913. * Settings tab
  44914. */
  44915. Settings = 4
  44916. }
  44917. /**
  44918. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44919. * what is happening in your scene
  44920. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44921. */
  44922. export class DebugLayer {
  44923. /**
  44924. * Define the url to get the inspector script from.
  44925. * By default it uses the babylonjs CDN.
  44926. * @ignoreNaming
  44927. */
  44928. static InspectorURL: string;
  44929. private _scene;
  44930. private BJSINSPECTOR;
  44931. private _onPropertyChangedObservable?;
  44932. /**
  44933. * Observable triggered when a property is changed through the inspector.
  44934. */
  44935. readonly onPropertyChangedObservable: any;
  44936. /**
  44937. * Instantiates a new debug layer.
  44938. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44939. * what is happening in your scene
  44940. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44941. * @param scene Defines the scene to inspect
  44942. */
  44943. constructor(scene: Scene);
  44944. /** Creates the inspector window. */
  44945. private _createInspector;
  44946. /**
  44947. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44948. * @param entity defines the entity to select
  44949. * @param lineContainerTitle defines the specific block to highlight
  44950. */
  44951. select(entity: any, lineContainerTitle?: string): void;
  44952. /** Get the inspector from bundle or global */
  44953. private _getGlobalInspector;
  44954. /**
  44955. * Get if the inspector is visible or not.
  44956. * @returns true if visible otherwise, false
  44957. */
  44958. isVisible(): boolean;
  44959. /**
  44960. * Hide the inspector and close its window.
  44961. */
  44962. hide(): void;
  44963. /**
  44964. * Launch the debugLayer.
  44965. * @param config Define the configuration of the inspector
  44966. * @return a promise fulfilled when the debug layer is visible
  44967. */
  44968. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44969. }
  44970. }
  44971. declare module BABYLON {
  44972. /**
  44973. * Class containing static functions to help procedurally build meshes
  44974. */
  44975. export class BoxBuilder {
  44976. /**
  44977. * Creates a box mesh
  44978. * * The parameter `size` sets the size (float) of each box side (default 1)
  44979. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44980. * * 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)
  44981. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44983. * * 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
  44984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44985. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44986. * @param name defines the name of the mesh
  44987. * @param options defines the options used to create the mesh
  44988. * @param scene defines the hosting scene
  44989. * @returns the box mesh
  44990. */
  44991. static CreateBox(name: string, options: {
  44992. size?: number;
  44993. width?: number;
  44994. height?: number;
  44995. depth?: number;
  44996. faceUV?: Vector4[];
  44997. faceColors?: Color4[];
  44998. sideOrientation?: number;
  44999. frontUVs?: Vector4;
  45000. backUVs?: Vector4;
  45001. wrap?: boolean;
  45002. topBaseAt?: number;
  45003. bottomBaseAt?: number;
  45004. updatable?: boolean;
  45005. }, scene?: Nullable<Scene>): Mesh;
  45006. }
  45007. }
  45008. declare module BABYLON {
  45009. /**
  45010. * Class containing static functions to help procedurally build meshes
  45011. */
  45012. export class SphereBuilder {
  45013. /**
  45014. * Creates a sphere mesh
  45015. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45016. * * 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`)
  45017. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45018. * * 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
  45019. * * 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)
  45020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45021. * * 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
  45022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45023. * @param name defines the name of the mesh
  45024. * @param options defines the options used to create the mesh
  45025. * @param scene defines the hosting scene
  45026. * @returns the sphere mesh
  45027. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45028. */
  45029. static CreateSphere(name: string, options: {
  45030. segments?: number;
  45031. diameter?: number;
  45032. diameterX?: number;
  45033. diameterY?: number;
  45034. diameterZ?: number;
  45035. arc?: number;
  45036. slice?: number;
  45037. sideOrientation?: number;
  45038. frontUVs?: Vector4;
  45039. backUVs?: Vector4;
  45040. updatable?: boolean;
  45041. }, scene?: Nullable<Scene>): Mesh;
  45042. }
  45043. }
  45044. declare module BABYLON.Debug {
  45045. /**
  45046. * Used to show the physics impostor around the specific mesh
  45047. */
  45048. export class PhysicsViewer {
  45049. /** @hidden */
  45050. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45051. /** @hidden */
  45052. protected _meshes: Array<Nullable<AbstractMesh>>;
  45053. /** @hidden */
  45054. protected _scene: Nullable<Scene>;
  45055. /** @hidden */
  45056. protected _numMeshes: number;
  45057. /** @hidden */
  45058. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45059. private _renderFunction;
  45060. private _utilityLayer;
  45061. private _debugBoxMesh;
  45062. private _debugSphereMesh;
  45063. private _debugCylinderMesh;
  45064. private _debugMaterial;
  45065. private _debugMeshMeshes;
  45066. /**
  45067. * Creates a new PhysicsViewer
  45068. * @param scene defines the hosting scene
  45069. */
  45070. constructor(scene: Scene);
  45071. /** @hidden */
  45072. protected _updateDebugMeshes(): void;
  45073. /**
  45074. * Renders a specified physic impostor
  45075. * @param impostor defines the impostor to render
  45076. * @param targetMesh defines the mesh represented by the impostor
  45077. * @returns the new debug mesh used to render the impostor
  45078. */
  45079. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45080. /**
  45081. * Hides a specified physic impostor
  45082. * @param impostor defines the impostor to hide
  45083. */
  45084. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45085. private _getDebugMaterial;
  45086. private _getDebugBoxMesh;
  45087. private _getDebugSphereMesh;
  45088. private _getDebugCylinderMesh;
  45089. private _getDebugMeshMesh;
  45090. private _getDebugMesh;
  45091. /** Releases all resources */
  45092. dispose(): void;
  45093. }
  45094. }
  45095. declare module BABYLON {
  45096. /**
  45097. * Class containing static functions to help procedurally build meshes
  45098. */
  45099. export class LinesBuilder {
  45100. /**
  45101. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45102. * * 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
  45103. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45104. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45105. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45106. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45107. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45108. * * 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
  45109. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45112. * @param name defines the name of the new line system
  45113. * @param options defines the options used to create the line system
  45114. * @param scene defines the hosting scene
  45115. * @returns a new line system mesh
  45116. */
  45117. static CreateLineSystem(name: string, options: {
  45118. lines: Vector3[][];
  45119. updatable?: boolean;
  45120. instance?: Nullable<LinesMesh>;
  45121. colors?: Nullable<Color4[][]>;
  45122. useVertexAlpha?: boolean;
  45123. }, scene: Nullable<Scene>): LinesMesh;
  45124. /**
  45125. * Creates a line mesh
  45126. * 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
  45127. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45128. * * The parameter `points` is an array successive Vector3
  45129. * * 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
  45130. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45131. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45132. * * When updating an instance, remember that only point positions can change, not the number of points
  45133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45135. * @param name defines the name of the new line system
  45136. * @param options defines the options used to create the line system
  45137. * @param scene defines the hosting scene
  45138. * @returns a new line mesh
  45139. */
  45140. static CreateLines(name: string, options: {
  45141. points: Vector3[];
  45142. updatable?: boolean;
  45143. instance?: Nullable<LinesMesh>;
  45144. colors?: Color4[];
  45145. useVertexAlpha?: boolean;
  45146. }, scene?: Nullable<Scene>): LinesMesh;
  45147. /**
  45148. * Creates a dashed line mesh
  45149. * * 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
  45150. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45151. * * The parameter `points` is an array successive Vector3
  45152. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45153. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45154. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45155. * * 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
  45156. * * When updating an instance, remember that only point positions can change, not the number of points
  45157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45158. * @param name defines the name of the mesh
  45159. * @param options defines the options used to create the mesh
  45160. * @param scene defines the hosting scene
  45161. * @returns the dashed line mesh
  45162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45163. */
  45164. static CreateDashedLines(name: string, options: {
  45165. points: Vector3[];
  45166. dashSize?: number;
  45167. gapSize?: number;
  45168. dashNb?: number;
  45169. updatable?: boolean;
  45170. instance?: LinesMesh;
  45171. }, scene?: Nullable<Scene>): LinesMesh;
  45172. }
  45173. }
  45174. declare module BABYLON {
  45175. /**
  45176. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45177. * in order to better appreciate the issue one might have.
  45178. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45179. */
  45180. export class RayHelper {
  45181. /**
  45182. * Defines the ray we are currently tryin to visualize.
  45183. */
  45184. ray: Nullable<Ray>;
  45185. private _renderPoints;
  45186. private _renderLine;
  45187. private _renderFunction;
  45188. private _scene;
  45189. private _updateToMeshFunction;
  45190. private _attachedToMesh;
  45191. private _meshSpaceDirection;
  45192. private _meshSpaceOrigin;
  45193. /**
  45194. * Helper function to create a colored helper in a scene in one line.
  45195. * @param ray Defines the ray we are currently tryin to visualize
  45196. * @param scene Defines the scene the ray is used in
  45197. * @param color Defines the color we want to see the ray in
  45198. * @returns The newly created ray helper.
  45199. */
  45200. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45201. /**
  45202. * Instantiate a new ray helper.
  45203. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45204. * in order to better appreciate the issue one might have.
  45205. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45206. * @param ray Defines the ray we are currently tryin to visualize
  45207. */
  45208. constructor(ray: Ray);
  45209. /**
  45210. * Shows the ray we are willing to debug.
  45211. * @param scene Defines the scene the ray needs to be rendered in
  45212. * @param color Defines the color the ray needs to be rendered in
  45213. */
  45214. show(scene: Scene, color?: Color3): void;
  45215. /**
  45216. * Hides the ray we are debugging.
  45217. */
  45218. hide(): void;
  45219. private _render;
  45220. /**
  45221. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45222. * @param mesh Defines the mesh we want the helper attached to
  45223. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45224. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45225. * @param length Defines the length of the ray
  45226. */
  45227. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45228. /**
  45229. * Detach the ray helper from the mesh it has previously been attached to.
  45230. */
  45231. detachFromMesh(): void;
  45232. private _updateToMesh;
  45233. /**
  45234. * Dispose the helper and release its associated resources.
  45235. */
  45236. dispose(): void;
  45237. }
  45238. }
  45239. declare module BABYLON.Debug {
  45240. /**
  45241. * Class used to render a debug view of a given skeleton
  45242. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45243. */
  45244. export class SkeletonViewer {
  45245. /** defines the skeleton to render */
  45246. skeleton: Skeleton;
  45247. /** defines the mesh attached to the skeleton */
  45248. mesh: AbstractMesh;
  45249. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45250. autoUpdateBonesMatrices: boolean;
  45251. /** defines the rendering group id to use with the viewer */
  45252. renderingGroupId: number;
  45253. /** Gets or sets the color used to render the skeleton */
  45254. color: Color3;
  45255. private _scene;
  45256. private _debugLines;
  45257. private _debugMesh;
  45258. private _isEnabled;
  45259. private _renderFunction;
  45260. private _utilityLayer;
  45261. /**
  45262. * Returns the mesh used to render the bones
  45263. */
  45264. readonly debugMesh: Nullable<LinesMesh>;
  45265. /**
  45266. * Creates a new SkeletonViewer
  45267. * @param skeleton defines the skeleton to render
  45268. * @param mesh defines the mesh attached to the skeleton
  45269. * @param scene defines the hosting scene
  45270. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45271. * @param renderingGroupId defines the rendering group id to use with the viewer
  45272. */
  45273. constructor(
  45274. /** defines the skeleton to render */
  45275. skeleton: Skeleton,
  45276. /** defines the mesh attached to the skeleton */
  45277. mesh: AbstractMesh, scene: Scene,
  45278. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45279. autoUpdateBonesMatrices?: boolean,
  45280. /** defines the rendering group id to use with the viewer */
  45281. renderingGroupId?: number);
  45282. /** Gets or sets a boolean indicating if the viewer is enabled */
  45283. isEnabled: boolean;
  45284. private _getBonePosition;
  45285. private _getLinesForBonesWithLength;
  45286. private _getLinesForBonesNoLength;
  45287. /** Update the viewer to sync with current skeleton state */
  45288. update(): void;
  45289. /** Release associated resources */
  45290. dispose(): void;
  45291. }
  45292. }
  45293. declare module BABYLON {
  45294. /**
  45295. * Options to create the null engine
  45296. */
  45297. export class NullEngineOptions {
  45298. /**
  45299. * Render width (Default: 512)
  45300. */
  45301. renderWidth: number;
  45302. /**
  45303. * Render height (Default: 256)
  45304. */
  45305. renderHeight: number;
  45306. /**
  45307. * Texture size (Default: 512)
  45308. */
  45309. textureSize: number;
  45310. /**
  45311. * If delta time between frames should be constant
  45312. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45313. */
  45314. deterministicLockstep: boolean;
  45315. /**
  45316. * Maximum about of steps between frames (Default: 4)
  45317. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45318. */
  45319. lockstepMaxSteps: number;
  45320. }
  45321. /**
  45322. * The null engine class provides support for headless version of babylon.js.
  45323. * This can be used in server side scenario or for testing purposes
  45324. */
  45325. export class NullEngine extends Engine {
  45326. private _options;
  45327. /**
  45328. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45329. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45330. * @returns true if engine is in deterministic lock step mode
  45331. */
  45332. isDeterministicLockStep(): boolean;
  45333. /**
  45334. * Gets the max steps when engine is running in deterministic lock step
  45335. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45336. * @returns the max steps
  45337. */
  45338. getLockstepMaxSteps(): number;
  45339. /**
  45340. * Gets the current hardware scaling level.
  45341. * By default the hardware scaling level is computed from the window device ratio.
  45342. * 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.
  45343. * @returns a number indicating the current hardware scaling level
  45344. */
  45345. getHardwareScalingLevel(): number;
  45346. constructor(options?: NullEngineOptions);
  45347. /**
  45348. * Creates a vertex buffer
  45349. * @param vertices the data for the vertex buffer
  45350. * @returns the new WebGL static buffer
  45351. */
  45352. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45353. /**
  45354. * Creates a new index buffer
  45355. * @param indices defines the content of the index buffer
  45356. * @param updatable defines if the index buffer must be updatable
  45357. * @returns a new webGL buffer
  45358. */
  45359. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45360. /**
  45361. * Clear the current render buffer or the current render target (if any is set up)
  45362. * @param color defines the color to use
  45363. * @param backBuffer defines if the back buffer must be cleared
  45364. * @param depth defines if the depth buffer must be cleared
  45365. * @param stencil defines if the stencil buffer must be cleared
  45366. */
  45367. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45368. /**
  45369. * Gets the current render width
  45370. * @param useScreen defines if screen size must be used (or the current render target if any)
  45371. * @returns a number defining the current render width
  45372. */
  45373. getRenderWidth(useScreen?: boolean): number;
  45374. /**
  45375. * Gets the current render height
  45376. * @param useScreen defines if screen size must be used (or the current render target if any)
  45377. * @returns a number defining the current render height
  45378. */
  45379. getRenderHeight(useScreen?: boolean): number;
  45380. /**
  45381. * Set the WebGL's viewport
  45382. * @param viewport defines the viewport element to be used
  45383. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45384. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45385. */
  45386. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45387. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45388. /**
  45389. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45390. * @param pipelineContext defines the pipeline context to use
  45391. * @param uniformsNames defines the list of uniform names
  45392. * @returns an array of webGL uniform locations
  45393. */
  45394. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45395. /**
  45396. * Gets the lsit of active attributes for a given webGL program
  45397. * @param pipelineContext defines the pipeline context to use
  45398. * @param attributesNames defines the list of attribute names to get
  45399. * @returns an array of indices indicating the offset of each attribute
  45400. */
  45401. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45402. /**
  45403. * Binds an effect to the webGL context
  45404. * @param effect defines the effect to bind
  45405. */
  45406. bindSamplers(effect: Effect): void;
  45407. /**
  45408. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45409. * @param effect defines the effect to activate
  45410. */
  45411. enableEffect(effect: Effect): void;
  45412. /**
  45413. * Set various states to the webGL context
  45414. * @param culling defines backface culling state
  45415. * @param zOffset defines the value to apply to zOffset (0 by default)
  45416. * @param force defines if states must be applied even if cache is up to date
  45417. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45418. */
  45419. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45420. /**
  45421. * Set the value of an uniform to an array of int32
  45422. * @param uniform defines the webGL uniform location where to store the value
  45423. * @param array defines the array of int32 to store
  45424. */
  45425. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45426. /**
  45427. * Set the value of an uniform to an array of int32 (stored as vec2)
  45428. * @param uniform defines the webGL uniform location where to store the value
  45429. * @param array defines the array of int32 to store
  45430. */
  45431. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45432. /**
  45433. * Set the value of an uniform to an array of int32 (stored as vec3)
  45434. * @param uniform defines the webGL uniform location where to store the value
  45435. * @param array defines the array of int32 to store
  45436. */
  45437. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45438. /**
  45439. * Set the value of an uniform to an array of int32 (stored as vec4)
  45440. * @param uniform defines the webGL uniform location where to store the value
  45441. * @param array defines the array of int32 to store
  45442. */
  45443. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45444. /**
  45445. * Set the value of an uniform to an array of float32
  45446. * @param uniform defines the webGL uniform location where to store the value
  45447. * @param array defines the array of float32 to store
  45448. */
  45449. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45450. /**
  45451. * Set the value of an uniform to an array of float32 (stored as vec2)
  45452. * @param uniform defines the webGL uniform location where to store the value
  45453. * @param array defines the array of float32 to store
  45454. */
  45455. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45456. /**
  45457. * Set the value of an uniform to an array of float32 (stored as vec3)
  45458. * @param uniform defines the webGL uniform location where to store the value
  45459. * @param array defines the array of float32 to store
  45460. */
  45461. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45462. /**
  45463. * Set the value of an uniform to an array of float32 (stored as vec4)
  45464. * @param uniform defines the webGL uniform location where to store the value
  45465. * @param array defines the array of float32 to store
  45466. */
  45467. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45468. /**
  45469. * Set the value of an uniform to an array of number
  45470. * @param uniform defines the webGL uniform location where to store the value
  45471. * @param array defines the array of number to store
  45472. */
  45473. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45474. /**
  45475. * Set the value of an uniform to an array of number (stored as vec2)
  45476. * @param uniform defines the webGL uniform location where to store the value
  45477. * @param array defines the array of number to store
  45478. */
  45479. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45480. /**
  45481. * Set the value of an uniform to an array of number (stored as vec3)
  45482. * @param uniform defines the webGL uniform location where to store the value
  45483. * @param array defines the array of number to store
  45484. */
  45485. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45486. /**
  45487. * Set the value of an uniform to an array of number (stored as vec4)
  45488. * @param uniform defines the webGL uniform location where to store the value
  45489. * @param array defines the array of number to store
  45490. */
  45491. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45492. /**
  45493. * Set the value of an uniform to an array of float32 (stored as matrices)
  45494. * @param uniform defines the webGL uniform location where to store the value
  45495. * @param matrices defines the array of float32 to store
  45496. */
  45497. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45498. /**
  45499. * Set the value of an uniform to a matrix (3x3)
  45500. * @param uniform defines the webGL uniform location where to store the value
  45501. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45502. */
  45503. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45504. /**
  45505. * Set the value of an uniform to a matrix (2x2)
  45506. * @param uniform defines the webGL uniform location where to store the value
  45507. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45508. */
  45509. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45510. /**
  45511. * Set the value of an uniform to a number (float)
  45512. * @param uniform defines the webGL uniform location where to store the value
  45513. * @param value defines the float number to store
  45514. */
  45515. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45516. /**
  45517. * Set the value of an uniform to a vec2
  45518. * @param uniform defines the webGL uniform location where to store the value
  45519. * @param x defines the 1st component of the value
  45520. * @param y defines the 2nd component of the value
  45521. */
  45522. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45523. /**
  45524. * Set the value of an uniform to a vec3
  45525. * @param uniform defines the webGL uniform location where to store the value
  45526. * @param x defines the 1st component of the value
  45527. * @param y defines the 2nd component of the value
  45528. * @param z defines the 3rd component of the value
  45529. */
  45530. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45531. /**
  45532. * Set the value of an uniform to a boolean
  45533. * @param uniform defines the webGL uniform location where to store the value
  45534. * @param bool defines the boolean to store
  45535. */
  45536. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45537. /**
  45538. * Set the value of an uniform to a vec4
  45539. * @param uniform defines the webGL uniform location where to store the value
  45540. * @param x defines the 1st component of the value
  45541. * @param y defines the 2nd component of the value
  45542. * @param z defines the 3rd component of the value
  45543. * @param w defines the 4th component of the value
  45544. */
  45545. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45546. /**
  45547. * Sets the current alpha mode
  45548. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45549. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45550. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45551. */
  45552. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45553. /**
  45554. * Bind webGl buffers directly to the webGL context
  45555. * @param vertexBuffers defines the vertex buffer to bind
  45556. * @param indexBuffer defines the index buffer to bind
  45557. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45558. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45559. * @param effect defines the effect associated with the vertex buffer
  45560. */
  45561. bindBuffers(vertexBuffers: {
  45562. [key: string]: VertexBuffer;
  45563. }, indexBuffer: DataBuffer, effect: Effect): void;
  45564. /**
  45565. * Force the entire cache to be cleared
  45566. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45567. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45568. */
  45569. wipeCaches(bruteForce?: boolean): void;
  45570. /**
  45571. * Send a draw order
  45572. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45573. * @param indexStart defines the starting index
  45574. * @param indexCount defines the number of index to draw
  45575. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45576. */
  45577. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45578. /**
  45579. * Draw a list of indexed primitives
  45580. * @param fillMode defines the primitive to use
  45581. * @param indexStart defines the starting index
  45582. * @param indexCount defines the number of index to draw
  45583. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45584. */
  45585. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45586. /**
  45587. * Draw a list of unindexed primitives
  45588. * @param fillMode defines the primitive to use
  45589. * @param verticesStart defines the index of first vertex to draw
  45590. * @param verticesCount defines the count of vertices to draw
  45591. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45592. */
  45593. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45594. /** @hidden */
  45595. _createTexture(): WebGLTexture;
  45596. /** @hidden */
  45597. _releaseTexture(texture: InternalTexture): void;
  45598. /**
  45599. * Usually called from Texture.ts.
  45600. * Passed information to create a WebGLTexture
  45601. * @param urlArg defines a value which contains one of the following:
  45602. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45603. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45604. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45605. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45606. * @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)
  45607. * @param scene needed for loading to the correct scene
  45608. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45609. * @param onLoad optional callback to be called upon successful completion
  45610. * @param onError optional callback to be called upon failure
  45611. * @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
  45612. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45613. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45614. * @param forcedExtension defines the extension to use to pick the right loader
  45615. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45616. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45617. */
  45618. 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;
  45619. /**
  45620. * Creates a new render target texture
  45621. * @param size defines the size of the texture
  45622. * @param options defines the options used to create the texture
  45623. * @returns a new render target texture stored in an InternalTexture
  45624. */
  45625. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45626. /**
  45627. * Update the sampling mode of a given texture
  45628. * @param samplingMode defines the required sampling mode
  45629. * @param texture defines the texture to update
  45630. */
  45631. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45632. /**
  45633. * Binds the frame buffer to the specified texture.
  45634. * @param texture The texture to render to or null for the default canvas
  45635. * @param faceIndex The face of the texture to render to in case of cube texture
  45636. * @param requiredWidth The width of the target to render to
  45637. * @param requiredHeight The height of the target to render to
  45638. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45639. * @param depthStencilTexture The depth stencil texture to use to render
  45640. * @param lodLevel defines le lod level to bind to the frame buffer
  45641. */
  45642. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45643. /**
  45644. * Unbind the current render target texture from the webGL context
  45645. * @param texture defines the render target texture to unbind
  45646. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45647. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45648. */
  45649. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45650. /**
  45651. * Creates a dynamic vertex buffer
  45652. * @param vertices the data for the dynamic vertex buffer
  45653. * @returns the new WebGL dynamic buffer
  45654. */
  45655. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45656. /**
  45657. * Update the content of a dynamic texture
  45658. * @param texture defines the texture to update
  45659. * @param canvas defines the canvas containing the source
  45660. * @param invertY defines if data must be stored with Y axis inverted
  45661. * @param premulAlpha defines if alpha is stored as premultiplied
  45662. * @param format defines the format of the data
  45663. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45664. */
  45665. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45666. /**
  45667. * Gets a boolean indicating if all created effects are ready
  45668. * @returns true if all effects are ready
  45669. */
  45670. areAllEffectsReady(): boolean;
  45671. /**
  45672. * @hidden
  45673. * Get the current error code of the webGL context
  45674. * @returns the error code
  45675. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45676. */
  45677. getError(): number;
  45678. /** @hidden */
  45679. _getUnpackAlignement(): number;
  45680. /** @hidden */
  45681. _unpackFlipY(value: boolean): void;
  45682. /**
  45683. * Update a dynamic index buffer
  45684. * @param indexBuffer defines the target index buffer
  45685. * @param indices defines the data to update
  45686. * @param offset defines the offset in the target index buffer where update should start
  45687. */
  45688. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45689. /**
  45690. * Updates a dynamic vertex buffer.
  45691. * @param vertexBuffer the vertex buffer to update
  45692. * @param vertices the data used to update the vertex buffer
  45693. * @param byteOffset the byte offset of the data (optional)
  45694. * @param byteLength the byte length of the data (optional)
  45695. */
  45696. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45697. /** @hidden */
  45698. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45699. /** @hidden */
  45700. _bindTexture(channel: number, texture: InternalTexture): void;
  45701. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45702. /**
  45703. * 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
  45704. */
  45705. releaseEffects(): void;
  45706. displayLoadingUI(): void;
  45707. hideLoadingUI(): void;
  45708. /** @hidden */
  45709. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45710. /** @hidden */
  45711. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45712. /** @hidden */
  45713. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45714. /** @hidden */
  45715. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45716. }
  45717. }
  45718. declare module BABYLON {
  45719. /** @hidden */
  45720. export class _OcclusionDataStorage {
  45721. /** @hidden */
  45722. occlusionInternalRetryCounter: number;
  45723. /** @hidden */
  45724. isOcclusionQueryInProgress: boolean;
  45725. /** @hidden */
  45726. isOccluded: boolean;
  45727. /** @hidden */
  45728. occlusionRetryCount: number;
  45729. /** @hidden */
  45730. occlusionType: number;
  45731. /** @hidden */
  45732. occlusionQueryAlgorithmType: number;
  45733. }
  45734. interface Engine {
  45735. /**
  45736. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45737. * @return the new query
  45738. */
  45739. createQuery(): WebGLQuery;
  45740. /**
  45741. * Delete and release a webGL query
  45742. * @param query defines the query to delete
  45743. * @return the current engine
  45744. */
  45745. deleteQuery(query: WebGLQuery): Engine;
  45746. /**
  45747. * Check if a given query has resolved and got its value
  45748. * @param query defines the query to check
  45749. * @returns true if the query got its value
  45750. */
  45751. isQueryResultAvailable(query: WebGLQuery): boolean;
  45752. /**
  45753. * Gets the value of a given query
  45754. * @param query defines the query to check
  45755. * @returns the value of the query
  45756. */
  45757. getQueryResult(query: WebGLQuery): number;
  45758. /**
  45759. * Initiates an occlusion query
  45760. * @param algorithmType defines the algorithm to use
  45761. * @param query defines the query to use
  45762. * @returns the current engine
  45763. * @see http://doc.babylonjs.com/features/occlusionquery
  45764. */
  45765. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45766. /**
  45767. * Ends an occlusion query
  45768. * @see http://doc.babylonjs.com/features/occlusionquery
  45769. * @param algorithmType defines the algorithm to use
  45770. * @returns the current engine
  45771. */
  45772. endOcclusionQuery(algorithmType: number): Engine;
  45773. /**
  45774. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45775. * Please note that only one query can be issued at a time
  45776. * @returns a time token used to track the time span
  45777. */
  45778. startTimeQuery(): Nullable<_TimeToken>;
  45779. /**
  45780. * Ends a time query
  45781. * @param token defines the token used to measure the time span
  45782. * @returns the time spent (in ns)
  45783. */
  45784. endTimeQuery(token: _TimeToken): int;
  45785. /** @hidden */
  45786. _currentNonTimestampToken: Nullable<_TimeToken>;
  45787. /** @hidden */
  45788. _createTimeQuery(): WebGLQuery;
  45789. /** @hidden */
  45790. _deleteTimeQuery(query: WebGLQuery): void;
  45791. /** @hidden */
  45792. _getGlAlgorithmType(algorithmType: number): number;
  45793. /** @hidden */
  45794. _getTimeQueryResult(query: WebGLQuery): any;
  45795. /** @hidden */
  45796. _getTimeQueryAvailability(query: WebGLQuery): any;
  45797. }
  45798. interface AbstractMesh {
  45799. /**
  45800. * Backing filed
  45801. * @hidden
  45802. */
  45803. __occlusionDataStorage: _OcclusionDataStorage;
  45804. /**
  45805. * Access property
  45806. * @hidden
  45807. */
  45808. _occlusionDataStorage: _OcclusionDataStorage;
  45809. /**
  45810. * 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.
  45811. * The default value is -1 which means don't break the query and wait till the result
  45812. * @see http://doc.babylonjs.com/features/occlusionquery
  45813. */
  45814. occlusionRetryCount: number;
  45815. /**
  45816. * 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:
  45817. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45818. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45819. * * 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.
  45820. * @see http://doc.babylonjs.com/features/occlusionquery
  45821. */
  45822. occlusionType: number;
  45823. /**
  45824. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45825. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45826. * * 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.
  45827. * @see http://doc.babylonjs.com/features/occlusionquery
  45828. */
  45829. occlusionQueryAlgorithmType: number;
  45830. /**
  45831. * 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
  45832. * @see http://doc.babylonjs.com/features/occlusionquery
  45833. */
  45834. isOccluded: boolean;
  45835. /**
  45836. * Flag to check the progress status of the query
  45837. * @see http://doc.babylonjs.com/features/occlusionquery
  45838. */
  45839. isOcclusionQueryInProgress: boolean;
  45840. }
  45841. }
  45842. declare module BABYLON {
  45843. /** @hidden */
  45844. export var _forceTransformFeedbackToBundle: boolean;
  45845. interface Engine {
  45846. /**
  45847. * Creates a webGL transform feedback object
  45848. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45849. * @returns the webGL transform feedback object
  45850. */
  45851. createTransformFeedback(): WebGLTransformFeedback;
  45852. /**
  45853. * Delete a webGL transform feedback object
  45854. * @param value defines the webGL transform feedback object to delete
  45855. */
  45856. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45857. /**
  45858. * Bind a webGL transform feedback object to the webgl context
  45859. * @param value defines the webGL transform feedback object to bind
  45860. */
  45861. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45862. /**
  45863. * Begins a transform feedback operation
  45864. * @param usePoints defines if points or triangles must be used
  45865. */
  45866. beginTransformFeedback(usePoints: boolean): void;
  45867. /**
  45868. * Ends a transform feedback operation
  45869. */
  45870. endTransformFeedback(): void;
  45871. /**
  45872. * Specify the varyings to use with transform feedback
  45873. * @param program defines the associated webGL program
  45874. * @param value defines the list of strings representing the varying names
  45875. */
  45876. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45877. /**
  45878. * Bind a webGL buffer for a transform feedback operation
  45879. * @param value defines the webGL buffer to bind
  45880. */
  45881. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45882. }
  45883. }
  45884. declare module BABYLON {
  45885. /**
  45886. * Creation options of the multi render target texture.
  45887. */
  45888. export interface IMultiRenderTargetOptions {
  45889. /**
  45890. * Define if the texture needs to create mip maps after render.
  45891. */
  45892. generateMipMaps?: boolean;
  45893. /**
  45894. * Define the types of all the draw buffers we want to create
  45895. */
  45896. types?: number[];
  45897. /**
  45898. * Define the sampling modes of all the draw buffers we want to create
  45899. */
  45900. samplingModes?: number[];
  45901. /**
  45902. * Define if a depth buffer is required
  45903. */
  45904. generateDepthBuffer?: boolean;
  45905. /**
  45906. * Define if a stencil buffer is required
  45907. */
  45908. generateStencilBuffer?: boolean;
  45909. /**
  45910. * Define if a depth texture is required instead of a depth buffer
  45911. */
  45912. generateDepthTexture?: boolean;
  45913. /**
  45914. * Define the number of desired draw buffers
  45915. */
  45916. textureCount?: number;
  45917. /**
  45918. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45919. */
  45920. doNotChangeAspectRatio?: boolean;
  45921. /**
  45922. * Define the default type of the buffers we are creating
  45923. */
  45924. defaultType?: number;
  45925. }
  45926. /**
  45927. * A multi render target, like a render target provides the ability to render to a texture.
  45928. * Unlike the render target, it can render to several draw buffers in one draw.
  45929. * This is specially interesting in deferred rendering or for any effects requiring more than
  45930. * just one color from a single pass.
  45931. */
  45932. export class MultiRenderTarget extends RenderTargetTexture {
  45933. private _internalTextures;
  45934. private _textures;
  45935. private _multiRenderTargetOptions;
  45936. /**
  45937. * Get if draw buffers are currently supported by the used hardware and browser.
  45938. */
  45939. readonly isSupported: boolean;
  45940. /**
  45941. * Get the list of textures generated by the multi render target.
  45942. */
  45943. readonly textures: Texture[];
  45944. /**
  45945. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45946. */
  45947. readonly depthTexture: Texture;
  45948. /**
  45949. * Set the wrapping mode on U of all the textures we are rendering to.
  45950. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45951. */
  45952. wrapU: number;
  45953. /**
  45954. * Set the wrapping mode on V of all the textures we are rendering to.
  45955. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45956. */
  45957. wrapV: number;
  45958. /**
  45959. * Instantiate a new multi render target texture.
  45960. * A multi render target, like a render target provides the ability to render to a texture.
  45961. * Unlike the render target, it can render to several draw buffers in one draw.
  45962. * This is specially interesting in deferred rendering or for any effects requiring more than
  45963. * just one color from a single pass.
  45964. * @param name Define the name of the texture
  45965. * @param size Define the size of the buffers to render to
  45966. * @param count Define the number of target we are rendering into
  45967. * @param scene Define the scene the texture belongs to
  45968. * @param options Define the options used to create the multi render target
  45969. */
  45970. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45971. /** @hidden */
  45972. _rebuild(): void;
  45973. private _createInternalTextures;
  45974. private _createTextures;
  45975. /**
  45976. * Define the number of samples used if MSAA is enabled.
  45977. */
  45978. samples: number;
  45979. /**
  45980. * Resize all the textures in the multi render target.
  45981. * Be carrefull as it will recreate all the data in the new texture.
  45982. * @param size Define the new size
  45983. */
  45984. resize(size: any): void;
  45985. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45986. /**
  45987. * Dispose the render targets and their associated resources
  45988. */
  45989. dispose(): void;
  45990. /**
  45991. * Release all the underlying texture used as draw buffers.
  45992. */
  45993. releaseInternalTextures(): void;
  45994. }
  45995. }
  45996. declare module BABYLON {
  45997. interface ThinEngine {
  45998. /**
  45999. * Unbind a list of render target textures from the webGL context
  46000. * This is used only when drawBuffer extension or webGL2 are active
  46001. * @param textures defines the render target textures to unbind
  46002. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46003. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46004. */
  46005. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46006. /**
  46007. * Create a multi render target texture
  46008. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46009. * @param size defines the size of the texture
  46010. * @param options defines the creation options
  46011. * @returns the cube texture as an InternalTexture
  46012. */
  46013. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46014. /**
  46015. * Update the sample count for a given multiple render target texture
  46016. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46017. * @param textures defines the textures to update
  46018. * @param samples defines the sample count to set
  46019. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46020. */
  46021. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46022. }
  46023. }
  46024. declare module BABYLON {
  46025. /**
  46026. * Class used to define an additional view for the engine
  46027. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46028. */
  46029. export class EngineView {
  46030. /** Defines the canvas where to render the view */
  46031. target: HTMLCanvasElement;
  46032. /** Defines an optional camera used to render the view (will use active camera else) */
  46033. camera?: Camera;
  46034. }
  46035. interface Engine {
  46036. /**
  46037. * Gets or sets the HTML element to use for attaching events
  46038. */
  46039. inputElement: Nullable<HTMLElement>;
  46040. /**
  46041. * Gets the current engine view
  46042. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46043. */
  46044. activeView: Nullable<EngineView>;
  46045. /** Gets or sets the list of views */
  46046. views: EngineView[];
  46047. /**
  46048. * Register a new child canvas
  46049. * @param canvas defines the canvas to register
  46050. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46051. * @returns the associated view
  46052. */
  46053. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46054. /**
  46055. * Remove a registered child canvas
  46056. * @param canvas defines the canvas to remove
  46057. * @returns the current engine
  46058. */
  46059. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46060. }
  46061. }
  46062. declare module BABYLON {
  46063. /**
  46064. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46065. */
  46066. export interface CubeMapInfo {
  46067. /**
  46068. * The pixel array for the front face.
  46069. * This is stored in format, left to right, up to down format.
  46070. */
  46071. front: Nullable<ArrayBufferView>;
  46072. /**
  46073. * The pixel array for the back face.
  46074. * This is stored in format, left to right, up to down format.
  46075. */
  46076. back: Nullable<ArrayBufferView>;
  46077. /**
  46078. * The pixel array for the left face.
  46079. * This is stored in format, left to right, up to down format.
  46080. */
  46081. left: Nullable<ArrayBufferView>;
  46082. /**
  46083. * The pixel array for the right face.
  46084. * This is stored in format, left to right, up to down format.
  46085. */
  46086. right: Nullable<ArrayBufferView>;
  46087. /**
  46088. * The pixel array for the up face.
  46089. * This is stored in format, left to right, up to down format.
  46090. */
  46091. up: Nullable<ArrayBufferView>;
  46092. /**
  46093. * The pixel array for the down face.
  46094. * This is stored in format, left to right, up to down format.
  46095. */
  46096. down: Nullable<ArrayBufferView>;
  46097. /**
  46098. * The size of the cubemap stored.
  46099. *
  46100. * Each faces will be size * size pixels.
  46101. */
  46102. size: number;
  46103. /**
  46104. * The format of the texture.
  46105. *
  46106. * RGBA, RGB.
  46107. */
  46108. format: number;
  46109. /**
  46110. * The type of the texture data.
  46111. *
  46112. * UNSIGNED_INT, FLOAT.
  46113. */
  46114. type: number;
  46115. /**
  46116. * Specifies whether the texture is in gamma space.
  46117. */
  46118. gammaSpace: boolean;
  46119. }
  46120. /**
  46121. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46122. */
  46123. export class PanoramaToCubeMapTools {
  46124. private static FACE_FRONT;
  46125. private static FACE_BACK;
  46126. private static FACE_RIGHT;
  46127. private static FACE_LEFT;
  46128. private static FACE_DOWN;
  46129. private static FACE_UP;
  46130. /**
  46131. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46132. *
  46133. * @param float32Array The source data.
  46134. * @param inputWidth The width of the input panorama.
  46135. * @param inputHeight The height of the input panorama.
  46136. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46137. * @return The cubemap data
  46138. */
  46139. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46140. private static CreateCubemapTexture;
  46141. private static CalcProjectionSpherical;
  46142. }
  46143. }
  46144. declare module BABYLON {
  46145. /**
  46146. * Helper class dealing with the extraction of spherical polynomial dataArray
  46147. * from a cube map.
  46148. */
  46149. export class CubeMapToSphericalPolynomialTools {
  46150. private static FileFaces;
  46151. /**
  46152. * Converts a texture to the according Spherical Polynomial data.
  46153. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46154. *
  46155. * @param texture The texture to extract the information from.
  46156. * @return The Spherical Polynomial data.
  46157. */
  46158. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46159. /**
  46160. * Converts a cubemap to the according Spherical Polynomial data.
  46161. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46162. *
  46163. * @param cubeInfo The Cube map to extract the information from.
  46164. * @return The Spherical Polynomial data.
  46165. */
  46166. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46167. }
  46168. }
  46169. declare module BABYLON {
  46170. interface BaseTexture {
  46171. /**
  46172. * Get the polynomial representation of the texture data.
  46173. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46174. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46175. */
  46176. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46177. }
  46178. }
  46179. declare module BABYLON {
  46180. /** @hidden */
  46181. export var rgbdEncodePixelShader: {
  46182. name: string;
  46183. shader: string;
  46184. };
  46185. }
  46186. declare module BABYLON {
  46187. /** @hidden */
  46188. export var rgbdDecodePixelShader: {
  46189. name: string;
  46190. shader: string;
  46191. };
  46192. }
  46193. declare module BABYLON {
  46194. /**
  46195. * Raw texture data and descriptor sufficient for WebGL texture upload
  46196. */
  46197. export interface EnvironmentTextureInfo {
  46198. /**
  46199. * Version of the environment map
  46200. */
  46201. version: number;
  46202. /**
  46203. * Width of image
  46204. */
  46205. width: number;
  46206. /**
  46207. * Irradiance information stored in the file.
  46208. */
  46209. irradiance: any;
  46210. /**
  46211. * Specular information stored in the file.
  46212. */
  46213. specular: any;
  46214. }
  46215. /**
  46216. * Defines One Image in the file. It requires only the position in the file
  46217. * as well as the length.
  46218. */
  46219. interface BufferImageData {
  46220. /**
  46221. * Length of the image data.
  46222. */
  46223. length: number;
  46224. /**
  46225. * Position of the data from the null terminator delimiting the end of the JSON.
  46226. */
  46227. position: number;
  46228. }
  46229. /**
  46230. * Defines the specular data enclosed in the file.
  46231. * This corresponds to the version 1 of the data.
  46232. */
  46233. export interface EnvironmentTextureSpecularInfoV1 {
  46234. /**
  46235. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46236. */
  46237. specularDataPosition?: number;
  46238. /**
  46239. * This contains all the images data needed to reconstruct the cubemap.
  46240. */
  46241. mipmaps: Array<BufferImageData>;
  46242. /**
  46243. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46244. */
  46245. lodGenerationScale: number;
  46246. }
  46247. /**
  46248. * Sets of helpers addressing the serialization and deserialization of environment texture
  46249. * stored in a BabylonJS env file.
  46250. * Those files are usually stored as .env files.
  46251. */
  46252. export class EnvironmentTextureTools {
  46253. /**
  46254. * Magic number identifying the env file.
  46255. */
  46256. private static _MagicBytes;
  46257. /**
  46258. * Gets the environment info from an env file.
  46259. * @param data The array buffer containing the .env bytes.
  46260. * @returns the environment file info (the json header) if successfully parsed.
  46261. */
  46262. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46263. /**
  46264. * Creates an environment texture from a loaded cube texture.
  46265. * @param texture defines the cube texture to convert in env file
  46266. * @return a promise containing the environment data if succesfull.
  46267. */
  46268. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46269. /**
  46270. * Creates a JSON representation of the spherical data.
  46271. * @param texture defines the texture containing the polynomials
  46272. * @return the JSON representation of the spherical info
  46273. */
  46274. private static _CreateEnvTextureIrradiance;
  46275. /**
  46276. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46277. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46278. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46279. * @return the views described by info providing access to the underlying buffer
  46280. */
  46281. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46282. /**
  46283. * Uploads the texture info contained in the env file to the GPU.
  46284. * @param texture defines the internal texture to upload to
  46285. * @param arrayBuffer defines the buffer cotaining the data to load
  46286. * @param info defines the texture info retrieved through the GetEnvInfo method
  46287. * @returns a promise
  46288. */
  46289. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46290. private static _OnImageReadyAsync;
  46291. /**
  46292. * Uploads the levels of image data to the GPU.
  46293. * @param texture defines the internal texture to upload to
  46294. * @param imageData defines the array buffer views of image data [mipmap][face]
  46295. * @returns a promise
  46296. */
  46297. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46298. /**
  46299. * Uploads spherical polynomials information to the texture.
  46300. * @param texture defines the texture we are trying to upload the information to
  46301. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46302. */
  46303. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46304. /** @hidden */
  46305. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46306. }
  46307. }
  46308. declare module BABYLON {
  46309. /**
  46310. * Contains position and normal vectors for a vertex
  46311. */
  46312. export class PositionNormalVertex {
  46313. /** the position of the vertex (defaut: 0,0,0) */
  46314. position: Vector3;
  46315. /** the normal of the vertex (defaut: 0,1,0) */
  46316. normal: Vector3;
  46317. /**
  46318. * Creates a PositionNormalVertex
  46319. * @param position the position of the vertex (defaut: 0,0,0)
  46320. * @param normal the normal of the vertex (defaut: 0,1,0)
  46321. */
  46322. constructor(
  46323. /** the position of the vertex (defaut: 0,0,0) */
  46324. position?: Vector3,
  46325. /** the normal of the vertex (defaut: 0,1,0) */
  46326. normal?: Vector3);
  46327. /**
  46328. * Clones the PositionNormalVertex
  46329. * @returns the cloned PositionNormalVertex
  46330. */
  46331. clone(): PositionNormalVertex;
  46332. }
  46333. /**
  46334. * Contains position, normal and uv vectors for a vertex
  46335. */
  46336. export class PositionNormalTextureVertex {
  46337. /** the position of the vertex (defaut: 0,0,0) */
  46338. position: Vector3;
  46339. /** the normal of the vertex (defaut: 0,1,0) */
  46340. normal: Vector3;
  46341. /** the uv of the vertex (default: 0,0) */
  46342. uv: Vector2;
  46343. /**
  46344. * Creates a PositionNormalTextureVertex
  46345. * @param position the position of the vertex (defaut: 0,0,0)
  46346. * @param normal the normal of the vertex (defaut: 0,1,0)
  46347. * @param uv the uv of the vertex (default: 0,0)
  46348. */
  46349. constructor(
  46350. /** the position of the vertex (defaut: 0,0,0) */
  46351. position?: Vector3,
  46352. /** the normal of the vertex (defaut: 0,1,0) */
  46353. normal?: Vector3,
  46354. /** the uv of the vertex (default: 0,0) */
  46355. uv?: Vector2);
  46356. /**
  46357. * Clones the PositionNormalTextureVertex
  46358. * @returns the cloned PositionNormalTextureVertex
  46359. */
  46360. clone(): PositionNormalTextureVertex;
  46361. }
  46362. }
  46363. declare module BABYLON {
  46364. /** @hidden */
  46365. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46366. private _genericAttributeLocation;
  46367. private _varyingLocationCount;
  46368. private _varyingLocationMap;
  46369. private _replacements;
  46370. private _textureCount;
  46371. private _uniforms;
  46372. lineProcessor(line: string): string;
  46373. attributeProcessor(attribute: string): string;
  46374. varyingProcessor(varying: string, isFragment: boolean): string;
  46375. uniformProcessor(uniform: string): string;
  46376. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46377. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46378. }
  46379. }
  46380. declare module BABYLON {
  46381. /**
  46382. * Container for accessors for natively-stored mesh data buffers.
  46383. */
  46384. class NativeDataBuffer extends DataBuffer {
  46385. /**
  46386. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46387. */
  46388. nativeIndexBuffer?: any;
  46389. /**
  46390. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46391. */
  46392. nativeVertexBuffer?: any;
  46393. }
  46394. /** @hidden */
  46395. class NativeTexture extends InternalTexture {
  46396. getInternalTexture(): InternalTexture;
  46397. getViewCount(): number;
  46398. }
  46399. /** @hidden */
  46400. export class NativeEngine extends Engine {
  46401. private readonly _native;
  46402. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  46403. private readonly INVALID_HANDLE;
  46404. getHardwareScalingLevel(): number;
  46405. constructor();
  46406. /**
  46407. * Can be used to override the current requestAnimationFrame requester.
  46408. * @hidden
  46409. */
  46410. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46411. /**
  46412. * Override default engine behavior.
  46413. * @param color
  46414. * @param backBuffer
  46415. * @param depth
  46416. * @param stencil
  46417. */
  46418. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46419. /**
  46420. * Gets host document
  46421. * @returns the host document object
  46422. */
  46423. getHostDocument(): Nullable<Document>;
  46424. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46425. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46426. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46427. recordVertexArrayObject(vertexBuffers: {
  46428. [key: string]: VertexBuffer;
  46429. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46430. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46431. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46432. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46433. /**
  46434. * Draw a list of indexed primitives
  46435. * @param fillMode defines the primitive to use
  46436. * @param indexStart defines the starting index
  46437. * @param indexCount defines the number of index to draw
  46438. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46439. */
  46440. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46441. /**
  46442. * Draw a list of unindexed primitives
  46443. * @param fillMode defines the primitive to use
  46444. * @param verticesStart defines the index of first vertex to draw
  46445. * @param verticesCount defines the count of vertices to draw
  46446. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46447. */
  46448. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46449. createPipelineContext(): IPipelineContext;
  46450. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46451. /** @hidden */
  46452. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46453. /** @hidden */
  46454. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46455. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46456. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46457. protected _setProgram(program: WebGLProgram): void;
  46458. _releaseEffect(effect: Effect): void;
  46459. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46460. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46461. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46462. bindSamplers(effect: Effect): void;
  46463. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46464. getRenderWidth(useScreen?: boolean): number;
  46465. getRenderHeight(useScreen?: boolean): number;
  46466. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46467. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46468. /**
  46469. * Set the z offset to apply to current rendering
  46470. * @param value defines the offset to apply
  46471. */
  46472. setZOffset(value: number): void;
  46473. /**
  46474. * Gets the current value of the zOffset
  46475. * @returns the current zOffset state
  46476. */
  46477. getZOffset(): number;
  46478. /**
  46479. * Enable or disable depth buffering
  46480. * @param enable defines the state to set
  46481. */
  46482. setDepthBuffer(enable: boolean): void;
  46483. /**
  46484. * Gets a boolean indicating if depth writing is enabled
  46485. * @returns the current depth writing state
  46486. */
  46487. getDepthWrite(): boolean;
  46488. /**
  46489. * Enable or disable depth writing
  46490. * @param enable defines the state to set
  46491. */
  46492. setDepthWrite(enable: boolean): void;
  46493. /**
  46494. * Enable or disable color writing
  46495. * @param enable defines the state to set
  46496. */
  46497. setColorWrite(enable: boolean): void;
  46498. /**
  46499. * Gets a boolean indicating if color writing is enabled
  46500. * @returns the current color writing state
  46501. */
  46502. getColorWrite(): boolean;
  46503. /**
  46504. * Sets alpha constants used by some alpha blending modes
  46505. * @param r defines the red component
  46506. * @param g defines the green component
  46507. * @param b defines the blue component
  46508. * @param a defines the alpha component
  46509. */
  46510. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46511. /**
  46512. * Sets the current alpha mode
  46513. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46514. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46515. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46516. */
  46517. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46518. /**
  46519. * Gets the current alpha mode
  46520. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46521. * @returns the current alpha mode
  46522. */
  46523. getAlphaMode(): number;
  46524. setInt(uniform: WebGLUniformLocation, int: number): void;
  46525. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46526. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46527. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46528. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46529. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46530. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46531. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46532. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46533. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46534. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46535. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46536. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46537. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46538. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46539. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46540. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46541. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46542. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46543. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46544. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46545. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46546. wipeCaches(bruteForce?: boolean): void;
  46547. _createTexture(): WebGLTexture;
  46548. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46549. /**
  46550. * Usually called from BABYLON.Texture.ts.
  46551. * Passed information to create a WebGLTexture
  46552. * @param urlArg defines a value which contains one of the following:
  46553. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46554. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46555. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46556. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46557. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46558. * @param scene needed for loading to the correct scene
  46559. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46560. * @param onLoad optional callback to be called upon successful completion
  46561. * @param onError optional callback to be called upon failure
  46562. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46563. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46564. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46565. * @param forcedExtension defines the extension to use to pick the right loader
  46566. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46567. */
  46568. 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;
  46569. /**
  46570. * Creates a cube texture
  46571. * @param rootUrl defines the url where the files to load is located
  46572. * @param scene defines the current scene
  46573. * @param files defines the list of files to load (1 per face)
  46574. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46575. * @param onLoad defines an optional callback raised when the texture is loaded
  46576. * @param onError defines an optional callback raised if there is an issue to load the texture
  46577. * @param format defines the format of the data
  46578. * @param forcedExtension defines the extension to use to pick the right loader
  46579. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46580. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46581. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46582. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46583. * @returns the cube texture as an InternalTexture
  46584. */
  46585. 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;
  46586. private _getSamplingFilter;
  46587. private static _GetNativeTextureFormat;
  46588. createRenderTargetTexture(size: number | {
  46589. width: number;
  46590. height: number;
  46591. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  46592. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46593. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46594. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46595. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46596. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46597. /**
  46598. * Updates a dynamic vertex buffer.
  46599. * @param vertexBuffer the vertex buffer to update
  46600. * @param data the data used to update the vertex buffer
  46601. * @param byteOffset the byte offset of the data (optional)
  46602. * @param byteLength the byte length of the data (optional)
  46603. */
  46604. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46605. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46606. private _updateAnisotropicLevel;
  46607. private _getAddressMode;
  46608. /** @hidden */
  46609. _bindTexture(channel: number, texture: InternalTexture): void;
  46610. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46611. releaseEffects(): void;
  46612. /** @hidden */
  46613. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46614. /** @hidden */
  46615. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46616. /** @hidden */
  46617. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46618. /** @hidden */
  46619. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46620. }
  46621. }
  46622. declare module BABYLON {
  46623. /**
  46624. * Gather the list of clipboard event types as constants.
  46625. */
  46626. export class ClipboardEventTypes {
  46627. /**
  46628. * The clipboard event is fired when a copy command is active (pressed).
  46629. */
  46630. static readonly COPY: number;
  46631. /**
  46632. * The clipboard event is fired when a cut command is active (pressed).
  46633. */
  46634. static readonly CUT: number;
  46635. /**
  46636. * The clipboard event is fired when a paste command is active (pressed).
  46637. */
  46638. static readonly PASTE: number;
  46639. }
  46640. /**
  46641. * This class is used to store clipboard related info for the onClipboardObservable event.
  46642. */
  46643. export class ClipboardInfo {
  46644. /**
  46645. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46646. */
  46647. type: number;
  46648. /**
  46649. * Defines the related dom event
  46650. */
  46651. event: ClipboardEvent;
  46652. /**
  46653. *Creates an instance of ClipboardInfo.
  46654. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46655. * @param event Defines the related dom event
  46656. */
  46657. constructor(
  46658. /**
  46659. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46660. */
  46661. type: number,
  46662. /**
  46663. * Defines the related dom event
  46664. */
  46665. event: ClipboardEvent);
  46666. /**
  46667. * Get the clipboard event's type from the keycode.
  46668. * @param keyCode Defines the keyCode for the current keyboard event.
  46669. * @return {number}
  46670. */
  46671. static GetTypeFromCharacter(keyCode: number): number;
  46672. }
  46673. }
  46674. declare module BABYLON {
  46675. /**
  46676. * Google Daydream controller
  46677. */
  46678. export class DaydreamController extends WebVRController {
  46679. /**
  46680. * Base Url for the controller model.
  46681. */
  46682. static MODEL_BASE_URL: string;
  46683. /**
  46684. * File name for the controller model.
  46685. */
  46686. static MODEL_FILENAME: string;
  46687. /**
  46688. * Gamepad Id prefix used to identify Daydream Controller.
  46689. */
  46690. static readonly GAMEPAD_ID_PREFIX: string;
  46691. /**
  46692. * Creates a new DaydreamController from a gamepad
  46693. * @param vrGamepad the gamepad that the controller should be created from
  46694. */
  46695. constructor(vrGamepad: any);
  46696. /**
  46697. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46698. * @param scene scene in which to add meshes
  46699. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46700. */
  46701. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46702. /**
  46703. * Called once for each button that changed state since the last frame
  46704. * @param buttonIdx Which button index changed
  46705. * @param state New state of the button
  46706. * @param changes Which properties on the state changed since last frame
  46707. */
  46708. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46709. }
  46710. }
  46711. declare module BABYLON {
  46712. /**
  46713. * Gear VR Controller
  46714. */
  46715. export class GearVRController extends WebVRController {
  46716. /**
  46717. * Base Url for the controller model.
  46718. */
  46719. static MODEL_BASE_URL: string;
  46720. /**
  46721. * File name for the controller model.
  46722. */
  46723. static MODEL_FILENAME: string;
  46724. /**
  46725. * Gamepad Id prefix used to identify this controller.
  46726. */
  46727. static readonly GAMEPAD_ID_PREFIX: string;
  46728. private readonly _buttonIndexToObservableNameMap;
  46729. /**
  46730. * Creates a new GearVRController from a gamepad
  46731. * @param vrGamepad the gamepad that the controller should be created from
  46732. */
  46733. constructor(vrGamepad: any);
  46734. /**
  46735. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46736. * @param scene scene in which to add meshes
  46737. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46738. */
  46739. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46740. /**
  46741. * Called once for each button that changed state since the last frame
  46742. * @param buttonIdx Which button index changed
  46743. * @param state New state of the button
  46744. * @param changes Which properties on the state changed since last frame
  46745. */
  46746. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46747. }
  46748. }
  46749. declare module BABYLON {
  46750. /**
  46751. * Class containing static functions to help procedurally build meshes
  46752. */
  46753. export class PolyhedronBuilder {
  46754. /**
  46755. * Creates a polyhedron mesh
  46756. * * 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
  46757. * * The parameter `size` (positive float, default 1) sets the polygon size
  46758. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46759. * * 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`
  46760. * * 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
  46761. * * 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)`)
  46762. * * 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
  46763. * * 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
  46764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46765. * * 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
  46766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46767. * @param name defines the name of the mesh
  46768. * @param options defines the options used to create the mesh
  46769. * @param scene defines the hosting scene
  46770. * @returns the polyhedron mesh
  46771. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46772. */
  46773. static CreatePolyhedron(name: string, options: {
  46774. type?: number;
  46775. size?: number;
  46776. sizeX?: number;
  46777. sizeY?: number;
  46778. sizeZ?: number;
  46779. custom?: any;
  46780. faceUV?: Vector4[];
  46781. faceColors?: Color4[];
  46782. flat?: boolean;
  46783. updatable?: boolean;
  46784. sideOrientation?: number;
  46785. frontUVs?: Vector4;
  46786. backUVs?: Vector4;
  46787. }, scene?: Nullable<Scene>): Mesh;
  46788. }
  46789. }
  46790. declare module BABYLON {
  46791. /**
  46792. * Gizmo that enables scaling a mesh along 3 axis
  46793. */
  46794. export class ScaleGizmo extends Gizmo {
  46795. /**
  46796. * Internal gizmo used for interactions on the x axis
  46797. */
  46798. xGizmo: AxisScaleGizmo;
  46799. /**
  46800. * Internal gizmo used for interactions on the y axis
  46801. */
  46802. yGizmo: AxisScaleGizmo;
  46803. /**
  46804. * Internal gizmo used for interactions on the z axis
  46805. */
  46806. zGizmo: AxisScaleGizmo;
  46807. /**
  46808. * Internal gizmo used to scale all axis equally
  46809. */
  46810. uniformScaleGizmo: AxisScaleGizmo;
  46811. private _meshAttached;
  46812. private _updateGizmoRotationToMatchAttachedMesh;
  46813. private _snapDistance;
  46814. private _scaleRatio;
  46815. private _uniformScalingMesh;
  46816. private _octahedron;
  46817. private _sensitivity;
  46818. /** Fires an event when any of it's sub gizmos are dragged */
  46819. onDragStartObservable: Observable<unknown>;
  46820. /** Fires an event when any of it's sub gizmos are released from dragging */
  46821. onDragEndObservable: Observable<unknown>;
  46822. attachedMesh: Nullable<AbstractMesh>;
  46823. /**
  46824. * Creates a ScaleGizmo
  46825. * @param gizmoLayer The utility layer the gizmo will be added to
  46826. */
  46827. constructor(gizmoLayer?: UtilityLayerRenderer);
  46828. updateGizmoRotationToMatchAttachedMesh: boolean;
  46829. /**
  46830. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46831. */
  46832. snapDistance: number;
  46833. /**
  46834. * Ratio for the scale of the gizmo (Default: 1)
  46835. */
  46836. scaleRatio: number;
  46837. /**
  46838. * Sensitivity factor for dragging (Default: 1)
  46839. */
  46840. sensitivity: number;
  46841. /**
  46842. * Disposes of the gizmo
  46843. */
  46844. dispose(): void;
  46845. }
  46846. }
  46847. declare module BABYLON {
  46848. /**
  46849. * Single axis scale gizmo
  46850. */
  46851. export class AxisScaleGizmo extends Gizmo {
  46852. /**
  46853. * Drag behavior responsible for the gizmos dragging interactions
  46854. */
  46855. dragBehavior: PointerDragBehavior;
  46856. private _pointerObserver;
  46857. /**
  46858. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46859. */
  46860. snapDistance: number;
  46861. /**
  46862. * Event that fires each time the gizmo snaps to a new location.
  46863. * * snapDistance is the the change in distance
  46864. */
  46865. onSnapObservable: Observable<{
  46866. snapDistance: number;
  46867. }>;
  46868. /**
  46869. * If the scaling operation should be done on all axis (default: false)
  46870. */
  46871. uniformScaling: boolean;
  46872. /**
  46873. * Custom sensitivity value for the drag strength
  46874. */
  46875. sensitivity: number;
  46876. private _isEnabled;
  46877. private _parent;
  46878. private _arrow;
  46879. private _coloredMaterial;
  46880. private _hoverMaterial;
  46881. /**
  46882. * Creates an AxisScaleGizmo
  46883. * @param gizmoLayer The utility layer the gizmo will be added to
  46884. * @param dragAxis The axis which the gizmo will be able to scale on
  46885. * @param color The color of the gizmo
  46886. */
  46887. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46888. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46889. /**
  46890. * If the gizmo is enabled
  46891. */
  46892. isEnabled: boolean;
  46893. /**
  46894. * Disposes of the gizmo
  46895. */
  46896. dispose(): void;
  46897. /**
  46898. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46899. * @param mesh The mesh to replace the default mesh of the gizmo
  46900. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46901. */
  46902. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46903. }
  46904. }
  46905. declare module BABYLON {
  46906. /**
  46907. * Bounding box gizmo
  46908. */
  46909. export class BoundingBoxGizmo extends Gizmo {
  46910. private _lineBoundingBox;
  46911. private _rotateSpheresParent;
  46912. private _scaleBoxesParent;
  46913. private _boundingDimensions;
  46914. private _renderObserver;
  46915. private _pointerObserver;
  46916. private _scaleDragSpeed;
  46917. private _tmpQuaternion;
  46918. private _tmpVector;
  46919. private _tmpRotationMatrix;
  46920. /**
  46921. * 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)
  46922. */
  46923. ignoreChildren: boolean;
  46924. /**
  46925. * 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)
  46926. */
  46927. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46928. /**
  46929. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46930. */
  46931. rotationSphereSize: number;
  46932. /**
  46933. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46934. */
  46935. scaleBoxSize: number;
  46936. /**
  46937. * 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)
  46938. */
  46939. fixedDragMeshScreenSize: boolean;
  46940. /**
  46941. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46942. */
  46943. fixedDragMeshScreenSizeDistanceFactor: number;
  46944. /**
  46945. * Fired when a rotation sphere or scale box is dragged
  46946. */
  46947. onDragStartObservable: Observable<{}>;
  46948. /**
  46949. * Fired when a scale box is dragged
  46950. */
  46951. onScaleBoxDragObservable: Observable<{}>;
  46952. /**
  46953. * Fired when a scale box drag is ended
  46954. */
  46955. onScaleBoxDragEndObservable: Observable<{}>;
  46956. /**
  46957. * Fired when a rotation sphere is dragged
  46958. */
  46959. onRotationSphereDragObservable: Observable<{}>;
  46960. /**
  46961. * Fired when a rotation sphere drag is ended
  46962. */
  46963. onRotationSphereDragEndObservable: Observable<{}>;
  46964. /**
  46965. * 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)
  46966. */
  46967. scalePivot: Nullable<Vector3>;
  46968. /**
  46969. * Mesh used as a pivot to rotate the attached mesh
  46970. */
  46971. private _anchorMesh;
  46972. private _existingMeshScale;
  46973. private _dragMesh;
  46974. private pointerDragBehavior;
  46975. private coloredMaterial;
  46976. private hoverColoredMaterial;
  46977. /**
  46978. * Sets the color of the bounding box gizmo
  46979. * @param color the color to set
  46980. */
  46981. setColor(color: Color3): void;
  46982. /**
  46983. * Creates an BoundingBoxGizmo
  46984. * @param gizmoLayer The utility layer the gizmo will be added to
  46985. * @param color The color of the gizmo
  46986. */
  46987. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46988. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46989. private _selectNode;
  46990. /**
  46991. * Updates the bounding box information for the Gizmo
  46992. */
  46993. updateBoundingBox(): void;
  46994. private _updateRotationSpheres;
  46995. private _updateScaleBoxes;
  46996. /**
  46997. * Enables rotation on the specified axis and disables rotation on the others
  46998. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46999. */
  47000. setEnabledRotationAxis(axis: string): void;
  47001. /**
  47002. * Enables/disables scaling
  47003. * @param enable if scaling should be enabled
  47004. */
  47005. setEnabledScaling(enable: boolean): void;
  47006. private _updateDummy;
  47007. /**
  47008. * Enables a pointer drag behavior on the bounding box of the gizmo
  47009. */
  47010. enableDragBehavior(): void;
  47011. /**
  47012. * Disposes of the gizmo
  47013. */
  47014. dispose(): void;
  47015. /**
  47016. * 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)
  47017. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47018. * @returns the bounding box mesh with the passed in mesh as a child
  47019. */
  47020. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47021. /**
  47022. * CustomMeshes are not supported by this gizmo
  47023. * @param mesh The mesh to replace the default mesh of the gizmo
  47024. */
  47025. setCustomMesh(mesh: Mesh): void;
  47026. }
  47027. }
  47028. declare module BABYLON {
  47029. /**
  47030. * Single plane rotation gizmo
  47031. */
  47032. export class PlaneRotationGizmo extends Gizmo {
  47033. /**
  47034. * Drag behavior responsible for the gizmos dragging interactions
  47035. */
  47036. dragBehavior: PointerDragBehavior;
  47037. private _pointerObserver;
  47038. /**
  47039. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47040. */
  47041. snapDistance: number;
  47042. /**
  47043. * Event that fires each time the gizmo snaps to a new location.
  47044. * * snapDistance is the the change in distance
  47045. */
  47046. onSnapObservable: Observable<{
  47047. snapDistance: number;
  47048. }>;
  47049. private _isEnabled;
  47050. private _parent;
  47051. /**
  47052. * Creates a PlaneRotationGizmo
  47053. * @param gizmoLayer The utility layer the gizmo will be added to
  47054. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47055. * @param color The color of the gizmo
  47056. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47057. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47058. */
  47059. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47060. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47061. /**
  47062. * If the gizmo is enabled
  47063. */
  47064. isEnabled: boolean;
  47065. /**
  47066. * Disposes of the gizmo
  47067. */
  47068. dispose(): void;
  47069. }
  47070. }
  47071. declare module BABYLON {
  47072. /**
  47073. * Gizmo that enables rotating a mesh along 3 axis
  47074. */
  47075. export class RotationGizmo extends Gizmo {
  47076. /**
  47077. * Internal gizmo used for interactions on the x axis
  47078. */
  47079. xGizmo: PlaneRotationGizmo;
  47080. /**
  47081. * Internal gizmo used for interactions on the y axis
  47082. */
  47083. yGizmo: PlaneRotationGizmo;
  47084. /**
  47085. * Internal gizmo used for interactions on the z axis
  47086. */
  47087. zGizmo: PlaneRotationGizmo;
  47088. /** Fires an event when any of it's sub gizmos are dragged */
  47089. onDragStartObservable: Observable<unknown>;
  47090. /** Fires an event when any of it's sub gizmos are released from dragging */
  47091. onDragEndObservable: Observable<unknown>;
  47092. private _meshAttached;
  47093. attachedMesh: Nullable<AbstractMesh>;
  47094. /**
  47095. * Creates a RotationGizmo
  47096. * @param gizmoLayer The utility layer the gizmo will be added to
  47097. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47098. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47099. */
  47100. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47101. updateGizmoRotationToMatchAttachedMesh: boolean;
  47102. /**
  47103. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47104. */
  47105. snapDistance: number;
  47106. /**
  47107. * Ratio for the scale of the gizmo (Default: 1)
  47108. */
  47109. scaleRatio: number;
  47110. /**
  47111. * Disposes of the gizmo
  47112. */
  47113. dispose(): void;
  47114. /**
  47115. * CustomMeshes are not supported by this gizmo
  47116. * @param mesh The mesh to replace the default mesh of the gizmo
  47117. */
  47118. setCustomMesh(mesh: Mesh): void;
  47119. }
  47120. }
  47121. declare module BABYLON {
  47122. /**
  47123. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47124. */
  47125. export class GizmoManager implements IDisposable {
  47126. private scene;
  47127. /**
  47128. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47129. */
  47130. gizmos: {
  47131. positionGizmo: Nullable<PositionGizmo>;
  47132. rotationGizmo: Nullable<RotationGizmo>;
  47133. scaleGizmo: Nullable<ScaleGizmo>;
  47134. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47135. };
  47136. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47137. clearGizmoOnEmptyPointerEvent: boolean;
  47138. /** Fires an event when the manager is attached to a mesh */
  47139. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47140. private _gizmosEnabled;
  47141. private _pointerObserver;
  47142. private _attachedMesh;
  47143. private _boundingBoxColor;
  47144. private _defaultUtilityLayer;
  47145. private _defaultKeepDepthUtilityLayer;
  47146. /**
  47147. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47148. */
  47149. boundingBoxDragBehavior: SixDofDragBehavior;
  47150. /**
  47151. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47152. */
  47153. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47154. /**
  47155. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47156. */
  47157. usePointerToAttachGizmos: boolean;
  47158. /**
  47159. * Utility layer that the bounding box gizmo belongs to
  47160. */
  47161. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47162. /**
  47163. * Utility layer that all gizmos besides bounding box belong to
  47164. */
  47165. readonly utilityLayer: UtilityLayerRenderer;
  47166. /**
  47167. * Instatiates a gizmo manager
  47168. * @param scene the scene to overlay the gizmos on top of
  47169. */
  47170. constructor(scene: Scene);
  47171. /**
  47172. * Attaches a set of gizmos to the specified mesh
  47173. * @param mesh The mesh the gizmo's should be attached to
  47174. */
  47175. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47176. /**
  47177. * If the position gizmo is enabled
  47178. */
  47179. positionGizmoEnabled: boolean;
  47180. /**
  47181. * If the rotation gizmo is enabled
  47182. */
  47183. rotationGizmoEnabled: boolean;
  47184. /**
  47185. * If the scale gizmo is enabled
  47186. */
  47187. scaleGizmoEnabled: boolean;
  47188. /**
  47189. * If the boundingBox gizmo is enabled
  47190. */
  47191. boundingBoxGizmoEnabled: boolean;
  47192. /**
  47193. * Disposes of the gizmo manager
  47194. */
  47195. dispose(): void;
  47196. }
  47197. }
  47198. declare module BABYLON {
  47199. /**
  47200. * A directional light is defined by a direction (what a surprise!).
  47201. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47202. * 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.
  47203. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47204. */
  47205. export class DirectionalLight extends ShadowLight {
  47206. private _shadowFrustumSize;
  47207. /**
  47208. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47209. */
  47210. /**
  47211. * Specifies a fix frustum size for the shadow generation.
  47212. */
  47213. shadowFrustumSize: number;
  47214. private _shadowOrthoScale;
  47215. /**
  47216. * Gets the shadow projection scale against the optimal computed one.
  47217. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47218. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47219. */
  47220. /**
  47221. * Sets the shadow projection scale against the optimal computed one.
  47222. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47223. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47224. */
  47225. shadowOrthoScale: number;
  47226. /**
  47227. * Automatically compute the projection matrix to best fit (including all the casters)
  47228. * on each frame.
  47229. */
  47230. autoUpdateExtends: boolean;
  47231. private _orthoLeft;
  47232. private _orthoRight;
  47233. private _orthoTop;
  47234. private _orthoBottom;
  47235. /**
  47236. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47237. * The directional light is emitted from everywhere in the given direction.
  47238. * It can cast shadows.
  47239. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47240. * @param name The friendly name of the light
  47241. * @param direction The direction of the light
  47242. * @param scene The scene the light belongs to
  47243. */
  47244. constructor(name: string, direction: Vector3, scene: Scene);
  47245. /**
  47246. * Returns the string "DirectionalLight".
  47247. * @return The class name
  47248. */
  47249. getClassName(): string;
  47250. /**
  47251. * Returns the integer 1.
  47252. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47253. */
  47254. getTypeID(): number;
  47255. /**
  47256. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47257. * Returns the DirectionalLight Shadow projection matrix.
  47258. */
  47259. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47260. /**
  47261. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47262. * Returns the DirectionalLight Shadow projection matrix.
  47263. */
  47264. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47265. /**
  47266. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47267. * Returns the DirectionalLight Shadow projection matrix.
  47268. */
  47269. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47270. protected _buildUniformLayout(): void;
  47271. /**
  47272. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47273. * @param effect The effect to update
  47274. * @param lightIndex The index of the light in the effect to update
  47275. * @returns The directional light
  47276. */
  47277. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47278. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47279. /**
  47280. * Gets the minZ used for shadow according to both the scene and the light.
  47281. *
  47282. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47283. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47284. * @param activeCamera The camera we are returning the min for
  47285. * @returns the depth min z
  47286. */
  47287. getDepthMinZ(activeCamera: Camera): number;
  47288. /**
  47289. * Gets the maxZ used for shadow according to both the scene and the light.
  47290. *
  47291. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47292. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47293. * @param activeCamera The camera we are returning the max for
  47294. * @returns the depth max z
  47295. */
  47296. getDepthMaxZ(activeCamera: Camera): number;
  47297. /**
  47298. * Prepares the list of defines specific to the light type.
  47299. * @param defines the list of defines
  47300. * @param lightIndex defines the index of the light for the effect
  47301. */
  47302. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47303. }
  47304. }
  47305. declare module BABYLON {
  47306. /**
  47307. * Class containing static functions to help procedurally build meshes
  47308. */
  47309. export class HemisphereBuilder {
  47310. /**
  47311. * Creates a hemisphere mesh
  47312. * @param name defines the name of the mesh
  47313. * @param options defines the options used to create the mesh
  47314. * @param scene defines the hosting scene
  47315. * @returns the hemisphere mesh
  47316. */
  47317. static CreateHemisphere(name: string, options: {
  47318. segments?: number;
  47319. diameter?: number;
  47320. sideOrientation?: number;
  47321. }, scene: any): Mesh;
  47322. }
  47323. }
  47324. declare module BABYLON {
  47325. /**
  47326. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47327. * These values define a cone of light starting from the position, emitting toward the direction.
  47328. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47329. * and the exponent defines the speed of the decay of the light with distance (reach).
  47330. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47331. */
  47332. export class SpotLight extends ShadowLight {
  47333. private _angle;
  47334. private _innerAngle;
  47335. private _cosHalfAngle;
  47336. private _lightAngleScale;
  47337. private _lightAngleOffset;
  47338. /**
  47339. * Gets the cone angle of the spot light in Radians.
  47340. */
  47341. /**
  47342. * Sets the cone angle of the spot light in Radians.
  47343. */
  47344. angle: number;
  47345. /**
  47346. * Only used in gltf falloff mode, this defines the angle where
  47347. * the directional falloff will start before cutting at angle which could be seen
  47348. * as outer angle.
  47349. */
  47350. /**
  47351. * Only used in gltf falloff mode, this defines the angle where
  47352. * the directional falloff will start before cutting at angle which could be seen
  47353. * as outer angle.
  47354. */
  47355. innerAngle: number;
  47356. private _shadowAngleScale;
  47357. /**
  47358. * Allows scaling the angle of the light for shadow generation only.
  47359. */
  47360. /**
  47361. * Allows scaling the angle of the light for shadow generation only.
  47362. */
  47363. shadowAngleScale: number;
  47364. /**
  47365. * The light decay speed with the distance from the emission spot.
  47366. */
  47367. exponent: number;
  47368. private _projectionTextureMatrix;
  47369. /**
  47370. * Allows reading the projecton texture
  47371. */
  47372. readonly projectionTextureMatrix: Matrix;
  47373. protected _projectionTextureLightNear: number;
  47374. /**
  47375. * Gets the near clip of the Spotlight for texture projection.
  47376. */
  47377. /**
  47378. * Sets the near clip of the Spotlight for texture projection.
  47379. */
  47380. projectionTextureLightNear: number;
  47381. protected _projectionTextureLightFar: number;
  47382. /**
  47383. * Gets the far clip of the Spotlight for texture projection.
  47384. */
  47385. /**
  47386. * Sets the far clip of the Spotlight for texture projection.
  47387. */
  47388. projectionTextureLightFar: number;
  47389. protected _projectionTextureUpDirection: Vector3;
  47390. /**
  47391. * Gets the Up vector of the Spotlight for texture projection.
  47392. */
  47393. /**
  47394. * Sets the Up vector of the Spotlight for texture projection.
  47395. */
  47396. projectionTextureUpDirection: Vector3;
  47397. private _projectionTexture;
  47398. /**
  47399. * Gets the projection texture of the light.
  47400. */
  47401. /**
  47402. * Sets the projection texture of the light.
  47403. */
  47404. projectionTexture: Nullable<BaseTexture>;
  47405. private _projectionTextureViewLightDirty;
  47406. private _projectionTextureProjectionLightDirty;
  47407. private _projectionTextureDirty;
  47408. private _projectionTextureViewTargetVector;
  47409. private _projectionTextureViewLightMatrix;
  47410. private _projectionTextureProjectionLightMatrix;
  47411. private _projectionTextureScalingMatrix;
  47412. /**
  47413. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47414. * It can cast shadows.
  47415. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47416. * @param name The light friendly name
  47417. * @param position The position of the spot light in the scene
  47418. * @param direction The direction of the light in the scene
  47419. * @param angle The cone angle of the light in Radians
  47420. * @param exponent The light decay speed with the distance from the emission spot
  47421. * @param scene The scene the lights belongs to
  47422. */
  47423. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47424. /**
  47425. * Returns the string "SpotLight".
  47426. * @returns the class name
  47427. */
  47428. getClassName(): string;
  47429. /**
  47430. * Returns the integer 2.
  47431. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47432. */
  47433. getTypeID(): number;
  47434. /**
  47435. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47436. */
  47437. protected _setDirection(value: Vector3): void;
  47438. /**
  47439. * Overrides the position setter to recompute the projection texture view light Matrix.
  47440. */
  47441. protected _setPosition(value: Vector3): void;
  47442. /**
  47443. * 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.
  47444. * Returns the SpotLight.
  47445. */
  47446. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47447. protected _computeProjectionTextureViewLightMatrix(): void;
  47448. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47449. /**
  47450. * Main function for light texture projection matrix computing.
  47451. */
  47452. protected _computeProjectionTextureMatrix(): void;
  47453. protected _buildUniformLayout(): void;
  47454. private _computeAngleValues;
  47455. /**
  47456. * Sets the passed Effect "effect" with the Light textures.
  47457. * @param effect The effect to update
  47458. * @param lightIndex The index of the light in the effect to update
  47459. * @returns The light
  47460. */
  47461. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  47462. /**
  47463. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47464. * @param effect The effect to update
  47465. * @param lightIndex The index of the light in the effect to update
  47466. * @returns The spot light
  47467. */
  47468. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47469. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47470. /**
  47471. * Disposes the light and the associated resources.
  47472. */
  47473. dispose(): void;
  47474. /**
  47475. * Prepares the list of defines specific to the light type.
  47476. * @param defines the list of defines
  47477. * @param lightIndex defines the index of the light for the effect
  47478. */
  47479. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47480. }
  47481. }
  47482. declare module BABYLON {
  47483. /**
  47484. * Gizmo that enables viewing a light
  47485. */
  47486. export class LightGizmo extends Gizmo {
  47487. private _lightMesh;
  47488. private _material;
  47489. private _cachedPosition;
  47490. private _cachedForward;
  47491. private _attachedMeshParent;
  47492. /**
  47493. * Creates a LightGizmo
  47494. * @param gizmoLayer The utility layer the gizmo will be added to
  47495. */
  47496. constructor(gizmoLayer?: UtilityLayerRenderer);
  47497. private _light;
  47498. /**
  47499. * The light that the gizmo is attached to
  47500. */
  47501. light: Nullable<Light>;
  47502. /**
  47503. * Gets the material used to render the light gizmo
  47504. */
  47505. readonly material: StandardMaterial;
  47506. /**
  47507. * @hidden
  47508. * Updates the gizmo to match the attached mesh's position/rotation
  47509. */
  47510. protected _update(): void;
  47511. private static _Scale;
  47512. /**
  47513. * Creates the lines for a light mesh
  47514. */
  47515. private static _CreateLightLines;
  47516. /**
  47517. * Disposes of the light gizmo
  47518. */
  47519. dispose(): void;
  47520. private static _CreateHemisphericLightMesh;
  47521. private static _CreatePointLightMesh;
  47522. private static _CreateSpotLightMesh;
  47523. private static _CreateDirectionalLightMesh;
  47524. }
  47525. }
  47526. declare module BABYLON {
  47527. /** @hidden */
  47528. export var backgroundFragmentDeclaration: {
  47529. name: string;
  47530. shader: string;
  47531. };
  47532. }
  47533. declare module BABYLON {
  47534. /** @hidden */
  47535. export var backgroundUboDeclaration: {
  47536. name: string;
  47537. shader: string;
  47538. };
  47539. }
  47540. declare module BABYLON {
  47541. /** @hidden */
  47542. export var backgroundPixelShader: {
  47543. name: string;
  47544. shader: string;
  47545. };
  47546. }
  47547. declare module BABYLON {
  47548. /** @hidden */
  47549. export var backgroundVertexDeclaration: {
  47550. name: string;
  47551. shader: string;
  47552. };
  47553. }
  47554. declare module BABYLON {
  47555. /** @hidden */
  47556. export var backgroundVertexShader: {
  47557. name: string;
  47558. shader: string;
  47559. };
  47560. }
  47561. declare module BABYLON {
  47562. /**
  47563. * Background material used to create an efficient environement around your scene.
  47564. */
  47565. export class BackgroundMaterial extends PushMaterial {
  47566. /**
  47567. * Standard reflectance value at parallel view angle.
  47568. */
  47569. static StandardReflectance0: number;
  47570. /**
  47571. * Standard reflectance value at grazing angle.
  47572. */
  47573. static StandardReflectance90: number;
  47574. protected _primaryColor: Color3;
  47575. /**
  47576. * Key light Color (multiply against the environement texture)
  47577. */
  47578. primaryColor: Color3;
  47579. protected __perceptualColor: Nullable<Color3>;
  47580. /**
  47581. * Experimental Internal Use Only.
  47582. *
  47583. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47584. * This acts as a helper to set the primary color to a more "human friendly" value.
  47585. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47586. * output color as close as possible from the chosen value.
  47587. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47588. * part of lighting setup.)
  47589. */
  47590. _perceptualColor: Nullable<Color3>;
  47591. protected _primaryColorShadowLevel: float;
  47592. /**
  47593. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47594. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47595. */
  47596. primaryColorShadowLevel: float;
  47597. protected _primaryColorHighlightLevel: float;
  47598. /**
  47599. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47600. * The primary color is used at the level chosen to define what the white area would look.
  47601. */
  47602. primaryColorHighlightLevel: float;
  47603. protected _reflectionTexture: Nullable<BaseTexture>;
  47604. /**
  47605. * Reflection Texture used in the material.
  47606. * Should be author in a specific way for the best result (refer to the documentation).
  47607. */
  47608. reflectionTexture: Nullable<BaseTexture>;
  47609. protected _reflectionBlur: float;
  47610. /**
  47611. * Reflection Texture level of blur.
  47612. *
  47613. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47614. * texture twice.
  47615. */
  47616. reflectionBlur: float;
  47617. protected _diffuseTexture: Nullable<BaseTexture>;
  47618. /**
  47619. * Diffuse Texture used in the material.
  47620. * Should be author in a specific way for the best result (refer to the documentation).
  47621. */
  47622. diffuseTexture: Nullable<BaseTexture>;
  47623. protected _shadowLights: Nullable<IShadowLight[]>;
  47624. /**
  47625. * Specify the list of lights casting shadow on the material.
  47626. * All scene shadow lights will be included if null.
  47627. */
  47628. shadowLights: Nullable<IShadowLight[]>;
  47629. protected _shadowLevel: float;
  47630. /**
  47631. * Helps adjusting the shadow to a softer level if required.
  47632. * 0 means black shadows and 1 means no shadows.
  47633. */
  47634. shadowLevel: float;
  47635. protected _sceneCenter: Vector3;
  47636. /**
  47637. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47638. * It is usually zero but might be interesting to modify according to your setup.
  47639. */
  47640. sceneCenter: Vector3;
  47641. protected _opacityFresnel: boolean;
  47642. /**
  47643. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47644. * This helps ensuring a nice transition when the camera goes under the ground.
  47645. */
  47646. opacityFresnel: boolean;
  47647. protected _reflectionFresnel: boolean;
  47648. /**
  47649. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47650. * This helps adding a mirror texture on the ground.
  47651. */
  47652. reflectionFresnel: boolean;
  47653. protected _reflectionFalloffDistance: number;
  47654. /**
  47655. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47656. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47657. */
  47658. reflectionFalloffDistance: number;
  47659. protected _reflectionAmount: number;
  47660. /**
  47661. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47662. */
  47663. reflectionAmount: number;
  47664. protected _reflectionReflectance0: number;
  47665. /**
  47666. * This specifies the weight of the reflection at grazing angle.
  47667. */
  47668. reflectionReflectance0: number;
  47669. protected _reflectionReflectance90: number;
  47670. /**
  47671. * This specifies the weight of the reflection at a perpendicular point of view.
  47672. */
  47673. reflectionReflectance90: number;
  47674. /**
  47675. * Sets the reflection reflectance fresnel values according to the default standard
  47676. * empirically know to work well :-)
  47677. */
  47678. reflectionStandardFresnelWeight: number;
  47679. protected _useRGBColor: boolean;
  47680. /**
  47681. * Helps to directly use the maps channels instead of their level.
  47682. */
  47683. useRGBColor: boolean;
  47684. protected _enableNoise: boolean;
  47685. /**
  47686. * This helps reducing the banding effect that could occur on the background.
  47687. */
  47688. enableNoise: boolean;
  47689. /**
  47690. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47691. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47692. * Recommended to be keep at 1.0 except for special cases.
  47693. */
  47694. fovMultiplier: number;
  47695. private _fovMultiplier;
  47696. /**
  47697. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47698. */
  47699. useEquirectangularFOV: boolean;
  47700. private _maxSimultaneousLights;
  47701. /**
  47702. * Number of Simultaneous lights allowed on the material.
  47703. */
  47704. maxSimultaneousLights: int;
  47705. /**
  47706. * Default configuration related to image processing available in the Background Material.
  47707. */
  47708. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47709. /**
  47710. * Keep track of the image processing observer to allow dispose and replace.
  47711. */
  47712. private _imageProcessingObserver;
  47713. /**
  47714. * Attaches a new image processing configuration to the PBR Material.
  47715. * @param configuration (if null the scene configuration will be use)
  47716. */
  47717. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47718. /**
  47719. * Gets the image processing configuration used either in this material.
  47720. */
  47721. /**
  47722. * Sets the Default image processing configuration used either in the this material.
  47723. *
  47724. * If sets to null, the scene one is in use.
  47725. */
  47726. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47727. /**
  47728. * Gets wether the color curves effect is enabled.
  47729. */
  47730. /**
  47731. * Sets wether the color curves effect is enabled.
  47732. */
  47733. cameraColorCurvesEnabled: boolean;
  47734. /**
  47735. * Gets wether the color grading effect is enabled.
  47736. */
  47737. /**
  47738. * Gets wether the color grading effect is enabled.
  47739. */
  47740. cameraColorGradingEnabled: boolean;
  47741. /**
  47742. * Gets wether tonemapping is enabled or not.
  47743. */
  47744. /**
  47745. * Sets wether tonemapping is enabled or not
  47746. */
  47747. cameraToneMappingEnabled: boolean;
  47748. /**
  47749. * The camera exposure used on this material.
  47750. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47751. * This corresponds to a photographic exposure.
  47752. */
  47753. /**
  47754. * The camera exposure used on this material.
  47755. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47756. * This corresponds to a photographic exposure.
  47757. */
  47758. cameraExposure: float;
  47759. /**
  47760. * Gets The camera contrast used on this material.
  47761. */
  47762. /**
  47763. * Sets The camera contrast used on this material.
  47764. */
  47765. cameraContrast: float;
  47766. /**
  47767. * Gets the Color Grading 2D Lookup Texture.
  47768. */
  47769. /**
  47770. * Sets the Color Grading 2D Lookup Texture.
  47771. */
  47772. cameraColorGradingTexture: Nullable<BaseTexture>;
  47773. /**
  47774. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47775. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47776. * 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;
  47777. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47778. */
  47779. /**
  47780. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47781. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47782. * 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;
  47783. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47784. */
  47785. cameraColorCurves: Nullable<ColorCurves>;
  47786. /**
  47787. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47788. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47789. */
  47790. switchToBGR: boolean;
  47791. private _renderTargets;
  47792. private _reflectionControls;
  47793. private _white;
  47794. private _primaryShadowColor;
  47795. private _primaryHighlightColor;
  47796. /**
  47797. * Instantiates a Background Material in the given scene
  47798. * @param name The friendly name of the material
  47799. * @param scene The scene to add the material to
  47800. */
  47801. constructor(name: string, scene: Scene);
  47802. /**
  47803. * Gets a boolean indicating that current material needs to register RTT
  47804. */
  47805. readonly hasRenderTargetTextures: boolean;
  47806. /**
  47807. * The entire material has been created in order to prevent overdraw.
  47808. * @returns false
  47809. */
  47810. needAlphaTesting(): boolean;
  47811. /**
  47812. * The entire material has been created in order to prevent overdraw.
  47813. * @returns true if blending is enable
  47814. */
  47815. needAlphaBlending(): boolean;
  47816. /**
  47817. * Checks wether the material is ready to be rendered for a given mesh.
  47818. * @param mesh The mesh to render
  47819. * @param subMesh The submesh to check against
  47820. * @param useInstances Specify wether or not the material is used with instances
  47821. * @returns true if all the dependencies are ready (Textures, Effects...)
  47822. */
  47823. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47824. /**
  47825. * Compute the primary color according to the chosen perceptual color.
  47826. */
  47827. private _computePrimaryColorFromPerceptualColor;
  47828. /**
  47829. * Compute the highlights and shadow colors according to their chosen levels.
  47830. */
  47831. private _computePrimaryColors;
  47832. /**
  47833. * Build the uniform buffer used in the material.
  47834. */
  47835. buildUniformLayout(): void;
  47836. /**
  47837. * Unbind the material.
  47838. */
  47839. unbind(): void;
  47840. /**
  47841. * Bind only the world matrix to the material.
  47842. * @param world The world matrix to bind.
  47843. */
  47844. bindOnlyWorldMatrix(world: Matrix): void;
  47845. /**
  47846. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47847. * @param world The world matrix to bind.
  47848. * @param subMesh The submesh to bind for.
  47849. */
  47850. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47851. /**
  47852. * Checks to see if a texture is used in the material.
  47853. * @param texture - Base texture to use.
  47854. * @returns - Boolean specifying if a texture is used in the material.
  47855. */
  47856. hasTexture(texture: BaseTexture): boolean;
  47857. /**
  47858. * Dispose the material.
  47859. * @param forceDisposeEffect Force disposal of the associated effect.
  47860. * @param forceDisposeTextures Force disposal of the associated textures.
  47861. */
  47862. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47863. /**
  47864. * Clones the material.
  47865. * @param name The cloned name.
  47866. * @returns The cloned material.
  47867. */
  47868. clone(name: string): BackgroundMaterial;
  47869. /**
  47870. * Serializes the current material to its JSON representation.
  47871. * @returns The JSON representation.
  47872. */
  47873. serialize(): any;
  47874. /**
  47875. * Gets the class name of the material
  47876. * @returns "BackgroundMaterial"
  47877. */
  47878. getClassName(): string;
  47879. /**
  47880. * Parse a JSON input to create back a background material.
  47881. * @param source The JSON data to parse
  47882. * @param scene The scene to create the parsed material in
  47883. * @param rootUrl The root url of the assets the material depends upon
  47884. * @returns the instantiated BackgroundMaterial.
  47885. */
  47886. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47887. }
  47888. }
  47889. declare module BABYLON {
  47890. /**
  47891. * Represents the different options available during the creation of
  47892. * a Environment helper.
  47893. *
  47894. * This can control the default ground, skybox and image processing setup of your scene.
  47895. */
  47896. export interface IEnvironmentHelperOptions {
  47897. /**
  47898. * Specifies wether or not to create a ground.
  47899. * True by default.
  47900. */
  47901. createGround: boolean;
  47902. /**
  47903. * Specifies the ground size.
  47904. * 15 by default.
  47905. */
  47906. groundSize: number;
  47907. /**
  47908. * The texture used on the ground for the main color.
  47909. * Comes from the BabylonJS CDN by default.
  47910. *
  47911. * Remarks: Can be either a texture or a url.
  47912. */
  47913. groundTexture: string | BaseTexture;
  47914. /**
  47915. * The color mixed in the ground texture by default.
  47916. * BabylonJS clearColor by default.
  47917. */
  47918. groundColor: Color3;
  47919. /**
  47920. * Specifies the ground opacity.
  47921. * 1 by default.
  47922. */
  47923. groundOpacity: number;
  47924. /**
  47925. * Enables the ground to receive shadows.
  47926. * True by default.
  47927. */
  47928. enableGroundShadow: boolean;
  47929. /**
  47930. * Helps preventing the shadow to be fully black on the ground.
  47931. * 0.5 by default.
  47932. */
  47933. groundShadowLevel: number;
  47934. /**
  47935. * Creates a mirror texture attach to the ground.
  47936. * false by default.
  47937. */
  47938. enableGroundMirror: boolean;
  47939. /**
  47940. * Specifies the ground mirror size ratio.
  47941. * 0.3 by default as the default kernel is 64.
  47942. */
  47943. groundMirrorSizeRatio: number;
  47944. /**
  47945. * Specifies the ground mirror blur kernel size.
  47946. * 64 by default.
  47947. */
  47948. groundMirrorBlurKernel: number;
  47949. /**
  47950. * Specifies the ground mirror visibility amount.
  47951. * 1 by default
  47952. */
  47953. groundMirrorAmount: number;
  47954. /**
  47955. * Specifies the ground mirror reflectance weight.
  47956. * This uses the standard weight of the background material to setup the fresnel effect
  47957. * of the mirror.
  47958. * 1 by default.
  47959. */
  47960. groundMirrorFresnelWeight: number;
  47961. /**
  47962. * Specifies the ground mirror Falloff distance.
  47963. * This can helps reducing the size of the reflection.
  47964. * 0 by Default.
  47965. */
  47966. groundMirrorFallOffDistance: number;
  47967. /**
  47968. * Specifies the ground mirror texture type.
  47969. * Unsigned Int by Default.
  47970. */
  47971. groundMirrorTextureType: number;
  47972. /**
  47973. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47974. * the shown objects.
  47975. */
  47976. groundYBias: number;
  47977. /**
  47978. * Specifies wether or not to create a skybox.
  47979. * True by default.
  47980. */
  47981. createSkybox: boolean;
  47982. /**
  47983. * Specifies the skybox size.
  47984. * 20 by default.
  47985. */
  47986. skyboxSize: number;
  47987. /**
  47988. * The texture used on the skybox for the main color.
  47989. * Comes from the BabylonJS CDN by default.
  47990. *
  47991. * Remarks: Can be either a texture or a url.
  47992. */
  47993. skyboxTexture: string | BaseTexture;
  47994. /**
  47995. * The color mixed in the skybox texture by default.
  47996. * BabylonJS clearColor by default.
  47997. */
  47998. skyboxColor: Color3;
  47999. /**
  48000. * The background rotation around the Y axis of the scene.
  48001. * This helps aligning the key lights of your scene with the background.
  48002. * 0 by default.
  48003. */
  48004. backgroundYRotation: number;
  48005. /**
  48006. * Compute automatically the size of the elements to best fit with the scene.
  48007. */
  48008. sizeAuto: boolean;
  48009. /**
  48010. * Default position of the rootMesh if autoSize is not true.
  48011. */
  48012. rootPosition: Vector3;
  48013. /**
  48014. * Sets up the image processing in the scene.
  48015. * true by default.
  48016. */
  48017. setupImageProcessing: boolean;
  48018. /**
  48019. * The texture used as your environment texture in the scene.
  48020. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48021. *
  48022. * Remarks: Can be either a texture or a url.
  48023. */
  48024. environmentTexture: string | BaseTexture;
  48025. /**
  48026. * The value of the exposure to apply to the scene.
  48027. * 0.6 by default if setupImageProcessing is true.
  48028. */
  48029. cameraExposure: number;
  48030. /**
  48031. * The value of the contrast to apply to the scene.
  48032. * 1.6 by default if setupImageProcessing is true.
  48033. */
  48034. cameraContrast: number;
  48035. /**
  48036. * Specifies wether or not tonemapping should be enabled in the scene.
  48037. * true by default if setupImageProcessing is true.
  48038. */
  48039. toneMappingEnabled: boolean;
  48040. }
  48041. /**
  48042. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48043. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48044. * It also helps with the default setup of your imageProcessing configuration.
  48045. */
  48046. export class EnvironmentHelper {
  48047. /**
  48048. * Default ground texture URL.
  48049. */
  48050. private static _groundTextureCDNUrl;
  48051. /**
  48052. * Default skybox texture URL.
  48053. */
  48054. private static _skyboxTextureCDNUrl;
  48055. /**
  48056. * Default environment texture URL.
  48057. */
  48058. private static _environmentTextureCDNUrl;
  48059. /**
  48060. * Creates the default options for the helper.
  48061. */
  48062. private static _getDefaultOptions;
  48063. private _rootMesh;
  48064. /**
  48065. * Gets the root mesh created by the helper.
  48066. */
  48067. readonly rootMesh: Mesh;
  48068. private _skybox;
  48069. /**
  48070. * Gets the skybox created by the helper.
  48071. */
  48072. readonly skybox: Nullable<Mesh>;
  48073. private _skyboxTexture;
  48074. /**
  48075. * Gets the skybox texture created by the helper.
  48076. */
  48077. readonly skyboxTexture: Nullable<BaseTexture>;
  48078. private _skyboxMaterial;
  48079. /**
  48080. * Gets the skybox material created by the helper.
  48081. */
  48082. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48083. private _ground;
  48084. /**
  48085. * Gets the ground mesh created by the helper.
  48086. */
  48087. readonly ground: Nullable<Mesh>;
  48088. private _groundTexture;
  48089. /**
  48090. * Gets the ground texture created by the helper.
  48091. */
  48092. readonly groundTexture: Nullable<BaseTexture>;
  48093. private _groundMirror;
  48094. /**
  48095. * Gets the ground mirror created by the helper.
  48096. */
  48097. readonly groundMirror: Nullable<MirrorTexture>;
  48098. /**
  48099. * Gets the ground mirror render list to helps pushing the meshes
  48100. * you wish in the ground reflection.
  48101. */
  48102. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48103. private _groundMaterial;
  48104. /**
  48105. * Gets the ground material created by the helper.
  48106. */
  48107. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48108. /**
  48109. * Stores the creation options.
  48110. */
  48111. private readonly _scene;
  48112. private _options;
  48113. /**
  48114. * This observable will be notified with any error during the creation of the environment,
  48115. * mainly texture creation errors.
  48116. */
  48117. onErrorObservable: Observable<{
  48118. message?: string;
  48119. exception?: any;
  48120. }>;
  48121. /**
  48122. * constructor
  48123. * @param options Defines the options we want to customize the helper
  48124. * @param scene The scene to add the material to
  48125. */
  48126. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48127. /**
  48128. * Updates the background according to the new options
  48129. * @param options
  48130. */
  48131. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48132. /**
  48133. * Sets the primary color of all the available elements.
  48134. * @param color the main color to affect to the ground and the background
  48135. */
  48136. setMainColor(color: Color3): void;
  48137. /**
  48138. * Setup the image processing according to the specified options.
  48139. */
  48140. private _setupImageProcessing;
  48141. /**
  48142. * Setup the environment texture according to the specified options.
  48143. */
  48144. private _setupEnvironmentTexture;
  48145. /**
  48146. * Setup the background according to the specified options.
  48147. */
  48148. private _setupBackground;
  48149. /**
  48150. * Get the scene sizes according to the setup.
  48151. */
  48152. private _getSceneSize;
  48153. /**
  48154. * Setup the ground according to the specified options.
  48155. */
  48156. private _setupGround;
  48157. /**
  48158. * Setup the ground material according to the specified options.
  48159. */
  48160. private _setupGroundMaterial;
  48161. /**
  48162. * Setup the ground diffuse texture according to the specified options.
  48163. */
  48164. private _setupGroundDiffuseTexture;
  48165. /**
  48166. * Setup the ground mirror texture according to the specified options.
  48167. */
  48168. private _setupGroundMirrorTexture;
  48169. /**
  48170. * Setup the ground to receive the mirror texture.
  48171. */
  48172. private _setupMirrorInGroundMaterial;
  48173. /**
  48174. * Setup the skybox according to the specified options.
  48175. */
  48176. private _setupSkybox;
  48177. /**
  48178. * Setup the skybox material according to the specified options.
  48179. */
  48180. private _setupSkyboxMaterial;
  48181. /**
  48182. * Setup the skybox reflection texture according to the specified options.
  48183. */
  48184. private _setupSkyboxReflectionTexture;
  48185. private _errorHandler;
  48186. /**
  48187. * Dispose all the elements created by the Helper.
  48188. */
  48189. dispose(): void;
  48190. }
  48191. }
  48192. declare module BABYLON {
  48193. /**
  48194. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48195. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48196. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48197. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48198. */
  48199. export class PhotoDome extends TransformNode {
  48200. /**
  48201. * Define the image as a Monoscopic panoramic 360 image.
  48202. */
  48203. static readonly MODE_MONOSCOPIC: number;
  48204. /**
  48205. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48206. */
  48207. static readonly MODE_TOPBOTTOM: number;
  48208. /**
  48209. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48210. */
  48211. static readonly MODE_SIDEBYSIDE: number;
  48212. private _useDirectMapping;
  48213. /**
  48214. * The texture being displayed on the sphere
  48215. */
  48216. protected _photoTexture: Texture;
  48217. /**
  48218. * Gets or sets the texture being displayed on the sphere
  48219. */
  48220. photoTexture: Texture;
  48221. /**
  48222. * Observable raised when an error occured while loading the 360 image
  48223. */
  48224. onLoadErrorObservable: Observable<string>;
  48225. /**
  48226. * The skybox material
  48227. */
  48228. protected _material: BackgroundMaterial;
  48229. /**
  48230. * The surface used for the skybox
  48231. */
  48232. protected _mesh: Mesh;
  48233. /**
  48234. * Gets the mesh used for the skybox.
  48235. */
  48236. readonly mesh: Mesh;
  48237. /**
  48238. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48239. * Also see the options.resolution property.
  48240. */
  48241. fovMultiplier: number;
  48242. private _imageMode;
  48243. /**
  48244. * Gets or set the current video mode for the video. It can be:
  48245. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48246. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48247. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48248. */
  48249. imageMode: number;
  48250. /**
  48251. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48252. * @param name Element's name, child elements will append suffixes for their own names.
  48253. * @param urlsOfPhoto defines the url of the photo to display
  48254. * @param options defines an object containing optional or exposed sub element properties
  48255. * @param onError defines a callback called when an error occured while loading the texture
  48256. */
  48257. constructor(name: string, urlOfPhoto: string, options: {
  48258. resolution?: number;
  48259. size?: number;
  48260. useDirectMapping?: boolean;
  48261. faceForward?: boolean;
  48262. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48263. private _onBeforeCameraRenderObserver;
  48264. private _changeImageMode;
  48265. /**
  48266. * Releases resources associated with this node.
  48267. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48268. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48269. */
  48270. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48271. }
  48272. }
  48273. declare module BABYLON {
  48274. /**
  48275. * Class used to host RGBD texture specific utilities
  48276. */
  48277. export class RGBDTextureTools {
  48278. /**
  48279. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48280. * @param texture the texture to expand.
  48281. */
  48282. static ExpandRGBDTexture(texture: Texture): void;
  48283. }
  48284. }
  48285. declare module BABYLON {
  48286. /**
  48287. * Class used to host texture specific utilities
  48288. */
  48289. export class BRDFTextureTools {
  48290. /**
  48291. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48292. * @param scene defines the hosting scene
  48293. * @returns the environment BRDF texture
  48294. */
  48295. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48296. private static _environmentBRDFBase64Texture;
  48297. }
  48298. }
  48299. declare module BABYLON {
  48300. /**
  48301. * @hidden
  48302. */
  48303. export interface IMaterialClearCoatDefines {
  48304. CLEARCOAT: boolean;
  48305. CLEARCOAT_DEFAULTIOR: boolean;
  48306. CLEARCOAT_TEXTURE: boolean;
  48307. CLEARCOAT_TEXTUREDIRECTUV: number;
  48308. CLEARCOAT_BUMP: boolean;
  48309. CLEARCOAT_BUMPDIRECTUV: number;
  48310. CLEARCOAT_TINT: boolean;
  48311. CLEARCOAT_TINT_TEXTURE: boolean;
  48312. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48313. /** @hidden */
  48314. _areTexturesDirty: boolean;
  48315. }
  48316. /**
  48317. * Define the code related to the clear coat parameters of the pbr material.
  48318. */
  48319. export class PBRClearCoatConfiguration {
  48320. /**
  48321. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48322. * The default fits with a polyurethane material.
  48323. */
  48324. private static readonly _DefaultIndexOfRefraction;
  48325. private _isEnabled;
  48326. /**
  48327. * Defines if the clear coat is enabled in the material.
  48328. */
  48329. isEnabled: boolean;
  48330. /**
  48331. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48332. */
  48333. intensity: number;
  48334. /**
  48335. * Defines the clear coat layer roughness.
  48336. */
  48337. roughness: number;
  48338. private _indexOfRefraction;
  48339. /**
  48340. * Defines the index of refraction of the clear coat.
  48341. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48342. * The default fits with a polyurethane material.
  48343. * Changing the default value is more performance intensive.
  48344. */
  48345. indexOfRefraction: number;
  48346. private _texture;
  48347. /**
  48348. * Stores the clear coat values in a texture.
  48349. */
  48350. texture: Nullable<BaseTexture>;
  48351. private _bumpTexture;
  48352. /**
  48353. * Define the clear coat specific bump texture.
  48354. */
  48355. bumpTexture: Nullable<BaseTexture>;
  48356. private _isTintEnabled;
  48357. /**
  48358. * Defines if the clear coat tint is enabled in the material.
  48359. */
  48360. isTintEnabled: boolean;
  48361. /**
  48362. * Defines the clear coat tint of the material.
  48363. * This is only use if tint is enabled
  48364. */
  48365. tintColor: Color3;
  48366. /**
  48367. * Defines the distance at which the tint color should be found in the
  48368. * clear coat media.
  48369. * This is only use if tint is enabled
  48370. */
  48371. tintColorAtDistance: number;
  48372. /**
  48373. * Defines the clear coat layer thickness.
  48374. * This is only use if tint is enabled
  48375. */
  48376. tintThickness: number;
  48377. private _tintTexture;
  48378. /**
  48379. * Stores the clear tint values in a texture.
  48380. * rgb is tint
  48381. * a is a thickness factor
  48382. */
  48383. tintTexture: Nullable<BaseTexture>;
  48384. /** @hidden */
  48385. private _internalMarkAllSubMeshesAsTexturesDirty;
  48386. /** @hidden */
  48387. _markAllSubMeshesAsTexturesDirty(): void;
  48388. /**
  48389. * Instantiate a new istance of clear coat configuration.
  48390. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48391. */
  48392. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48393. /**
  48394. * Gets wehter the submesh is ready to be used or not.
  48395. * @param defines the list of "defines" to update.
  48396. * @param scene defines the scene the material belongs to.
  48397. * @param engine defines the engine the material belongs to.
  48398. * @param disableBumpMap defines wether the material disables bump or not.
  48399. * @returns - boolean indicating that the submesh is ready or not.
  48400. */
  48401. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48402. /**
  48403. * Checks to see if a texture is used in the material.
  48404. * @param defines the list of "defines" to update.
  48405. * @param scene defines the scene to the material belongs to.
  48406. */
  48407. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48408. /**
  48409. * Binds the material data.
  48410. * @param uniformBuffer defines the Uniform buffer to fill in.
  48411. * @param scene defines the scene the material belongs to.
  48412. * @param engine defines the engine the material belongs to.
  48413. * @param disableBumpMap defines wether the material disables bump or not.
  48414. * @param isFrozen defines wether the material is frozen or not.
  48415. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48416. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48417. */
  48418. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48419. /**
  48420. * Checks to see if a texture is used in the material.
  48421. * @param texture - Base texture to use.
  48422. * @returns - Boolean specifying if a texture is used in the material.
  48423. */
  48424. hasTexture(texture: BaseTexture): boolean;
  48425. /**
  48426. * Returns an array of the actively used textures.
  48427. * @param activeTextures Array of BaseTextures
  48428. */
  48429. getActiveTextures(activeTextures: BaseTexture[]): void;
  48430. /**
  48431. * Returns the animatable textures.
  48432. * @param animatables Array of animatable textures.
  48433. */
  48434. getAnimatables(animatables: IAnimatable[]): void;
  48435. /**
  48436. * Disposes the resources of the material.
  48437. * @param forceDisposeTextures - Forces the disposal of all textures.
  48438. */
  48439. dispose(forceDisposeTextures?: boolean): void;
  48440. /**
  48441. * Get the current class name of the texture useful for serialization or dynamic coding.
  48442. * @returns "PBRClearCoatConfiguration"
  48443. */
  48444. getClassName(): string;
  48445. /**
  48446. * Add fallbacks to the effect fallbacks list.
  48447. * @param defines defines the Base texture to use.
  48448. * @param fallbacks defines the current fallback list.
  48449. * @param currentRank defines the current fallback rank.
  48450. * @returns the new fallback rank.
  48451. */
  48452. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48453. /**
  48454. * Add the required uniforms to the current list.
  48455. * @param uniforms defines the current uniform list.
  48456. */
  48457. static AddUniforms(uniforms: string[]): void;
  48458. /**
  48459. * Add the required samplers to the current list.
  48460. * @param samplers defines the current sampler list.
  48461. */
  48462. static AddSamplers(samplers: string[]): void;
  48463. /**
  48464. * Add the required uniforms to the current buffer.
  48465. * @param uniformBuffer defines the current uniform buffer.
  48466. */
  48467. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48468. /**
  48469. * Makes a duplicate of the current configuration into another one.
  48470. * @param clearCoatConfiguration define the config where to copy the info
  48471. */
  48472. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48473. /**
  48474. * Serializes this clear coat configuration.
  48475. * @returns - An object with the serialized config.
  48476. */
  48477. serialize(): any;
  48478. /**
  48479. * Parses a anisotropy Configuration from a serialized object.
  48480. * @param source - Serialized object.
  48481. * @param scene Defines the scene we are parsing for
  48482. * @param rootUrl Defines the rootUrl to load from
  48483. */
  48484. parse(source: any, scene: Scene, rootUrl: string): void;
  48485. }
  48486. }
  48487. declare module BABYLON {
  48488. /**
  48489. * @hidden
  48490. */
  48491. export interface IMaterialAnisotropicDefines {
  48492. ANISOTROPIC: boolean;
  48493. ANISOTROPIC_TEXTURE: boolean;
  48494. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48495. MAINUV1: boolean;
  48496. _areTexturesDirty: boolean;
  48497. _needUVs: boolean;
  48498. }
  48499. /**
  48500. * Define the code related to the anisotropic parameters of the pbr material.
  48501. */
  48502. export class PBRAnisotropicConfiguration {
  48503. private _isEnabled;
  48504. /**
  48505. * Defines if the anisotropy is enabled in the material.
  48506. */
  48507. isEnabled: boolean;
  48508. /**
  48509. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48510. */
  48511. intensity: number;
  48512. /**
  48513. * Defines if the effect is along the tangents, bitangents or in between.
  48514. * By default, the effect is "strectching" the highlights along the tangents.
  48515. */
  48516. direction: Vector2;
  48517. private _texture;
  48518. /**
  48519. * Stores the anisotropy values in a texture.
  48520. * rg is direction (like normal from -1 to 1)
  48521. * b is a intensity
  48522. */
  48523. texture: Nullable<BaseTexture>;
  48524. /** @hidden */
  48525. private _internalMarkAllSubMeshesAsTexturesDirty;
  48526. /** @hidden */
  48527. _markAllSubMeshesAsTexturesDirty(): void;
  48528. /**
  48529. * Instantiate a new istance of anisotropy configuration.
  48530. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48531. */
  48532. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48533. /**
  48534. * Specifies that the submesh is ready to be used.
  48535. * @param defines the list of "defines" to update.
  48536. * @param scene defines the scene the material belongs to.
  48537. * @returns - boolean indicating that the submesh is ready or not.
  48538. */
  48539. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48540. /**
  48541. * Checks to see if a texture is used in the material.
  48542. * @param defines the list of "defines" to update.
  48543. * @param mesh the mesh we are preparing the defines for.
  48544. * @param scene defines the scene the material belongs to.
  48545. */
  48546. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48547. /**
  48548. * Binds the material data.
  48549. * @param uniformBuffer defines the Uniform buffer to fill in.
  48550. * @param scene defines the scene the material belongs to.
  48551. * @param isFrozen defines wether the material is frozen or not.
  48552. */
  48553. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48554. /**
  48555. * Checks to see if a texture is used in the material.
  48556. * @param texture - Base texture to use.
  48557. * @returns - Boolean specifying if a texture is used in the material.
  48558. */
  48559. hasTexture(texture: BaseTexture): boolean;
  48560. /**
  48561. * Returns an array of the actively used textures.
  48562. * @param activeTextures Array of BaseTextures
  48563. */
  48564. getActiveTextures(activeTextures: BaseTexture[]): void;
  48565. /**
  48566. * Returns the animatable textures.
  48567. * @param animatables Array of animatable textures.
  48568. */
  48569. getAnimatables(animatables: IAnimatable[]): void;
  48570. /**
  48571. * Disposes the resources of the material.
  48572. * @param forceDisposeTextures - Forces the disposal of all textures.
  48573. */
  48574. dispose(forceDisposeTextures?: boolean): void;
  48575. /**
  48576. * Get the current class name of the texture useful for serialization or dynamic coding.
  48577. * @returns "PBRAnisotropicConfiguration"
  48578. */
  48579. getClassName(): string;
  48580. /**
  48581. * Add fallbacks to the effect fallbacks list.
  48582. * @param defines defines the Base texture to use.
  48583. * @param fallbacks defines the current fallback list.
  48584. * @param currentRank defines the current fallback rank.
  48585. * @returns the new fallback rank.
  48586. */
  48587. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48588. /**
  48589. * Add the required uniforms to the current list.
  48590. * @param uniforms defines the current uniform list.
  48591. */
  48592. static AddUniforms(uniforms: string[]): void;
  48593. /**
  48594. * Add the required uniforms to the current buffer.
  48595. * @param uniformBuffer defines the current uniform buffer.
  48596. */
  48597. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48598. /**
  48599. * Add the required samplers to the current list.
  48600. * @param samplers defines the current sampler list.
  48601. */
  48602. static AddSamplers(samplers: string[]): void;
  48603. /**
  48604. * Makes a duplicate of the current configuration into another one.
  48605. * @param anisotropicConfiguration define the config where to copy the info
  48606. */
  48607. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48608. /**
  48609. * Serializes this anisotropy configuration.
  48610. * @returns - An object with the serialized config.
  48611. */
  48612. serialize(): any;
  48613. /**
  48614. * Parses a anisotropy Configuration from a serialized object.
  48615. * @param source - Serialized object.
  48616. * @param scene Defines the scene we are parsing for
  48617. * @param rootUrl Defines the rootUrl to load from
  48618. */
  48619. parse(source: any, scene: Scene, rootUrl: string): void;
  48620. }
  48621. }
  48622. declare module BABYLON {
  48623. /**
  48624. * @hidden
  48625. */
  48626. export interface IMaterialBRDFDefines {
  48627. BRDF_V_HEIGHT_CORRELATED: boolean;
  48628. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48629. SPHERICAL_HARMONICS: boolean;
  48630. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48631. /** @hidden */
  48632. _areMiscDirty: boolean;
  48633. }
  48634. /**
  48635. * Define the code related to the BRDF parameters of the pbr material.
  48636. */
  48637. export class PBRBRDFConfiguration {
  48638. /**
  48639. * Default value used for the energy conservation.
  48640. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48641. */
  48642. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48643. /**
  48644. * Default value used for the Smith Visibility Height Correlated mode.
  48645. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48646. */
  48647. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48648. /**
  48649. * Default value used for the IBL diffuse part.
  48650. * This can help switching back to the polynomials mode globally which is a tiny bit
  48651. * less GPU intensive at the drawback of a lower quality.
  48652. */
  48653. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48654. /**
  48655. * Default value used for activating energy conservation for the specular workflow.
  48656. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48657. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48658. */
  48659. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48660. private _useEnergyConservation;
  48661. /**
  48662. * Defines if the material uses energy conservation.
  48663. */
  48664. useEnergyConservation: boolean;
  48665. private _useSmithVisibilityHeightCorrelated;
  48666. /**
  48667. * LEGACY Mode set to false
  48668. * Defines if the material uses height smith correlated visibility term.
  48669. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48670. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48671. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48672. * Not relying on height correlated will also disable energy conservation.
  48673. */
  48674. useSmithVisibilityHeightCorrelated: boolean;
  48675. private _useSphericalHarmonics;
  48676. /**
  48677. * LEGACY Mode set to false
  48678. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48679. * diffuse part of the IBL.
  48680. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48681. * to the ground truth.
  48682. */
  48683. useSphericalHarmonics: boolean;
  48684. private _useSpecularGlossinessInputEnergyConservation;
  48685. /**
  48686. * Defines if the material uses energy conservation, when the specular workflow is active.
  48687. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48688. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48689. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48690. */
  48691. useSpecularGlossinessInputEnergyConservation: boolean;
  48692. /** @hidden */
  48693. private _internalMarkAllSubMeshesAsMiscDirty;
  48694. /** @hidden */
  48695. _markAllSubMeshesAsMiscDirty(): void;
  48696. /**
  48697. * Instantiate a new istance of clear coat configuration.
  48698. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48699. */
  48700. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48701. /**
  48702. * Checks to see if a texture is used in the material.
  48703. * @param defines the list of "defines" to update.
  48704. */
  48705. prepareDefines(defines: IMaterialBRDFDefines): void;
  48706. /**
  48707. * Get the current class name of the texture useful for serialization or dynamic coding.
  48708. * @returns "PBRClearCoatConfiguration"
  48709. */
  48710. getClassName(): string;
  48711. /**
  48712. * Makes a duplicate of the current configuration into another one.
  48713. * @param brdfConfiguration define the config where to copy the info
  48714. */
  48715. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48716. /**
  48717. * Serializes this BRDF configuration.
  48718. * @returns - An object with the serialized config.
  48719. */
  48720. serialize(): any;
  48721. /**
  48722. * Parses a anisotropy Configuration from a serialized object.
  48723. * @param source - Serialized object.
  48724. * @param scene Defines the scene we are parsing for
  48725. * @param rootUrl Defines the rootUrl to load from
  48726. */
  48727. parse(source: any, scene: Scene, rootUrl: string): void;
  48728. }
  48729. }
  48730. declare module BABYLON {
  48731. /**
  48732. * @hidden
  48733. */
  48734. export interface IMaterialSheenDefines {
  48735. SHEEN: boolean;
  48736. SHEEN_TEXTURE: boolean;
  48737. SHEEN_TEXTUREDIRECTUV: number;
  48738. SHEEN_LINKWITHALBEDO: boolean;
  48739. /** @hidden */
  48740. _areTexturesDirty: boolean;
  48741. }
  48742. /**
  48743. * Define the code related to the Sheen parameters of the pbr material.
  48744. */
  48745. export class PBRSheenConfiguration {
  48746. private _isEnabled;
  48747. /**
  48748. * Defines if the material uses sheen.
  48749. */
  48750. isEnabled: boolean;
  48751. private _linkSheenWithAlbedo;
  48752. /**
  48753. * Defines if the sheen is linked to the sheen color.
  48754. */
  48755. linkSheenWithAlbedo: boolean;
  48756. /**
  48757. * Defines the sheen intensity.
  48758. */
  48759. intensity: number;
  48760. /**
  48761. * Defines the sheen color.
  48762. */
  48763. color: Color3;
  48764. private _texture;
  48765. /**
  48766. * Stores the sheen tint values in a texture.
  48767. * rgb is tint
  48768. * a is a intensity
  48769. */
  48770. texture: Nullable<BaseTexture>;
  48771. /** @hidden */
  48772. private _internalMarkAllSubMeshesAsTexturesDirty;
  48773. /** @hidden */
  48774. _markAllSubMeshesAsTexturesDirty(): void;
  48775. /**
  48776. * Instantiate a new istance of clear coat configuration.
  48777. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48778. */
  48779. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48780. /**
  48781. * Specifies that the submesh is ready to be used.
  48782. * @param defines the list of "defines" to update.
  48783. * @param scene defines the scene the material belongs to.
  48784. * @returns - boolean indicating that the submesh is ready or not.
  48785. */
  48786. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48787. /**
  48788. * Checks to see if a texture is used in the material.
  48789. * @param defines the list of "defines" to update.
  48790. * @param scene defines the scene the material belongs to.
  48791. */
  48792. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48793. /**
  48794. * Binds the material data.
  48795. * @param uniformBuffer defines the Uniform buffer to fill in.
  48796. * @param scene defines the scene the material belongs to.
  48797. * @param isFrozen defines wether the material is frozen or not.
  48798. */
  48799. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48800. /**
  48801. * Checks to see if a texture is used in the material.
  48802. * @param texture - Base texture to use.
  48803. * @returns - Boolean specifying if a texture is used in the material.
  48804. */
  48805. hasTexture(texture: BaseTexture): boolean;
  48806. /**
  48807. * Returns an array of the actively used textures.
  48808. * @param activeTextures Array of BaseTextures
  48809. */
  48810. getActiveTextures(activeTextures: BaseTexture[]): void;
  48811. /**
  48812. * Returns the animatable textures.
  48813. * @param animatables Array of animatable textures.
  48814. */
  48815. getAnimatables(animatables: IAnimatable[]): void;
  48816. /**
  48817. * Disposes the resources of the material.
  48818. * @param forceDisposeTextures - Forces the disposal of all textures.
  48819. */
  48820. dispose(forceDisposeTextures?: boolean): void;
  48821. /**
  48822. * Get the current class name of the texture useful for serialization or dynamic coding.
  48823. * @returns "PBRSheenConfiguration"
  48824. */
  48825. getClassName(): string;
  48826. /**
  48827. * Add fallbacks to the effect fallbacks list.
  48828. * @param defines defines the Base texture to use.
  48829. * @param fallbacks defines the current fallback list.
  48830. * @param currentRank defines the current fallback rank.
  48831. * @returns the new fallback rank.
  48832. */
  48833. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48834. /**
  48835. * Add the required uniforms to the current list.
  48836. * @param uniforms defines the current uniform list.
  48837. */
  48838. static AddUniforms(uniforms: string[]): void;
  48839. /**
  48840. * Add the required uniforms to the current buffer.
  48841. * @param uniformBuffer defines the current uniform buffer.
  48842. */
  48843. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48844. /**
  48845. * Add the required samplers to the current list.
  48846. * @param samplers defines the current sampler list.
  48847. */
  48848. static AddSamplers(samplers: string[]): void;
  48849. /**
  48850. * Makes a duplicate of the current configuration into another one.
  48851. * @param sheenConfiguration define the config where to copy the info
  48852. */
  48853. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48854. /**
  48855. * Serializes this BRDF configuration.
  48856. * @returns - An object with the serialized config.
  48857. */
  48858. serialize(): any;
  48859. /**
  48860. * Parses a anisotropy Configuration from a serialized object.
  48861. * @param source - Serialized object.
  48862. * @param scene Defines the scene we are parsing for
  48863. * @param rootUrl Defines the rootUrl to load from
  48864. */
  48865. parse(source: any, scene: Scene, rootUrl: string): void;
  48866. }
  48867. }
  48868. declare module BABYLON {
  48869. /**
  48870. * @hidden
  48871. */
  48872. export interface IMaterialSubSurfaceDefines {
  48873. SUBSURFACE: boolean;
  48874. SS_REFRACTION: boolean;
  48875. SS_TRANSLUCENCY: boolean;
  48876. SS_SCATERRING: boolean;
  48877. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48878. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48879. SS_REFRACTIONMAP_3D: boolean;
  48880. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48881. SS_LODINREFRACTIONALPHA: boolean;
  48882. SS_GAMMAREFRACTION: boolean;
  48883. SS_RGBDREFRACTION: boolean;
  48884. SS_LINEARSPECULARREFRACTION: boolean;
  48885. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48886. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48887. /** @hidden */
  48888. _areTexturesDirty: boolean;
  48889. }
  48890. /**
  48891. * Define the code related to the sub surface parameters of the pbr material.
  48892. */
  48893. export class PBRSubSurfaceConfiguration {
  48894. private _isRefractionEnabled;
  48895. /**
  48896. * Defines if the refraction is enabled in the material.
  48897. */
  48898. isRefractionEnabled: boolean;
  48899. private _isTranslucencyEnabled;
  48900. /**
  48901. * Defines if the translucency is enabled in the material.
  48902. */
  48903. isTranslucencyEnabled: boolean;
  48904. private _isScatteringEnabled;
  48905. /**
  48906. * Defines the refraction intensity of the material.
  48907. * The refraction when enabled replaces the Diffuse part of the material.
  48908. * The intensity helps transitionning between diffuse and refraction.
  48909. */
  48910. refractionIntensity: number;
  48911. /**
  48912. * Defines the translucency intensity of the material.
  48913. * When translucency has been enabled, this defines how much of the "translucency"
  48914. * is addded to the diffuse part of the material.
  48915. */
  48916. translucencyIntensity: number;
  48917. /**
  48918. * Defines the scattering intensity of the material.
  48919. * When scattering has been enabled, this defines how much of the "scattered light"
  48920. * is addded to the diffuse part of the material.
  48921. */
  48922. scatteringIntensity: number;
  48923. private _thicknessTexture;
  48924. /**
  48925. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48926. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48927. * 0 would mean minimumThickness
  48928. * 1 would mean maximumThickness
  48929. * The other channels might be use as a mask to vary the different effects intensity.
  48930. */
  48931. thicknessTexture: Nullable<BaseTexture>;
  48932. private _refractionTexture;
  48933. /**
  48934. * Defines the texture to use for refraction.
  48935. */
  48936. refractionTexture: Nullable<BaseTexture>;
  48937. private _indexOfRefraction;
  48938. /**
  48939. * Defines the index of refraction used in the material.
  48940. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48941. */
  48942. indexOfRefraction: number;
  48943. private _invertRefractionY;
  48944. /**
  48945. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48946. */
  48947. invertRefractionY: boolean;
  48948. private _linkRefractionWithTransparency;
  48949. /**
  48950. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48951. * Materials half opaque for instance using refraction could benefit from this control.
  48952. */
  48953. linkRefractionWithTransparency: boolean;
  48954. /**
  48955. * Defines the minimum thickness stored in the thickness map.
  48956. * If no thickness map is defined, this value will be used to simulate thickness.
  48957. */
  48958. minimumThickness: number;
  48959. /**
  48960. * Defines the maximum thickness stored in the thickness map.
  48961. */
  48962. maximumThickness: number;
  48963. /**
  48964. * Defines the volume tint of the material.
  48965. * This is used for both translucency and scattering.
  48966. */
  48967. tintColor: Color3;
  48968. /**
  48969. * Defines the distance at which the tint color should be found in the media.
  48970. * This is used for refraction only.
  48971. */
  48972. tintColorAtDistance: number;
  48973. /**
  48974. * Defines how far each channel transmit through the media.
  48975. * It is defined as a color to simplify it selection.
  48976. */
  48977. diffusionDistance: Color3;
  48978. private _useMaskFromThicknessTexture;
  48979. /**
  48980. * Stores the intensity of the different subsurface effects in the thickness texture.
  48981. * * the green channel is the translucency intensity.
  48982. * * the blue channel is the scattering intensity.
  48983. * * the alpha channel is the refraction intensity.
  48984. */
  48985. useMaskFromThicknessTexture: boolean;
  48986. /** @hidden */
  48987. private _internalMarkAllSubMeshesAsTexturesDirty;
  48988. /** @hidden */
  48989. _markAllSubMeshesAsTexturesDirty(): void;
  48990. /**
  48991. * Instantiate a new istance of sub surface configuration.
  48992. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48993. */
  48994. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48995. /**
  48996. * Gets wehter the submesh is ready to be used or not.
  48997. * @param defines the list of "defines" to update.
  48998. * @param scene defines the scene the material belongs to.
  48999. * @returns - boolean indicating that the submesh is ready or not.
  49000. */
  49001. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49002. /**
  49003. * Checks to see if a texture is used in the material.
  49004. * @param defines the list of "defines" to update.
  49005. * @param scene defines the scene to the material belongs to.
  49006. */
  49007. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49008. /**
  49009. * Binds the material data.
  49010. * @param uniformBuffer defines the Uniform buffer to fill in.
  49011. * @param scene defines the scene the material belongs to.
  49012. * @param engine defines the engine the material belongs to.
  49013. * @param isFrozen defines wether the material is frozen or not.
  49014. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49015. */
  49016. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49017. /**
  49018. * Unbinds the material from the mesh.
  49019. * @param activeEffect defines the effect that should be unbound from.
  49020. * @returns true if unbound, otherwise false
  49021. */
  49022. unbind(activeEffect: Effect): boolean;
  49023. /**
  49024. * Returns the texture used for refraction or null if none is used.
  49025. * @param scene defines the scene the material belongs to.
  49026. * @returns - Refraction texture if present. If no refraction texture and refraction
  49027. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49028. */
  49029. private _getRefractionTexture;
  49030. /**
  49031. * Returns true if alpha blending should be disabled.
  49032. */
  49033. readonly disableAlphaBlending: boolean;
  49034. /**
  49035. * Fills the list of render target textures.
  49036. * @param renderTargets the list of render targets to update
  49037. */
  49038. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49039. /**
  49040. * Checks to see if a texture is used in the material.
  49041. * @param texture - Base texture to use.
  49042. * @returns - Boolean specifying if a texture is used in the material.
  49043. */
  49044. hasTexture(texture: BaseTexture): boolean;
  49045. /**
  49046. * Gets a boolean indicating that current material needs to register RTT
  49047. * @returns true if this uses a render target otherwise false.
  49048. */
  49049. hasRenderTargetTextures(): boolean;
  49050. /**
  49051. * Returns an array of the actively used textures.
  49052. * @param activeTextures Array of BaseTextures
  49053. */
  49054. getActiveTextures(activeTextures: BaseTexture[]): void;
  49055. /**
  49056. * Returns the animatable textures.
  49057. * @param animatables Array of animatable textures.
  49058. */
  49059. getAnimatables(animatables: IAnimatable[]): void;
  49060. /**
  49061. * Disposes the resources of the material.
  49062. * @param forceDisposeTextures - Forces the disposal of all textures.
  49063. */
  49064. dispose(forceDisposeTextures?: boolean): void;
  49065. /**
  49066. * Get the current class name of the texture useful for serialization or dynamic coding.
  49067. * @returns "PBRSubSurfaceConfiguration"
  49068. */
  49069. getClassName(): string;
  49070. /**
  49071. * Add fallbacks to the effect fallbacks list.
  49072. * @param defines defines the Base texture to use.
  49073. * @param fallbacks defines the current fallback list.
  49074. * @param currentRank defines the current fallback rank.
  49075. * @returns the new fallback rank.
  49076. */
  49077. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49078. /**
  49079. * Add the required uniforms to the current list.
  49080. * @param uniforms defines the current uniform list.
  49081. */
  49082. static AddUniforms(uniforms: string[]): void;
  49083. /**
  49084. * Add the required samplers to the current list.
  49085. * @param samplers defines the current sampler list.
  49086. */
  49087. static AddSamplers(samplers: string[]): void;
  49088. /**
  49089. * Add the required uniforms to the current buffer.
  49090. * @param uniformBuffer defines the current uniform buffer.
  49091. */
  49092. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49093. /**
  49094. * Makes a duplicate of the current configuration into another one.
  49095. * @param configuration define the config where to copy the info
  49096. */
  49097. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49098. /**
  49099. * Serializes this Sub Surface configuration.
  49100. * @returns - An object with the serialized config.
  49101. */
  49102. serialize(): any;
  49103. /**
  49104. * Parses a anisotropy Configuration from a serialized object.
  49105. * @param source - Serialized object.
  49106. * @param scene Defines the scene we are parsing for
  49107. * @param rootUrl Defines the rootUrl to load from
  49108. */
  49109. parse(source: any, scene: Scene, rootUrl: string): void;
  49110. }
  49111. }
  49112. declare module BABYLON {
  49113. /** @hidden */
  49114. export var pbrFragmentDeclaration: {
  49115. name: string;
  49116. shader: string;
  49117. };
  49118. }
  49119. declare module BABYLON {
  49120. /** @hidden */
  49121. export var pbrUboDeclaration: {
  49122. name: string;
  49123. shader: string;
  49124. };
  49125. }
  49126. declare module BABYLON {
  49127. /** @hidden */
  49128. export var pbrFragmentExtraDeclaration: {
  49129. name: string;
  49130. shader: string;
  49131. };
  49132. }
  49133. declare module BABYLON {
  49134. /** @hidden */
  49135. export var pbrFragmentSamplersDeclaration: {
  49136. name: string;
  49137. shader: string;
  49138. };
  49139. }
  49140. declare module BABYLON {
  49141. /** @hidden */
  49142. export var pbrHelperFunctions: {
  49143. name: string;
  49144. shader: string;
  49145. };
  49146. }
  49147. declare module BABYLON {
  49148. /** @hidden */
  49149. export var harmonicsFunctions: {
  49150. name: string;
  49151. shader: string;
  49152. };
  49153. }
  49154. declare module BABYLON {
  49155. /** @hidden */
  49156. export var pbrDirectLightingSetupFunctions: {
  49157. name: string;
  49158. shader: string;
  49159. };
  49160. }
  49161. declare module BABYLON {
  49162. /** @hidden */
  49163. export var pbrDirectLightingFalloffFunctions: {
  49164. name: string;
  49165. shader: string;
  49166. };
  49167. }
  49168. declare module BABYLON {
  49169. /** @hidden */
  49170. export var pbrBRDFFunctions: {
  49171. name: string;
  49172. shader: string;
  49173. };
  49174. }
  49175. declare module BABYLON {
  49176. /** @hidden */
  49177. export var pbrDirectLightingFunctions: {
  49178. name: string;
  49179. shader: string;
  49180. };
  49181. }
  49182. declare module BABYLON {
  49183. /** @hidden */
  49184. export var pbrIBLFunctions: {
  49185. name: string;
  49186. shader: string;
  49187. };
  49188. }
  49189. declare module BABYLON {
  49190. /** @hidden */
  49191. export var pbrDebug: {
  49192. name: string;
  49193. shader: string;
  49194. };
  49195. }
  49196. declare module BABYLON {
  49197. /** @hidden */
  49198. export var pbrPixelShader: {
  49199. name: string;
  49200. shader: string;
  49201. };
  49202. }
  49203. declare module BABYLON {
  49204. /** @hidden */
  49205. export var pbrVertexDeclaration: {
  49206. name: string;
  49207. shader: string;
  49208. };
  49209. }
  49210. declare module BABYLON {
  49211. /** @hidden */
  49212. export var pbrVertexShader: {
  49213. name: string;
  49214. shader: string;
  49215. };
  49216. }
  49217. declare module BABYLON {
  49218. /**
  49219. * Manages the defines for the PBR Material.
  49220. * @hidden
  49221. */
  49222. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49223. PBR: boolean;
  49224. MAINUV1: boolean;
  49225. MAINUV2: boolean;
  49226. UV1: boolean;
  49227. UV2: boolean;
  49228. ALBEDO: boolean;
  49229. ALBEDODIRECTUV: number;
  49230. VERTEXCOLOR: boolean;
  49231. AMBIENT: boolean;
  49232. AMBIENTDIRECTUV: number;
  49233. AMBIENTINGRAYSCALE: boolean;
  49234. OPACITY: boolean;
  49235. VERTEXALPHA: boolean;
  49236. OPACITYDIRECTUV: number;
  49237. OPACITYRGB: boolean;
  49238. ALPHATEST: boolean;
  49239. DEPTHPREPASS: boolean;
  49240. ALPHABLEND: boolean;
  49241. ALPHAFROMALBEDO: boolean;
  49242. ALPHATESTVALUE: string;
  49243. SPECULAROVERALPHA: boolean;
  49244. RADIANCEOVERALPHA: boolean;
  49245. ALPHAFRESNEL: boolean;
  49246. LINEARALPHAFRESNEL: boolean;
  49247. PREMULTIPLYALPHA: boolean;
  49248. EMISSIVE: boolean;
  49249. EMISSIVEDIRECTUV: number;
  49250. REFLECTIVITY: boolean;
  49251. REFLECTIVITYDIRECTUV: number;
  49252. SPECULARTERM: boolean;
  49253. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49254. MICROSURFACEAUTOMATIC: boolean;
  49255. LODBASEDMICROSFURACE: boolean;
  49256. MICROSURFACEMAP: boolean;
  49257. MICROSURFACEMAPDIRECTUV: number;
  49258. METALLICWORKFLOW: boolean;
  49259. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49260. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49261. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49262. AOSTOREINMETALMAPRED: boolean;
  49263. METALLICF0FACTORFROMMETALLICMAP: boolean;
  49264. ENVIRONMENTBRDF: boolean;
  49265. ENVIRONMENTBRDF_RGBD: boolean;
  49266. NORMAL: boolean;
  49267. TANGENT: boolean;
  49268. BUMP: boolean;
  49269. BUMPDIRECTUV: number;
  49270. OBJECTSPACE_NORMALMAP: boolean;
  49271. PARALLAX: boolean;
  49272. PARALLAXOCCLUSION: boolean;
  49273. NORMALXYSCALE: boolean;
  49274. LIGHTMAP: boolean;
  49275. LIGHTMAPDIRECTUV: number;
  49276. USELIGHTMAPASSHADOWMAP: boolean;
  49277. GAMMALIGHTMAP: boolean;
  49278. RGBDLIGHTMAP: boolean;
  49279. REFLECTION: boolean;
  49280. REFLECTIONMAP_3D: boolean;
  49281. REFLECTIONMAP_SPHERICAL: boolean;
  49282. REFLECTIONMAP_PLANAR: boolean;
  49283. REFLECTIONMAP_CUBIC: boolean;
  49284. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49285. REFLECTIONMAP_PROJECTION: boolean;
  49286. REFLECTIONMAP_SKYBOX: boolean;
  49287. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49288. REFLECTIONMAP_EXPLICIT: boolean;
  49289. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49290. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49291. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49292. INVERTCUBICMAP: boolean;
  49293. USESPHERICALFROMREFLECTIONMAP: boolean;
  49294. USEIRRADIANCEMAP: boolean;
  49295. SPHERICAL_HARMONICS: boolean;
  49296. USESPHERICALINVERTEX: boolean;
  49297. REFLECTIONMAP_OPPOSITEZ: boolean;
  49298. LODINREFLECTIONALPHA: boolean;
  49299. GAMMAREFLECTION: boolean;
  49300. RGBDREFLECTION: boolean;
  49301. LINEARSPECULARREFLECTION: boolean;
  49302. RADIANCEOCCLUSION: boolean;
  49303. HORIZONOCCLUSION: boolean;
  49304. INSTANCES: boolean;
  49305. NUM_BONE_INFLUENCERS: number;
  49306. BonesPerMesh: number;
  49307. BONETEXTURE: boolean;
  49308. NONUNIFORMSCALING: boolean;
  49309. MORPHTARGETS: boolean;
  49310. MORPHTARGETS_NORMAL: boolean;
  49311. MORPHTARGETS_TANGENT: boolean;
  49312. MORPHTARGETS_UV: boolean;
  49313. NUM_MORPH_INFLUENCERS: number;
  49314. IMAGEPROCESSING: boolean;
  49315. VIGNETTE: boolean;
  49316. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49317. VIGNETTEBLENDMODEOPAQUE: boolean;
  49318. TONEMAPPING: boolean;
  49319. TONEMAPPING_ACES: boolean;
  49320. CONTRAST: boolean;
  49321. COLORCURVES: boolean;
  49322. COLORGRADING: boolean;
  49323. COLORGRADING3D: boolean;
  49324. SAMPLER3DGREENDEPTH: boolean;
  49325. SAMPLER3DBGRMAP: boolean;
  49326. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49327. EXPOSURE: boolean;
  49328. MULTIVIEW: boolean;
  49329. USEPHYSICALLIGHTFALLOFF: boolean;
  49330. USEGLTFLIGHTFALLOFF: boolean;
  49331. TWOSIDEDLIGHTING: boolean;
  49332. SHADOWFLOAT: boolean;
  49333. CLIPPLANE: boolean;
  49334. CLIPPLANE2: boolean;
  49335. CLIPPLANE3: boolean;
  49336. CLIPPLANE4: boolean;
  49337. POINTSIZE: boolean;
  49338. FOG: boolean;
  49339. LOGARITHMICDEPTH: boolean;
  49340. FORCENORMALFORWARD: boolean;
  49341. SPECULARAA: boolean;
  49342. CLEARCOAT: boolean;
  49343. CLEARCOAT_DEFAULTIOR: boolean;
  49344. CLEARCOAT_TEXTURE: boolean;
  49345. CLEARCOAT_TEXTUREDIRECTUV: number;
  49346. CLEARCOAT_BUMP: boolean;
  49347. CLEARCOAT_BUMPDIRECTUV: number;
  49348. CLEARCOAT_TINT: boolean;
  49349. CLEARCOAT_TINT_TEXTURE: boolean;
  49350. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49351. ANISOTROPIC: boolean;
  49352. ANISOTROPIC_TEXTURE: boolean;
  49353. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49354. BRDF_V_HEIGHT_CORRELATED: boolean;
  49355. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49356. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49357. SHEEN: boolean;
  49358. SHEEN_TEXTURE: boolean;
  49359. SHEEN_TEXTUREDIRECTUV: number;
  49360. SHEEN_LINKWITHALBEDO: boolean;
  49361. SUBSURFACE: boolean;
  49362. SS_REFRACTION: boolean;
  49363. SS_TRANSLUCENCY: boolean;
  49364. SS_SCATERRING: boolean;
  49365. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49366. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49367. SS_REFRACTIONMAP_3D: boolean;
  49368. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49369. SS_LODINREFRACTIONALPHA: boolean;
  49370. SS_GAMMAREFRACTION: boolean;
  49371. SS_RGBDREFRACTION: boolean;
  49372. SS_LINEARSPECULARREFRACTION: boolean;
  49373. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49374. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49375. UNLIT: boolean;
  49376. DEBUGMODE: number;
  49377. /**
  49378. * Initializes the PBR Material defines.
  49379. */
  49380. constructor();
  49381. /**
  49382. * Resets the PBR Material defines.
  49383. */
  49384. reset(): void;
  49385. }
  49386. /**
  49387. * The Physically based material base class of BJS.
  49388. *
  49389. * This offers the main features of a standard PBR material.
  49390. * For more information, please refer to the documentation :
  49391. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49392. */
  49393. export abstract class PBRBaseMaterial extends PushMaterial {
  49394. /**
  49395. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49396. */
  49397. static readonly PBRMATERIAL_OPAQUE: number;
  49398. /**
  49399. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49400. */
  49401. static readonly PBRMATERIAL_ALPHATEST: number;
  49402. /**
  49403. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49404. */
  49405. static readonly PBRMATERIAL_ALPHABLEND: number;
  49406. /**
  49407. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49408. * They are also discarded below the alpha cutoff threshold to improve performances.
  49409. */
  49410. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49411. /**
  49412. * Defines the default value of how much AO map is occluding the analytical lights
  49413. * (point spot...).
  49414. */
  49415. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49416. /**
  49417. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49418. */
  49419. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49420. /**
  49421. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49422. * to enhance interoperability with other engines.
  49423. */
  49424. static readonly LIGHTFALLOFF_GLTF: number;
  49425. /**
  49426. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49427. * to enhance interoperability with other materials.
  49428. */
  49429. static readonly LIGHTFALLOFF_STANDARD: number;
  49430. /**
  49431. * Intensity of the direct lights e.g. the four lights available in your scene.
  49432. * This impacts both the direct diffuse and specular highlights.
  49433. */
  49434. protected _directIntensity: number;
  49435. /**
  49436. * Intensity of the emissive part of the material.
  49437. * This helps controlling the emissive effect without modifying the emissive color.
  49438. */
  49439. protected _emissiveIntensity: number;
  49440. /**
  49441. * Intensity of the environment e.g. how much the environment will light the object
  49442. * either through harmonics for rough material or through the refelction for shiny ones.
  49443. */
  49444. protected _environmentIntensity: number;
  49445. /**
  49446. * This is a special control allowing the reduction of the specular highlights coming from the
  49447. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49448. */
  49449. protected _specularIntensity: number;
  49450. /**
  49451. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49452. */
  49453. private _lightingInfos;
  49454. /**
  49455. * Debug Control allowing disabling the bump map on this material.
  49456. */
  49457. protected _disableBumpMap: boolean;
  49458. /**
  49459. * AKA Diffuse Texture in standard nomenclature.
  49460. */
  49461. protected _albedoTexture: Nullable<BaseTexture>;
  49462. /**
  49463. * AKA Occlusion Texture in other nomenclature.
  49464. */
  49465. protected _ambientTexture: Nullable<BaseTexture>;
  49466. /**
  49467. * AKA Occlusion Texture Intensity in other nomenclature.
  49468. */
  49469. protected _ambientTextureStrength: number;
  49470. /**
  49471. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49472. * 1 means it completely occludes it
  49473. * 0 mean it has no impact
  49474. */
  49475. protected _ambientTextureImpactOnAnalyticalLights: number;
  49476. /**
  49477. * Stores the alpha values in a texture.
  49478. */
  49479. protected _opacityTexture: Nullable<BaseTexture>;
  49480. /**
  49481. * Stores the reflection values in a texture.
  49482. */
  49483. protected _reflectionTexture: Nullable<BaseTexture>;
  49484. /**
  49485. * Stores the emissive values in a texture.
  49486. */
  49487. protected _emissiveTexture: Nullable<BaseTexture>;
  49488. /**
  49489. * AKA Specular texture in other nomenclature.
  49490. */
  49491. protected _reflectivityTexture: Nullable<BaseTexture>;
  49492. /**
  49493. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49494. */
  49495. protected _metallicTexture: Nullable<BaseTexture>;
  49496. /**
  49497. * Specifies the metallic scalar of the metallic/roughness workflow.
  49498. * Can also be used to scale the metalness values of the metallic texture.
  49499. */
  49500. protected _metallic: Nullable<number>;
  49501. /**
  49502. * Specifies the roughness scalar of the metallic/roughness workflow.
  49503. * Can also be used to scale the roughness values of the metallic texture.
  49504. */
  49505. protected _roughness: Nullable<number>;
  49506. /**
  49507. * Specifies the an F0 factor to help configuring the material F0.
  49508. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  49509. * to 0.5 the previously hard coded value stays the same.
  49510. * Can also be used to scale the F0 values of the metallic texture.
  49511. */
  49512. protected _metallicF0Factor: number;
  49513. /**
  49514. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  49515. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  49516. * your expectation as it multiplies with the texture data.
  49517. */
  49518. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  49519. /**
  49520. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49521. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49522. */
  49523. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49524. /**
  49525. * Stores surface normal data used to displace a mesh in a texture.
  49526. */
  49527. protected _bumpTexture: Nullable<BaseTexture>;
  49528. /**
  49529. * Stores the pre-calculated light information of a mesh in a texture.
  49530. */
  49531. protected _lightmapTexture: Nullable<BaseTexture>;
  49532. /**
  49533. * The color of a material in ambient lighting.
  49534. */
  49535. protected _ambientColor: Color3;
  49536. /**
  49537. * AKA Diffuse Color in other nomenclature.
  49538. */
  49539. protected _albedoColor: Color3;
  49540. /**
  49541. * AKA Specular Color in other nomenclature.
  49542. */
  49543. protected _reflectivityColor: Color3;
  49544. /**
  49545. * The color applied when light is reflected from a material.
  49546. */
  49547. protected _reflectionColor: Color3;
  49548. /**
  49549. * The color applied when light is emitted from a material.
  49550. */
  49551. protected _emissiveColor: Color3;
  49552. /**
  49553. * AKA Glossiness in other nomenclature.
  49554. */
  49555. protected _microSurface: number;
  49556. /**
  49557. * Specifies that the material will use the light map as a show map.
  49558. */
  49559. protected _useLightmapAsShadowmap: boolean;
  49560. /**
  49561. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49562. * makes the reflect vector face the model (under horizon).
  49563. */
  49564. protected _useHorizonOcclusion: boolean;
  49565. /**
  49566. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49567. * too much the area relying on ambient texture to define their ambient occlusion.
  49568. */
  49569. protected _useRadianceOcclusion: boolean;
  49570. /**
  49571. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49572. */
  49573. protected _useAlphaFromAlbedoTexture: boolean;
  49574. /**
  49575. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49576. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49577. */
  49578. protected _useSpecularOverAlpha: boolean;
  49579. /**
  49580. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49581. */
  49582. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49583. /**
  49584. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49585. */
  49586. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49587. /**
  49588. * Specifies if the metallic texture contains the roughness information in its green channel.
  49589. */
  49590. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49591. /**
  49592. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49593. */
  49594. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49595. /**
  49596. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49597. */
  49598. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49599. /**
  49600. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49601. */
  49602. protected _useAmbientInGrayScale: boolean;
  49603. /**
  49604. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49605. * The material will try to infer what glossiness each pixel should be.
  49606. */
  49607. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49608. /**
  49609. * Defines the falloff type used in this material.
  49610. * It by default is Physical.
  49611. */
  49612. protected _lightFalloff: number;
  49613. /**
  49614. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49615. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49616. */
  49617. protected _useRadianceOverAlpha: boolean;
  49618. /**
  49619. * Allows using an object space normal map (instead of tangent space).
  49620. */
  49621. protected _useObjectSpaceNormalMap: boolean;
  49622. /**
  49623. * Allows using the bump map in parallax mode.
  49624. */
  49625. protected _useParallax: boolean;
  49626. /**
  49627. * Allows using the bump map in parallax occlusion mode.
  49628. */
  49629. protected _useParallaxOcclusion: boolean;
  49630. /**
  49631. * Controls the scale bias of the parallax mode.
  49632. */
  49633. protected _parallaxScaleBias: number;
  49634. /**
  49635. * If sets to true, disables all the lights affecting the material.
  49636. */
  49637. protected _disableLighting: boolean;
  49638. /**
  49639. * Number of Simultaneous lights allowed on the material.
  49640. */
  49641. protected _maxSimultaneousLights: number;
  49642. /**
  49643. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49644. */
  49645. protected _invertNormalMapX: boolean;
  49646. /**
  49647. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49648. */
  49649. protected _invertNormalMapY: boolean;
  49650. /**
  49651. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49652. */
  49653. protected _twoSidedLighting: boolean;
  49654. /**
  49655. * Defines the alpha limits in alpha test mode.
  49656. */
  49657. protected _alphaCutOff: number;
  49658. /**
  49659. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49660. */
  49661. protected _forceAlphaTest: boolean;
  49662. /**
  49663. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49664. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49665. */
  49666. protected _useAlphaFresnel: boolean;
  49667. /**
  49668. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49669. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49670. */
  49671. protected _useLinearAlphaFresnel: boolean;
  49672. /**
  49673. * The transparency mode of the material.
  49674. */
  49675. protected _transparencyMode: Nullable<number>;
  49676. /**
  49677. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49678. * from cos thetav and roughness:
  49679. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49680. */
  49681. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49682. /**
  49683. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49684. */
  49685. protected _forceIrradianceInFragment: boolean;
  49686. /**
  49687. * Force normal to face away from face.
  49688. */
  49689. protected _forceNormalForward: boolean;
  49690. /**
  49691. * Enables specular anti aliasing in the PBR shader.
  49692. * It will both interacts on the Geometry for analytical and IBL lighting.
  49693. * It also prefilter the roughness map based on the bump values.
  49694. */
  49695. protected _enableSpecularAntiAliasing: boolean;
  49696. /**
  49697. * Default configuration related to image processing available in the PBR Material.
  49698. */
  49699. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49700. /**
  49701. * Keep track of the image processing observer to allow dispose and replace.
  49702. */
  49703. private _imageProcessingObserver;
  49704. /**
  49705. * Attaches a new image processing configuration to the PBR Material.
  49706. * @param configuration
  49707. */
  49708. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49709. /**
  49710. * Stores the available render targets.
  49711. */
  49712. private _renderTargets;
  49713. /**
  49714. * Sets the global ambient color for the material used in lighting calculations.
  49715. */
  49716. private _globalAmbientColor;
  49717. /**
  49718. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49719. */
  49720. private _useLogarithmicDepth;
  49721. /**
  49722. * If set to true, no lighting calculations will be applied.
  49723. */
  49724. private _unlit;
  49725. private _debugMode;
  49726. /**
  49727. * @hidden
  49728. * This is reserved for the inspector.
  49729. * Defines the material debug mode.
  49730. * It helps seeing only some components of the material while troubleshooting.
  49731. */
  49732. debugMode: number;
  49733. /**
  49734. * @hidden
  49735. * This is reserved for the inspector.
  49736. * Specify from where on screen the debug mode should start.
  49737. * The value goes from -1 (full screen) to 1 (not visible)
  49738. * It helps with side by side comparison against the final render
  49739. * This defaults to -1
  49740. */
  49741. private debugLimit;
  49742. /**
  49743. * @hidden
  49744. * This is reserved for the inspector.
  49745. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49746. * You can use the factor to better multiply the final value.
  49747. */
  49748. private debugFactor;
  49749. /**
  49750. * Defines the clear coat layer parameters for the material.
  49751. */
  49752. readonly clearCoat: PBRClearCoatConfiguration;
  49753. /**
  49754. * Defines the anisotropic parameters for the material.
  49755. */
  49756. readonly anisotropy: PBRAnisotropicConfiguration;
  49757. /**
  49758. * Defines the BRDF parameters for the material.
  49759. */
  49760. readonly brdf: PBRBRDFConfiguration;
  49761. /**
  49762. * Defines the Sheen parameters for the material.
  49763. */
  49764. readonly sheen: PBRSheenConfiguration;
  49765. /**
  49766. * Defines the SubSurface parameters for the material.
  49767. */
  49768. readonly subSurface: PBRSubSurfaceConfiguration;
  49769. /**
  49770. * Custom callback helping to override the default shader used in the material.
  49771. */
  49772. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49773. protected _rebuildInParallel: boolean;
  49774. /**
  49775. * Instantiates a new PBRMaterial instance.
  49776. *
  49777. * @param name The material name
  49778. * @param scene The scene the material will be use in.
  49779. */
  49780. constructor(name: string, scene: Scene);
  49781. /**
  49782. * Gets a boolean indicating that current material needs to register RTT
  49783. */
  49784. readonly hasRenderTargetTextures: boolean;
  49785. /**
  49786. * Gets the name of the material class.
  49787. */
  49788. getClassName(): string;
  49789. /**
  49790. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49791. */
  49792. /**
  49793. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49794. */
  49795. useLogarithmicDepth: boolean;
  49796. /**
  49797. * Gets the current transparency mode.
  49798. */
  49799. /**
  49800. * Sets the transparency mode of the material.
  49801. *
  49802. * | Value | Type | Description |
  49803. * | ----- | ----------------------------------- | ----------- |
  49804. * | 0 | OPAQUE | |
  49805. * | 1 | ALPHATEST | |
  49806. * | 2 | ALPHABLEND | |
  49807. * | 3 | ALPHATESTANDBLEND | |
  49808. *
  49809. */
  49810. transparencyMode: Nullable<number>;
  49811. /**
  49812. * Returns true if alpha blending should be disabled.
  49813. */
  49814. private readonly _disableAlphaBlending;
  49815. /**
  49816. * Specifies whether or not this material should be rendered in alpha blend mode.
  49817. */
  49818. needAlphaBlending(): boolean;
  49819. /**
  49820. * Specifies if the mesh will require alpha blending.
  49821. * @param mesh - BJS mesh.
  49822. */
  49823. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49824. /**
  49825. * Specifies whether or not this material should be rendered in alpha test mode.
  49826. */
  49827. needAlphaTesting(): boolean;
  49828. /**
  49829. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49830. */
  49831. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49832. /**
  49833. * Gets the texture used for the alpha test.
  49834. */
  49835. getAlphaTestTexture(): Nullable<BaseTexture>;
  49836. /**
  49837. * Specifies that the submesh is ready to be used.
  49838. * @param mesh - BJS mesh.
  49839. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49840. * @param useInstances - Specifies that instances should be used.
  49841. * @returns - boolean indicating that the submesh is ready or not.
  49842. */
  49843. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49844. /**
  49845. * Specifies if the material uses metallic roughness workflow.
  49846. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49847. */
  49848. isMetallicWorkflow(): boolean;
  49849. private _prepareEffect;
  49850. private _prepareDefines;
  49851. /**
  49852. * Force shader compilation
  49853. */
  49854. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  49855. /**
  49856. * Initializes the uniform buffer layout for the shader.
  49857. */
  49858. buildUniformLayout(): void;
  49859. /**
  49860. * Unbinds the material from the mesh
  49861. */
  49862. unbind(): void;
  49863. /**
  49864. * Binds the submesh data.
  49865. * @param world - The world matrix.
  49866. * @param mesh - The BJS mesh.
  49867. * @param subMesh - A submesh of the BJS mesh.
  49868. */
  49869. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49870. /**
  49871. * Returns the animatable textures.
  49872. * @returns - Array of animatable textures.
  49873. */
  49874. getAnimatables(): IAnimatable[];
  49875. /**
  49876. * Returns the texture used for reflections.
  49877. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49878. */
  49879. private _getReflectionTexture;
  49880. /**
  49881. * Returns an array of the actively used textures.
  49882. * @returns - Array of BaseTextures
  49883. */
  49884. getActiveTextures(): BaseTexture[];
  49885. /**
  49886. * Checks to see if a texture is used in the material.
  49887. * @param texture - Base texture to use.
  49888. * @returns - Boolean specifying if a texture is used in the material.
  49889. */
  49890. hasTexture(texture: BaseTexture): boolean;
  49891. /**
  49892. * Disposes the resources of the material.
  49893. * @param forceDisposeEffect - Forces the disposal of effects.
  49894. * @param forceDisposeTextures - Forces the disposal of all textures.
  49895. */
  49896. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49897. }
  49898. }
  49899. declare module BABYLON {
  49900. /**
  49901. * The Physically based material of BJS.
  49902. *
  49903. * This offers the main features of a standard PBR material.
  49904. * For more information, please refer to the documentation :
  49905. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49906. */
  49907. export class PBRMaterial extends PBRBaseMaterial {
  49908. /**
  49909. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49910. */
  49911. static readonly PBRMATERIAL_OPAQUE: number;
  49912. /**
  49913. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49914. */
  49915. static readonly PBRMATERIAL_ALPHATEST: number;
  49916. /**
  49917. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49918. */
  49919. static readonly PBRMATERIAL_ALPHABLEND: number;
  49920. /**
  49921. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49922. * They are also discarded below the alpha cutoff threshold to improve performances.
  49923. */
  49924. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49925. /**
  49926. * Defines the default value of how much AO map is occluding the analytical lights
  49927. * (point spot...).
  49928. */
  49929. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49930. /**
  49931. * Intensity of the direct lights e.g. the four lights available in your scene.
  49932. * This impacts both the direct diffuse and specular highlights.
  49933. */
  49934. directIntensity: number;
  49935. /**
  49936. * Intensity of the emissive part of the material.
  49937. * This helps controlling the emissive effect without modifying the emissive color.
  49938. */
  49939. emissiveIntensity: number;
  49940. /**
  49941. * Intensity of the environment e.g. how much the environment will light the object
  49942. * either through harmonics for rough material or through the refelction for shiny ones.
  49943. */
  49944. environmentIntensity: number;
  49945. /**
  49946. * This is a special control allowing the reduction of the specular highlights coming from the
  49947. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49948. */
  49949. specularIntensity: number;
  49950. /**
  49951. * Debug Control allowing disabling the bump map on this material.
  49952. */
  49953. disableBumpMap: boolean;
  49954. /**
  49955. * AKA Diffuse Texture in standard nomenclature.
  49956. */
  49957. albedoTexture: BaseTexture;
  49958. /**
  49959. * AKA Occlusion Texture in other nomenclature.
  49960. */
  49961. ambientTexture: BaseTexture;
  49962. /**
  49963. * AKA Occlusion Texture Intensity in other nomenclature.
  49964. */
  49965. ambientTextureStrength: number;
  49966. /**
  49967. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49968. * 1 means it completely occludes it
  49969. * 0 mean it has no impact
  49970. */
  49971. ambientTextureImpactOnAnalyticalLights: number;
  49972. /**
  49973. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  49974. */
  49975. opacityTexture: BaseTexture;
  49976. /**
  49977. * Stores the reflection values in a texture.
  49978. */
  49979. reflectionTexture: Nullable<BaseTexture>;
  49980. /**
  49981. * Stores the emissive values in a texture.
  49982. */
  49983. emissiveTexture: BaseTexture;
  49984. /**
  49985. * AKA Specular texture in other nomenclature.
  49986. */
  49987. reflectivityTexture: BaseTexture;
  49988. /**
  49989. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49990. */
  49991. metallicTexture: BaseTexture;
  49992. /**
  49993. * Specifies the metallic scalar of the metallic/roughness workflow.
  49994. * Can also be used to scale the metalness values of the metallic texture.
  49995. */
  49996. metallic: Nullable<number>;
  49997. /**
  49998. * Specifies the roughness scalar of the metallic/roughness workflow.
  49999. * Can also be used to scale the roughness values of the metallic texture.
  50000. */
  50001. roughness: Nullable<number>;
  50002. /**
  50003. * Specifies the an F0 factor to help configuring the material F0.
  50004. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50005. * to 0.5 the previously hard coded value stays the same.
  50006. * Can also be used to scale the F0 values of the metallic texture.
  50007. */
  50008. metallicF0Factor: number;
  50009. /**
  50010. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50011. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50012. * your expectation as it multiplies with the texture data.
  50013. */
  50014. useMetallicF0FactorFromMetallicTexture: boolean;
  50015. /**
  50016. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50017. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50018. */
  50019. microSurfaceTexture: BaseTexture;
  50020. /**
  50021. * Stores surface normal data used to displace a mesh in a texture.
  50022. */
  50023. bumpTexture: BaseTexture;
  50024. /**
  50025. * Stores the pre-calculated light information of a mesh in a texture.
  50026. */
  50027. lightmapTexture: BaseTexture;
  50028. /**
  50029. * Stores the refracted light information in a texture.
  50030. */
  50031. refractionTexture: Nullable<BaseTexture>;
  50032. /**
  50033. * The color of a material in ambient lighting.
  50034. */
  50035. ambientColor: Color3;
  50036. /**
  50037. * AKA Diffuse Color in other nomenclature.
  50038. */
  50039. albedoColor: Color3;
  50040. /**
  50041. * AKA Specular Color in other nomenclature.
  50042. */
  50043. reflectivityColor: Color3;
  50044. /**
  50045. * The color reflected from the material.
  50046. */
  50047. reflectionColor: Color3;
  50048. /**
  50049. * The color emitted from the material.
  50050. */
  50051. emissiveColor: Color3;
  50052. /**
  50053. * AKA Glossiness in other nomenclature.
  50054. */
  50055. microSurface: number;
  50056. /**
  50057. * source material index of refraction (IOR)' / 'destination material IOR.
  50058. */
  50059. indexOfRefraction: number;
  50060. /**
  50061. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50062. */
  50063. invertRefractionY: boolean;
  50064. /**
  50065. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50066. * Materials half opaque for instance using refraction could benefit from this control.
  50067. */
  50068. linkRefractionWithTransparency: boolean;
  50069. /**
  50070. * If true, the light map contains occlusion information instead of lighting info.
  50071. */
  50072. useLightmapAsShadowmap: boolean;
  50073. /**
  50074. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50075. */
  50076. useAlphaFromAlbedoTexture: boolean;
  50077. /**
  50078. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50079. */
  50080. forceAlphaTest: boolean;
  50081. /**
  50082. * Defines the alpha limits in alpha test mode.
  50083. */
  50084. alphaCutOff: number;
  50085. /**
  50086. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50087. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50088. */
  50089. useSpecularOverAlpha: boolean;
  50090. /**
  50091. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50092. */
  50093. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50094. /**
  50095. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50096. */
  50097. useRoughnessFromMetallicTextureAlpha: boolean;
  50098. /**
  50099. * Specifies if the metallic texture contains the roughness information in its green channel.
  50100. */
  50101. useRoughnessFromMetallicTextureGreen: boolean;
  50102. /**
  50103. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50104. */
  50105. useMetallnessFromMetallicTextureBlue: boolean;
  50106. /**
  50107. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50108. */
  50109. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50110. /**
  50111. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50112. */
  50113. useAmbientInGrayScale: boolean;
  50114. /**
  50115. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50116. * The material will try to infer what glossiness each pixel should be.
  50117. */
  50118. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50119. /**
  50120. * BJS is using an harcoded light falloff based on a manually sets up range.
  50121. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50122. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50123. */
  50124. /**
  50125. * BJS is using an harcoded light falloff based on a manually sets up range.
  50126. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50127. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50128. */
  50129. usePhysicalLightFalloff: boolean;
  50130. /**
  50131. * In order to support the falloff compatibility with gltf, a special mode has been added
  50132. * to reproduce the gltf light falloff.
  50133. */
  50134. /**
  50135. * In order to support the falloff compatibility with gltf, a special mode has been added
  50136. * to reproduce the gltf light falloff.
  50137. */
  50138. useGLTFLightFalloff: boolean;
  50139. /**
  50140. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50141. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50142. */
  50143. useRadianceOverAlpha: boolean;
  50144. /**
  50145. * Allows using an object space normal map (instead of tangent space).
  50146. */
  50147. useObjectSpaceNormalMap: boolean;
  50148. /**
  50149. * Allows using the bump map in parallax mode.
  50150. */
  50151. useParallax: boolean;
  50152. /**
  50153. * Allows using the bump map in parallax occlusion mode.
  50154. */
  50155. useParallaxOcclusion: boolean;
  50156. /**
  50157. * Controls the scale bias of the parallax mode.
  50158. */
  50159. parallaxScaleBias: number;
  50160. /**
  50161. * If sets to true, disables all the lights affecting the material.
  50162. */
  50163. disableLighting: boolean;
  50164. /**
  50165. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50166. */
  50167. forceIrradianceInFragment: boolean;
  50168. /**
  50169. * Number of Simultaneous lights allowed on the material.
  50170. */
  50171. maxSimultaneousLights: number;
  50172. /**
  50173. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50174. */
  50175. invertNormalMapX: boolean;
  50176. /**
  50177. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50178. */
  50179. invertNormalMapY: boolean;
  50180. /**
  50181. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50182. */
  50183. twoSidedLighting: boolean;
  50184. /**
  50185. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50186. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50187. */
  50188. useAlphaFresnel: boolean;
  50189. /**
  50190. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50191. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50192. */
  50193. useLinearAlphaFresnel: boolean;
  50194. /**
  50195. * Let user defines the brdf lookup texture used for IBL.
  50196. * A default 8bit version is embedded but you could point at :
  50197. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50198. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50199. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50200. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50201. */
  50202. environmentBRDFTexture: Nullable<BaseTexture>;
  50203. /**
  50204. * Force normal to face away from face.
  50205. */
  50206. forceNormalForward: boolean;
  50207. /**
  50208. * Enables specular anti aliasing in the PBR shader.
  50209. * It will both interacts on the Geometry for analytical and IBL lighting.
  50210. * It also prefilter the roughness map based on the bump values.
  50211. */
  50212. enableSpecularAntiAliasing: boolean;
  50213. /**
  50214. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50215. * makes the reflect vector face the model (under horizon).
  50216. */
  50217. useHorizonOcclusion: boolean;
  50218. /**
  50219. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50220. * too much the area relying on ambient texture to define their ambient occlusion.
  50221. */
  50222. useRadianceOcclusion: boolean;
  50223. /**
  50224. * If set to true, no lighting calculations will be applied.
  50225. */
  50226. unlit: boolean;
  50227. /**
  50228. * Gets the image processing configuration used either in this material.
  50229. */
  50230. /**
  50231. * Sets the Default image processing configuration used either in the this material.
  50232. *
  50233. * If sets to null, the scene one is in use.
  50234. */
  50235. imageProcessingConfiguration: ImageProcessingConfiguration;
  50236. /**
  50237. * Gets wether the color curves effect is enabled.
  50238. */
  50239. /**
  50240. * Sets wether the color curves effect is enabled.
  50241. */
  50242. cameraColorCurvesEnabled: boolean;
  50243. /**
  50244. * Gets wether the color grading effect is enabled.
  50245. */
  50246. /**
  50247. * Gets wether the color grading effect is enabled.
  50248. */
  50249. cameraColorGradingEnabled: boolean;
  50250. /**
  50251. * Gets wether tonemapping is enabled or not.
  50252. */
  50253. /**
  50254. * Sets wether tonemapping is enabled or not
  50255. */
  50256. cameraToneMappingEnabled: boolean;
  50257. /**
  50258. * The camera exposure used on this material.
  50259. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50260. * This corresponds to a photographic exposure.
  50261. */
  50262. /**
  50263. * The camera exposure used on this material.
  50264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50265. * This corresponds to a photographic exposure.
  50266. */
  50267. cameraExposure: number;
  50268. /**
  50269. * Gets The camera contrast used on this material.
  50270. */
  50271. /**
  50272. * Sets The camera contrast used on this material.
  50273. */
  50274. cameraContrast: number;
  50275. /**
  50276. * Gets the Color Grading 2D Lookup Texture.
  50277. */
  50278. /**
  50279. * Sets the Color Grading 2D Lookup Texture.
  50280. */
  50281. cameraColorGradingTexture: Nullable<BaseTexture>;
  50282. /**
  50283. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50284. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50285. * 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;
  50286. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50287. */
  50288. /**
  50289. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50290. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50291. * 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;
  50292. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50293. */
  50294. cameraColorCurves: Nullable<ColorCurves>;
  50295. /**
  50296. * Instantiates a new PBRMaterial instance.
  50297. *
  50298. * @param name The material name
  50299. * @param scene The scene the material will be use in.
  50300. */
  50301. constructor(name: string, scene: Scene);
  50302. /**
  50303. * Returns the name of this material class.
  50304. */
  50305. getClassName(): string;
  50306. /**
  50307. * Makes a duplicate of the current material.
  50308. * @param name - name to use for the new material.
  50309. */
  50310. clone(name: string): PBRMaterial;
  50311. /**
  50312. * Serializes this PBR Material.
  50313. * @returns - An object with the serialized material.
  50314. */
  50315. serialize(): any;
  50316. /**
  50317. * Parses a PBR Material from a serialized object.
  50318. * @param source - Serialized object.
  50319. * @param scene - BJS scene instance.
  50320. * @param rootUrl - url for the scene object
  50321. * @returns - PBRMaterial
  50322. */
  50323. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50324. }
  50325. }
  50326. declare module BABYLON {
  50327. /**
  50328. * Direct draw surface info
  50329. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50330. */
  50331. export interface DDSInfo {
  50332. /**
  50333. * Width of the texture
  50334. */
  50335. width: number;
  50336. /**
  50337. * Width of the texture
  50338. */
  50339. height: number;
  50340. /**
  50341. * Number of Mipmaps for the texture
  50342. * @see https://en.wikipedia.org/wiki/Mipmap
  50343. */
  50344. mipmapCount: number;
  50345. /**
  50346. * If the textures format is a known fourCC format
  50347. * @see https://www.fourcc.org/
  50348. */
  50349. isFourCC: boolean;
  50350. /**
  50351. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50352. */
  50353. isRGB: boolean;
  50354. /**
  50355. * If the texture is a lumincance format
  50356. */
  50357. isLuminance: boolean;
  50358. /**
  50359. * If this is a cube texture
  50360. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50361. */
  50362. isCube: boolean;
  50363. /**
  50364. * If the texture is a compressed format eg. FOURCC_DXT1
  50365. */
  50366. isCompressed: boolean;
  50367. /**
  50368. * The dxgiFormat of the texture
  50369. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50370. */
  50371. dxgiFormat: number;
  50372. /**
  50373. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50374. */
  50375. textureType: number;
  50376. /**
  50377. * Sphericle polynomial created for the dds texture
  50378. */
  50379. sphericalPolynomial?: SphericalPolynomial;
  50380. }
  50381. /**
  50382. * Class used to provide DDS decompression tools
  50383. */
  50384. export class DDSTools {
  50385. /**
  50386. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50387. */
  50388. static StoreLODInAlphaChannel: boolean;
  50389. /**
  50390. * Gets DDS information from an array buffer
  50391. * @param arrayBuffer defines the array buffer to read data from
  50392. * @returns the DDS information
  50393. */
  50394. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50395. private static _FloatView;
  50396. private static _Int32View;
  50397. private static _ToHalfFloat;
  50398. private static _FromHalfFloat;
  50399. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50400. private static _GetHalfFloatRGBAArrayBuffer;
  50401. private static _GetFloatRGBAArrayBuffer;
  50402. private static _GetFloatAsUIntRGBAArrayBuffer;
  50403. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50404. private static _GetRGBAArrayBuffer;
  50405. private static _ExtractLongWordOrder;
  50406. private static _GetRGBArrayBuffer;
  50407. private static _GetLuminanceArrayBuffer;
  50408. /**
  50409. * Uploads DDS Levels to a Babylon Texture
  50410. * @hidden
  50411. */
  50412. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50413. }
  50414. interface ThinEngine {
  50415. /**
  50416. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50417. * @param rootUrl defines the url where the file to load is located
  50418. * @param scene defines the current scene
  50419. * @param lodScale defines scale to apply to the mip map selection
  50420. * @param lodOffset defines offset to apply to the mip map selection
  50421. * @param onLoad defines an optional callback raised when the texture is loaded
  50422. * @param onError defines an optional callback raised if there is an issue to load the texture
  50423. * @param format defines the format of the data
  50424. * @param forcedExtension defines the extension to use to pick the right loader
  50425. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50426. * @returns the cube texture as an InternalTexture
  50427. */
  50428. 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;
  50429. }
  50430. }
  50431. declare module BABYLON {
  50432. /**
  50433. * Implementation of the DDS Texture Loader.
  50434. * @hidden
  50435. */
  50436. export class _DDSTextureLoader implements IInternalTextureLoader {
  50437. /**
  50438. * Defines wether the loader supports cascade loading the different faces.
  50439. */
  50440. readonly supportCascades: boolean;
  50441. /**
  50442. * This returns if the loader support the current file information.
  50443. * @param extension defines the file extension of the file being loaded
  50444. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50445. * @param fallback defines the fallback internal texture if any
  50446. * @param isBase64 defines whether the texture is encoded as a base64
  50447. * @param isBuffer defines whether the texture data are stored as a buffer
  50448. * @returns true if the loader can load the specified file
  50449. */
  50450. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50451. /**
  50452. * Transform the url before loading if required.
  50453. * @param rootUrl the url of the texture
  50454. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50455. * @returns the transformed texture
  50456. */
  50457. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50458. /**
  50459. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50460. * @param rootUrl the url of the texture
  50461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50462. * @returns the fallback texture
  50463. */
  50464. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50465. /**
  50466. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50467. * @param data contains the texture data
  50468. * @param texture defines the BabylonJS internal texture
  50469. * @param createPolynomials will be true if polynomials have been requested
  50470. * @param onLoad defines the callback to trigger once the texture is ready
  50471. * @param onError defines the callback to trigger in case of error
  50472. */
  50473. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50474. /**
  50475. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50476. * @param data contains the texture data
  50477. * @param texture defines the BabylonJS internal texture
  50478. * @param callback defines the method to call once ready to upload
  50479. */
  50480. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50481. }
  50482. }
  50483. declare module BABYLON {
  50484. /**
  50485. * Implementation of the ENV Texture Loader.
  50486. * @hidden
  50487. */
  50488. export class _ENVTextureLoader implements IInternalTextureLoader {
  50489. /**
  50490. * Defines wether the loader supports cascade loading the different faces.
  50491. */
  50492. readonly supportCascades: boolean;
  50493. /**
  50494. * This returns if the loader support the current file information.
  50495. * @param extension defines the file extension of the file being loaded
  50496. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50497. * @param fallback defines the fallback internal texture if any
  50498. * @param isBase64 defines whether the texture is encoded as a base64
  50499. * @param isBuffer defines whether the texture data are stored as a buffer
  50500. * @returns true if the loader can load the specified file
  50501. */
  50502. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50503. /**
  50504. * Transform the url before loading if required.
  50505. * @param rootUrl the url of the texture
  50506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50507. * @returns the transformed texture
  50508. */
  50509. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50510. /**
  50511. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50512. * @param rootUrl the url of the texture
  50513. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50514. * @returns the fallback texture
  50515. */
  50516. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50517. /**
  50518. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50519. * @param data contains the texture data
  50520. * @param texture defines the BabylonJS internal texture
  50521. * @param createPolynomials will be true if polynomials have been requested
  50522. * @param onLoad defines the callback to trigger once the texture is ready
  50523. * @param onError defines the callback to trigger in case of error
  50524. */
  50525. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50526. /**
  50527. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50528. * @param data contains the texture data
  50529. * @param texture defines the BabylonJS internal texture
  50530. * @param callback defines the method to call once ready to upload
  50531. */
  50532. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50533. }
  50534. }
  50535. declare module BABYLON {
  50536. /**
  50537. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50538. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50539. */
  50540. export class KhronosTextureContainer {
  50541. /** contents of the KTX container file */
  50542. arrayBuffer: any;
  50543. private static HEADER_LEN;
  50544. private static COMPRESSED_2D;
  50545. private static COMPRESSED_3D;
  50546. private static TEX_2D;
  50547. private static TEX_3D;
  50548. /**
  50549. * Gets the openGL type
  50550. */
  50551. glType: number;
  50552. /**
  50553. * Gets the openGL type size
  50554. */
  50555. glTypeSize: number;
  50556. /**
  50557. * Gets the openGL format
  50558. */
  50559. glFormat: number;
  50560. /**
  50561. * Gets the openGL internal format
  50562. */
  50563. glInternalFormat: number;
  50564. /**
  50565. * Gets the base internal format
  50566. */
  50567. glBaseInternalFormat: number;
  50568. /**
  50569. * Gets image width in pixel
  50570. */
  50571. pixelWidth: number;
  50572. /**
  50573. * Gets image height in pixel
  50574. */
  50575. pixelHeight: number;
  50576. /**
  50577. * Gets image depth in pixels
  50578. */
  50579. pixelDepth: number;
  50580. /**
  50581. * Gets the number of array elements
  50582. */
  50583. numberOfArrayElements: number;
  50584. /**
  50585. * Gets the number of faces
  50586. */
  50587. numberOfFaces: number;
  50588. /**
  50589. * Gets the number of mipmap levels
  50590. */
  50591. numberOfMipmapLevels: number;
  50592. /**
  50593. * Gets the bytes of key value data
  50594. */
  50595. bytesOfKeyValueData: number;
  50596. /**
  50597. * Gets the load type
  50598. */
  50599. loadType: number;
  50600. /**
  50601. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50602. */
  50603. isInvalid: boolean;
  50604. /**
  50605. * Creates a new KhronosTextureContainer
  50606. * @param arrayBuffer contents of the KTX container file
  50607. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50608. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50609. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50610. */
  50611. constructor(
  50612. /** contents of the KTX container file */
  50613. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50614. /**
  50615. * Uploads KTX content to a Babylon Texture.
  50616. * It is assumed that the texture has already been created & is currently bound
  50617. * @hidden
  50618. */
  50619. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50620. private _upload2DCompressedLevels;
  50621. }
  50622. }
  50623. declare module BABYLON {
  50624. /**
  50625. * Implementation of the KTX Texture Loader.
  50626. * @hidden
  50627. */
  50628. export class _KTXTextureLoader implements IInternalTextureLoader {
  50629. /**
  50630. * Defines wether the loader supports cascade loading the different faces.
  50631. */
  50632. readonly supportCascades: boolean;
  50633. /**
  50634. * This returns if the loader support the current file information.
  50635. * @param extension defines the file extension of the file being loaded
  50636. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50637. * @param fallback defines the fallback internal texture if any
  50638. * @param isBase64 defines whether the texture is encoded as a base64
  50639. * @param isBuffer defines whether the texture data are stored as a buffer
  50640. * @returns true if the loader can load the specified file
  50641. */
  50642. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50643. /**
  50644. * Transform the url before loading if required.
  50645. * @param rootUrl the url of the texture
  50646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50647. * @returns the transformed texture
  50648. */
  50649. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50650. /**
  50651. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50652. * @param rootUrl the url of the texture
  50653. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50654. * @returns the fallback texture
  50655. */
  50656. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50657. /**
  50658. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50659. * @param data contains the texture data
  50660. * @param texture defines the BabylonJS internal texture
  50661. * @param createPolynomials will be true if polynomials have been requested
  50662. * @param onLoad defines the callback to trigger once the texture is ready
  50663. * @param onError defines the callback to trigger in case of error
  50664. */
  50665. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50666. /**
  50667. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50668. * @param data contains the texture data
  50669. * @param texture defines the BabylonJS internal texture
  50670. * @param callback defines the method to call once ready to upload
  50671. */
  50672. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50673. }
  50674. }
  50675. declare module BABYLON {
  50676. /** @hidden */
  50677. export var _forceSceneHelpersToBundle: boolean;
  50678. interface Scene {
  50679. /**
  50680. * Creates a default light for the scene.
  50681. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50682. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50683. */
  50684. createDefaultLight(replace?: boolean): void;
  50685. /**
  50686. * Creates a default camera for the scene.
  50687. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50688. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50689. * @param replace has default false, when true replaces the active camera in the scene
  50690. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50691. */
  50692. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50693. /**
  50694. * Creates a default camera and a default light.
  50695. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50696. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50697. * @param replace has the default false, when true replaces the active camera/light in the scene
  50698. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50699. */
  50700. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50701. /**
  50702. * Creates a new sky box
  50703. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50704. * @param environmentTexture defines the texture to use as environment texture
  50705. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50706. * @param scale defines the overall scale of the skybox
  50707. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50708. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50709. * @returns a new mesh holding the sky box
  50710. */
  50711. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50712. /**
  50713. * Creates a new environment
  50714. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50715. * @param options defines the options you can use to configure the environment
  50716. * @returns the new EnvironmentHelper
  50717. */
  50718. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50719. /**
  50720. * Creates a new VREXperienceHelper
  50721. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50722. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50723. * @returns a new VREXperienceHelper
  50724. */
  50725. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50726. /**
  50727. * Creates a new WebXRDefaultExperience
  50728. * @see http://doc.babylonjs.com/how_to/webxr
  50729. * @param options experience options
  50730. * @returns a promise for a new WebXRDefaultExperience
  50731. */
  50732. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50733. }
  50734. }
  50735. declare module BABYLON {
  50736. /**
  50737. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50738. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50739. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50740. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50741. */
  50742. export class VideoDome extends TransformNode {
  50743. /**
  50744. * Define the video source as a Monoscopic panoramic 360 video.
  50745. */
  50746. static readonly MODE_MONOSCOPIC: number;
  50747. /**
  50748. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50749. */
  50750. static readonly MODE_TOPBOTTOM: number;
  50751. /**
  50752. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50753. */
  50754. static readonly MODE_SIDEBYSIDE: number;
  50755. private _halfDome;
  50756. private _useDirectMapping;
  50757. /**
  50758. * The video texture being displayed on the sphere
  50759. */
  50760. protected _videoTexture: VideoTexture;
  50761. /**
  50762. * Gets the video texture being displayed on the sphere
  50763. */
  50764. readonly videoTexture: VideoTexture;
  50765. /**
  50766. * The skybox material
  50767. */
  50768. protected _material: BackgroundMaterial;
  50769. /**
  50770. * The surface used for the skybox
  50771. */
  50772. protected _mesh: Mesh;
  50773. /**
  50774. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50775. */
  50776. private _halfDomeMask;
  50777. /**
  50778. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50779. * Also see the options.resolution property.
  50780. */
  50781. fovMultiplier: number;
  50782. private _videoMode;
  50783. /**
  50784. * Gets or set the current video mode for the video. It can be:
  50785. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50786. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50787. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50788. */
  50789. videoMode: number;
  50790. /**
  50791. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50792. *
  50793. */
  50794. /**
  50795. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50796. */
  50797. halfDome: boolean;
  50798. /**
  50799. * Oberserver used in Stereoscopic VR Mode.
  50800. */
  50801. private _onBeforeCameraRenderObserver;
  50802. /**
  50803. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50804. * @param name Element's name, child elements will append suffixes for their own names.
  50805. * @param urlsOrVideo defines the url(s) or the video element to use
  50806. * @param options An object containing optional or exposed sub element properties
  50807. */
  50808. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50809. resolution?: number;
  50810. clickToPlay?: boolean;
  50811. autoPlay?: boolean;
  50812. loop?: boolean;
  50813. size?: number;
  50814. poster?: string;
  50815. faceForward?: boolean;
  50816. useDirectMapping?: boolean;
  50817. halfDomeMode?: boolean;
  50818. }, scene: Scene);
  50819. private _changeVideoMode;
  50820. /**
  50821. * Releases resources associated with this node.
  50822. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50823. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50824. */
  50825. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50826. }
  50827. }
  50828. declare module BABYLON {
  50829. /**
  50830. * This class can be used to get instrumentation data from a Babylon engine
  50831. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50832. */
  50833. export class EngineInstrumentation implements IDisposable {
  50834. /**
  50835. * Define the instrumented engine.
  50836. */
  50837. engine: Engine;
  50838. private _captureGPUFrameTime;
  50839. private _gpuFrameTimeToken;
  50840. private _gpuFrameTime;
  50841. private _captureShaderCompilationTime;
  50842. private _shaderCompilationTime;
  50843. private _onBeginFrameObserver;
  50844. private _onEndFrameObserver;
  50845. private _onBeforeShaderCompilationObserver;
  50846. private _onAfterShaderCompilationObserver;
  50847. /**
  50848. * Gets the perf counter used for GPU frame time
  50849. */
  50850. readonly gpuFrameTimeCounter: PerfCounter;
  50851. /**
  50852. * Gets the GPU frame time capture status
  50853. */
  50854. /**
  50855. * Enable or disable the GPU frame time capture
  50856. */
  50857. captureGPUFrameTime: boolean;
  50858. /**
  50859. * Gets the perf counter used for shader compilation time
  50860. */
  50861. readonly shaderCompilationTimeCounter: PerfCounter;
  50862. /**
  50863. * Gets the shader compilation time capture status
  50864. */
  50865. /**
  50866. * Enable or disable the shader compilation time capture
  50867. */
  50868. captureShaderCompilationTime: boolean;
  50869. /**
  50870. * Instantiates a new engine instrumentation.
  50871. * This class can be used to get instrumentation data from a Babylon engine
  50872. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50873. * @param engine Defines the engine to instrument
  50874. */
  50875. constructor(
  50876. /**
  50877. * Define the instrumented engine.
  50878. */
  50879. engine: Engine);
  50880. /**
  50881. * Dispose and release associated resources.
  50882. */
  50883. dispose(): void;
  50884. }
  50885. }
  50886. declare module BABYLON {
  50887. /**
  50888. * This class can be used to get instrumentation data from a Babylon engine
  50889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50890. */
  50891. export class SceneInstrumentation implements IDisposable {
  50892. /**
  50893. * Defines the scene to instrument
  50894. */
  50895. scene: Scene;
  50896. private _captureActiveMeshesEvaluationTime;
  50897. private _activeMeshesEvaluationTime;
  50898. private _captureRenderTargetsRenderTime;
  50899. private _renderTargetsRenderTime;
  50900. private _captureFrameTime;
  50901. private _frameTime;
  50902. private _captureRenderTime;
  50903. private _renderTime;
  50904. private _captureInterFrameTime;
  50905. private _interFrameTime;
  50906. private _captureParticlesRenderTime;
  50907. private _particlesRenderTime;
  50908. private _captureSpritesRenderTime;
  50909. private _spritesRenderTime;
  50910. private _capturePhysicsTime;
  50911. private _physicsTime;
  50912. private _captureAnimationsTime;
  50913. private _animationsTime;
  50914. private _captureCameraRenderTime;
  50915. private _cameraRenderTime;
  50916. private _onBeforeActiveMeshesEvaluationObserver;
  50917. private _onAfterActiveMeshesEvaluationObserver;
  50918. private _onBeforeRenderTargetsRenderObserver;
  50919. private _onAfterRenderTargetsRenderObserver;
  50920. private _onAfterRenderObserver;
  50921. private _onBeforeDrawPhaseObserver;
  50922. private _onAfterDrawPhaseObserver;
  50923. private _onBeforeAnimationsObserver;
  50924. private _onBeforeParticlesRenderingObserver;
  50925. private _onAfterParticlesRenderingObserver;
  50926. private _onBeforeSpritesRenderingObserver;
  50927. private _onAfterSpritesRenderingObserver;
  50928. private _onBeforePhysicsObserver;
  50929. private _onAfterPhysicsObserver;
  50930. private _onAfterAnimationsObserver;
  50931. private _onBeforeCameraRenderObserver;
  50932. private _onAfterCameraRenderObserver;
  50933. /**
  50934. * Gets the perf counter used for active meshes evaluation time
  50935. */
  50936. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50937. /**
  50938. * Gets the active meshes evaluation time capture status
  50939. */
  50940. /**
  50941. * Enable or disable the active meshes evaluation time capture
  50942. */
  50943. captureActiveMeshesEvaluationTime: boolean;
  50944. /**
  50945. * Gets the perf counter used for render targets render time
  50946. */
  50947. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50948. /**
  50949. * Gets the render targets render time capture status
  50950. */
  50951. /**
  50952. * Enable or disable the render targets render time capture
  50953. */
  50954. captureRenderTargetsRenderTime: boolean;
  50955. /**
  50956. * Gets the perf counter used for particles render time
  50957. */
  50958. readonly particlesRenderTimeCounter: PerfCounter;
  50959. /**
  50960. * Gets the particles render time capture status
  50961. */
  50962. /**
  50963. * Enable or disable the particles render time capture
  50964. */
  50965. captureParticlesRenderTime: boolean;
  50966. /**
  50967. * Gets the perf counter used for sprites render time
  50968. */
  50969. readonly spritesRenderTimeCounter: PerfCounter;
  50970. /**
  50971. * Gets the sprites render time capture status
  50972. */
  50973. /**
  50974. * Enable or disable the sprites render time capture
  50975. */
  50976. captureSpritesRenderTime: boolean;
  50977. /**
  50978. * Gets the perf counter used for physics time
  50979. */
  50980. readonly physicsTimeCounter: PerfCounter;
  50981. /**
  50982. * Gets the physics time capture status
  50983. */
  50984. /**
  50985. * Enable or disable the physics time capture
  50986. */
  50987. capturePhysicsTime: boolean;
  50988. /**
  50989. * Gets the perf counter used for animations time
  50990. */
  50991. readonly animationsTimeCounter: PerfCounter;
  50992. /**
  50993. * Gets the animations time capture status
  50994. */
  50995. /**
  50996. * Enable or disable the animations time capture
  50997. */
  50998. captureAnimationsTime: boolean;
  50999. /**
  51000. * Gets the perf counter used for frame time capture
  51001. */
  51002. readonly frameTimeCounter: PerfCounter;
  51003. /**
  51004. * Gets the frame time capture status
  51005. */
  51006. /**
  51007. * Enable or disable the frame time capture
  51008. */
  51009. captureFrameTime: boolean;
  51010. /**
  51011. * Gets the perf counter used for inter-frames time capture
  51012. */
  51013. readonly interFrameTimeCounter: PerfCounter;
  51014. /**
  51015. * Gets the inter-frames time capture status
  51016. */
  51017. /**
  51018. * Enable or disable the inter-frames time capture
  51019. */
  51020. captureInterFrameTime: boolean;
  51021. /**
  51022. * Gets the perf counter used for render time capture
  51023. */
  51024. readonly renderTimeCounter: PerfCounter;
  51025. /**
  51026. * Gets the render time capture status
  51027. */
  51028. /**
  51029. * Enable or disable the render time capture
  51030. */
  51031. captureRenderTime: boolean;
  51032. /**
  51033. * Gets the perf counter used for camera render time capture
  51034. */
  51035. readonly cameraRenderTimeCounter: PerfCounter;
  51036. /**
  51037. * Gets the camera render time capture status
  51038. */
  51039. /**
  51040. * Enable or disable the camera render time capture
  51041. */
  51042. captureCameraRenderTime: boolean;
  51043. /**
  51044. * Gets the perf counter used for draw calls
  51045. */
  51046. readonly drawCallsCounter: PerfCounter;
  51047. /**
  51048. * Instantiates a new scene instrumentation.
  51049. * This class can be used to get instrumentation data from a Babylon engine
  51050. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51051. * @param scene Defines the scene to instrument
  51052. */
  51053. constructor(
  51054. /**
  51055. * Defines the scene to instrument
  51056. */
  51057. scene: Scene);
  51058. /**
  51059. * Dispose and release associated resources.
  51060. */
  51061. dispose(): void;
  51062. }
  51063. }
  51064. declare module BABYLON {
  51065. /** @hidden */
  51066. export var glowMapGenerationPixelShader: {
  51067. name: string;
  51068. shader: string;
  51069. };
  51070. }
  51071. declare module BABYLON {
  51072. /** @hidden */
  51073. export var glowMapGenerationVertexShader: {
  51074. name: string;
  51075. shader: string;
  51076. };
  51077. }
  51078. declare module BABYLON {
  51079. /**
  51080. * Effect layer options. This helps customizing the behaviour
  51081. * of the effect layer.
  51082. */
  51083. export interface IEffectLayerOptions {
  51084. /**
  51085. * Multiplication factor apply to the canvas size to compute the render target size
  51086. * used to generated the objects (the smaller the faster).
  51087. */
  51088. mainTextureRatio: number;
  51089. /**
  51090. * Enforces a fixed size texture to ensure effect stability across devices.
  51091. */
  51092. mainTextureFixedSize?: number;
  51093. /**
  51094. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51095. */
  51096. alphaBlendingMode: number;
  51097. /**
  51098. * The camera attached to the layer.
  51099. */
  51100. camera: Nullable<Camera>;
  51101. /**
  51102. * The rendering group to draw the layer in.
  51103. */
  51104. renderingGroupId: number;
  51105. }
  51106. /**
  51107. * The effect layer Helps adding post process effect blended with the main pass.
  51108. *
  51109. * This can be for instance use to generate glow or higlight effects on the scene.
  51110. *
  51111. * The effect layer class can not be used directly and is intented to inherited from to be
  51112. * customized per effects.
  51113. */
  51114. export abstract class EffectLayer {
  51115. private _vertexBuffers;
  51116. private _indexBuffer;
  51117. private _cachedDefines;
  51118. private _effectLayerMapGenerationEffect;
  51119. private _effectLayerOptions;
  51120. private _mergeEffect;
  51121. protected _scene: Scene;
  51122. protected _engine: Engine;
  51123. protected _maxSize: number;
  51124. protected _mainTextureDesiredSize: ISize;
  51125. protected _mainTexture: RenderTargetTexture;
  51126. protected _shouldRender: boolean;
  51127. protected _postProcesses: PostProcess[];
  51128. protected _textures: BaseTexture[];
  51129. protected _emissiveTextureAndColor: {
  51130. texture: Nullable<BaseTexture>;
  51131. color: Color4;
  51132. };
  51133. /**
  51134. * The name of the layer
  51135. */
  51136. name: string;
  51137. /**
  51138. * The clear color of the texture used to generate the glow map.
  51139. */
  51140. neutralColor: Color4;
  51141. /**
  51142. * Specifies wether the highlight layer is enabled or not.
  51143. */
  51144. isEnabled: boolean;
  51145. /**
  51146. * Gets the camera attached to the layer.
  51147. */
  51148. readonly camera: Nullable<Camera>;
  51149. /**
  51150. * Gets the rendering group id the layer should render in.
  51151. */
  51152. renderingGroupId: number;
  51153. /**
  51154. * An event triggered when the effect layer has been disposed.
  51155. */
  51156. onDisposeObservable: Observable<EffectLayer>;
  51157. /**
  51158. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51159. */
  51160. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51161. /**
  51162. * An event triggered when the generated texture is being merged in the scene.
  51163. */
  51164. onBeforeComposeObservable: Observable<EffectLayer>;
  51165. /**
  51166. * An event triggered when the mesh is rendered into the effect render target.
  51167. */
  51168. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  51169. /**
  51170. * An event triggered after the mesh has been rendered into the effect render target.
  51171. */
  51172. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  51173. /**
  51174. * An event triggered when the generated texture has been merged in the scene.
  51175. */
  51176. onAfterComposeObservable: Observable<EffectLayer>;
  51177. /**
  51178. * An event triggered when the efffect layer changes its size.
  51179. */
  51180. onSizeChangedObservable: Observable<EffectLayer>;
  51181. /** @hidden */
  51182. static _SceneComponentInitialization: (scene: Scene) => void;
  51183. /**
  51184. * Instantiates a new effect Layer and references it in the scene.
  51185. * @param name The name of the layer
  51186. * @param scene The scene to use the layer in
  51187. */
  51188. constructor(
  51189. /** The Friendly of the effect in the scene */
  51190. name: string, scene: Scene);
  51191. /**
  51192. * Get the effect name of the layer.
  51193. * @return The effect name
  51194. */
  51195. abstract getEffectName(): string;
  51196. /**
  51197. * Checks for the readiness of the element composing the layer.
  51198. * @param subMesh the mesh to check for
  51199. * @param useInstances specify wether or not to use instances to render the mesh
  51200. * @return true if ready otherwise, false
  51201. */
  51202. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51203. /**
  51204. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51205. * @returns true if the effect requires stencil during the main canvas render pass.
  51206. */
  51207. abstract needStencil(): boolean;
  51208. /**
  51209. * Create the merge effect. This is the shader use to blit the information back
  51210. * to the main canvas at the end of the scene rendering.
  51211. * @returns The effect containing the shader used to merge the effect on the main canvas
  51212. */
  51213. protected abstract _createMergeEffect(): Effect;
  51214. /**
  51215. * Creates the render target textures and post processes used in the effect layer.
  51216. */
  51217. protected abstract _createTextureAndPostProcesses(): void;
  51218. /**
  51219. * Implementation specific of rendering the generating effect on the main canvas.
  51220. * @param effect The effect used to render through
  51221. */
  51222. protected abstract _internalRender(effect: Effect): void;
  51223. /**
  51224. * Sets the required values for both the emissive texture and and the main color.
  51225. */
  51226. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51227. /**
  51228. * Free any resources and references associated to a mesh.
  51229. * Internal use
  51230. * @param mesh The mesh to free.
  51231. */
  51232. abstract _disposeMesh(mesh: Mesh): void;
  51233. /**
  51234. * Serializes this layer (Glow or Highlight for example)
  51235. * @returns a serialized layer object
  51236. */
  51237. abstract serialize?(): any;
  51238. /**
  51239. * Initializes the effect layer with the required options.
  51240. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51241. */
  51242. protected _init(options: Partial<IEffectLayerOptions>): void;
  51243. /**
  51244. * Generates the index buffer of the full screen quad blending to the main canvas.
  51245. */
  51246. private _generateIndexBuffer;
  51247. /**
  51248. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51249. */
  51250. private _generateVertexBuffer;
  51251. /**
  51252. * Sets the main texture desired size which is the closest power of two
  51253. * of the engine canvas size.
  51254. */
  51255. private _setMainTextureSize;
  51256. /**
  51257. * Creates the main texture for the effect layer.
  51258. */
  51259. protected _createMainTexture(): void;
  51260. /**
  51261. * Adds specific effects defines.
  51262. * @param defines The defines to add specifics to.
  51263. */
  51264. protected _addCustomEffectDefines(defines: string[]): void;
  51265. /**
  51266. * Checks for the readiness of the element composing the layer.
  51267. * @param subMesh the mesh to check for
  51268. * @param useInstances specify wether or not to use instances to render the mesh
  51269. * @param emissiveTexture the associated emissive texture used to generate the glow
  51270. * @return true if ready otherwise, false
  51271. */
  51272. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51273. /**
  51274. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51275. */
  51276. render(): void;
  51277. /**
  51278. * Determine if a given mesh will be used in the current effect.
  51279. * @param mesh mesh to test
  51280. * @returns true if the mesh will be used
  51281. */
  51282. hasMesh(mesh: AbstractMesh): boolean;
  51283. /**
  51284. * Returns true if the layer contains information to display, otherwise false.
  51285. * @returns true if the glow layer should be rendered
  51286. */
  51287. shouldRender(): boolean;
  51288. /**
  51289. * Returns true if the mesh should render, otherwise false.
  51290. * @param mesh The mesh to render
  51291. * @returns true if it should render otherwise false
  51292. */
  51293. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51294. /**
  51295. * Returns true if the mesh can be rendered, otherwise false.
  51296. * @param mesh The mesh to render
  51297. * @param material The material used on the mesh
  51298. * @returns true if it can be rendered otherwise false
  51299. */
  51300. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51301. /**
  51302. * Returns true if the mesh should render, otherwise false.
  51303. * @param mesh The mesh to render
  51304. * @returns true if it should render otherwise false
  51305. */
  51306. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51307. /**
  51308. * Renders the submesh passed in parameter to the generation map.
  51309. */
  51310. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51311. /**
  51312. * Defines wether the current material of the mesh should be use to render the effect.
  51313. * @param mesh defines the current mesh to render
  51314. */
  51315. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51316. /**
  51317. * Rebuild the required buffers.
  51318. * @hidden Internal use only.
  51319. */
  51320. _rebuild(): void;
  51321. /**
  51322. * Dispose only the render target textures and post process.
  51323. */
  51324. private _disposeTextureAndPostProcesses;
  51325. /**
  51326. * Dispose the highlight layer and free resources.
  51327. */
  51328. dispose(): void;
  51329. /**
  51330. * Gets the class name of the effect layer
  51331. * @returns the string with the class name of the effect layer
  51332. */
  51333. getClassName(): string;
  51334. /**
  51335. * Creates an effect layer from parsed effect layer data
  51336. * @param parsedEffectLayer defines effect layer data
  51337. * @param scene defines the current scene
  51338. * @param rootUrl defines the root URL containing the effect layer information
  51339. * @returns a parsed effect Layer
  51340. */
  51341. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51342. }
  51343. }
  51344. declare module BABYLON {
  51345. interface AbstractScene {
  51346. /**
  51347. * The list of effect layers (highlights/glow) added to the scene
  51348. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51349. * @see http://doc.babylonjs.com/how_to/glow_layer
  51350. */
  51351. effectLayers: Array<EffectLayer>;
  51352. /**
  51353. * Removes the given effect layer from this scene.
  51354. * @param toRemove defines the effect layer to remove
  51355. * @returns the index of the removed effect layer
  51356. */
  51357. removeEffectLayer(toRemove: EffectLayer): number;
  51358. /**
  51359. * Adds the given effect layer to this scene
  51360. * @param newEffectLayer defines the effect layer to add
  51361. */
  51362. addEffectLayer(newEffectLayer: EffectLayer): void;
  51363. }
  51364. /**
  51365. * Defines the layer scene component responsible to manage any effect layers
  51366. * in a given scene.
  51367. */
  51368. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51369. /**
  51370. * The component name helpfull to identify the component in the list of scene components.
  51371. */
  51372. readonly name: string;
  51373. /**
  51374. * The scene the component belongs to.
  51375. */
  51376. scene: Scene;
  51377. private _engine;
  51378. private _renderEffects;
  51379. private _needStencil;
  51380. private _previousStencilState;
  51381. /**
  51382. * Creates a new instance of the component for the given scene
  51383. * @param scene Defines the scene to register the component in
  51384. */
  51385. constructor(scene: Scene);
  51386. /**
  51387. * Registers the component in a given scene
  51388. */
  51389. register(): void;
  51390. /**
  51391. * Rebuilds the elements related to this component in case of
  51392. * context lost for instance.
  51393. */
  51394. rebuild(): void;
  51395. /**
  51396. * Serializes the component data to the specified json object
  51397. * @param serializationObject The object to serialize to
  51398. */
  51399. serialize(serializationObject: any): void;
  51400. /**
  51401. * Adds all the elements from the container to the scene
  51402. * @param container the container holding the elements
  51403. */
  51404. addFromContainer(container: AbstractScene): void;
  51405. /**
  51406. * Removes all the elements in the container from the scene
  51407. * @param container contains the elements to remove
  51408. * @param dispose if the removed element should be disposed (default: false)
  51409. */
  51410. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51411. /**
  51412. * Disposes the component and the associated ressources.
  51413. */
  51414. dispose(): void;
  51415. private _isReadyForMesh;
  51416. private _renderMainTexture;
  51417. private _setStencil;
  51418. private _setStencilBack;
  51419. private _draw;
  51420. private _drawCamera;
  51421. private _drawRenderingGroup;
  51422. }
  51423. }
  51424. declare module BABYLON {
  51425. /** @hidden */
  51426. export var glowMapMergePixelShader: {
  51427. name: string;
  51428. shader: string;
  51429. };
  51430. }
  51431. declare module BABYLON {
  51432. /** @hidden */
  51433. export var glowMapMergeVertexShader: {
  51434. name: string;
  51435. shader: string;
  51436. };
  51437. }
  51438. declare module BABYLON {
  51439. interface AbstractScene {
  51440. /**
  51441. * Return a the first highlight layer of the scene with a given name.
  51442. * @param name The name of the highlight layer to look for.
  51443. * @return The highlight layer if found otherwise null.
  51444. */
  51445. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51446. }
  51447. /**
  51448. * Glow layer options. This helps customizing the behaviour
  51449. * of the glow layer.
  51450. */
  51451. export interface IGlowLayerOptions {
  51452. /**
  51453. * Multiplication factor apply to the canvas size to compute the render target size
  51454. * used to generated the glowing objects (the smaller the faster).
  51455. */
  51456. mainTextureRatio: number;
  51457. /**
  51458. * Enforces a fixed size texture to ensure resize independant blur.
  51459. */
  51460. mainTextureFixedSize?: number;
  51461. /**
  51462. * How big is the kernel of the blur texture.
  51463. */
  51464. blurKernelSize: number;
  51465. /**
  51466. * The camera attached to the layer.
  51467. */
  51468. camera: Nullable<Camera>;
  51469. /**
  51470. * Enable MSAA by chosing the number of samples.
  51471. */
  51472. mainTextureSamples?: number;
  51473. /**
  51474. * The rendering group to draw the layer in.
  51475. */
  51476. renderingGroupId: number;
  51477. }
  51478. /**
  51479. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51480. *
  51481. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  51482. *
  51483. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51484. */
  51485. export class GlowLayer extends EffectLayer {
  51486. /**
  51487. * Effect Name of the layer.
  51488. */
  51489. static readonly EffectName: string;
  51490. /**
  51491. * The default blur kernel size used for the glow.
  51492. */
  51493. static DefaultBlurKernelSize: number;
  51494. /**
  51495. * The default texture size ratio used for the glow.
  51496. */
  51497. static DefaultTextureRatio: number;
  51498. /**
  51499. * Sets the kernel size of the blur.
  51500. */
  51501. /**
  51502. * Gets the kernel size of the blur.
  51503. */
  51504. blurKernelSize: number;
  51505. /**
  51506. * Sets the glow intensity.
  51507. */
  51508. /**
  51509. * Gets the glow intensity.
  51510. */
  51511. intensity: number;
  51512. private _options;
  51513. private _intensity;
  51514. private _horizontalBlurPostprocess1;
  51515. private _verticalBlurPostprocess1;
  51516. private _horizontalBlurPostprocess2;
  51517. private _verticalBlurPostprocess2;
  51518. private _blurTexture1;
  51519. private _blurTexture2;
  51520. private _postProcesses1;
  51521. private _postProcesses2;
  51522. private _includedOnlyMeshes;
  51523. private _excludedMeshes;
  51524. private _meshesUsingTheirOwnMaterials;
  51525. /**
  51526. * Callback used to let the user override the color selection on a per mesh basis
  51527. */
  51528. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51529. /**
  51530. * Callback used to let the user override the texture selection on a per mesh basis
  51531. */
  51532. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51533. /**
  51534. * Instantiates a new glow Layer and references it to the scene.
  51535. * @param name The name of the layer
  51536. * @param scene The scene to use the layer in
  51537. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51538. */
  51539. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51540. /**
  51541. * Get the effect name of the layer.
  51542. * @return The effect name
  51543. */
  51544. getEffectName(): string;
  51545. /**
  51546. * Create the merge effect. This is the shader use to blit the information back
  51547. * to the main canvas at the end of the scene rendering.
  51548. */
  51549. protected _createMergeEffect(): Effect;
  51550. /**
  51551. * Creates the render target textures and post processes used in the glow layer.
  51552. */
  51553. protected _createTextureAndPostProcesses(): void;
  51554. /**
  51555. * Checks for the readiness of the element composing the layer.
  51556. * @param subMesh the mesh to check for
  51557. * @param useInstances specify wether or not to use instances to render the mesh
  51558. * @param emissiveTexture the associated emissive texture used to generate the glow
  51559. * @return true if ready otherwise, false
  51560. */
  51561. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51562. /**
  51563. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51564. */
  51565. needStencil(): boolean;
  51566. /**
  51567. * Returns true if the mesh can be rendered, otherwise false.
  51568. * @param mesh The mesh to render
  51569. * @param material The material used on the mesh
  51570. * @returns true if it can be rendered otherwise false
  51571. */
  51572. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51573. /**
  51574. * Implementation specific of rendering the generating effect on the main canvas.
  51575. * @param effect The effect used to render through
  51576. */
  51577. protected _internalRender(effect: Effect): void;
  51578. /**
  51579. * Sets the required values for both the emissive texture and and the main color.
  51580. */
  51581. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51582. /**
  51583. * Returns true if the mesh should render, otherwise false.
  51584. * @param mesh The mesh to render
  51585. * @returns true if it should render otherwise false
  51586. */
  51587. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51588. /**
  51589. * Adds specific effects defines.
  51590. * @param defines The defines to add specifics to.
  51591. */
  51592. protected _addCustomEffectDefines(defines: string[]): void;
  51593. /**
  51594. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51595. * @param mesh The mesh to exclude from the glow layer
  51596. */
  51597. addExcludedMesh(mesh: Mesh): void;
  51598. /**
  51599. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51600. * @param mesh The mesh to remove
  51601. */
  51602. removeExcludedMesh(mesh: Mesh): void;
  51603. /**
  51604. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51605. * @param mesh The mesh to include in the glow layer
  51606. */
  51607. addIncludedOnlyMesh(mesh: Mesh): void;
  51608. /**
  51609. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51610. * @param mesh The mesh to remove
  51611. */
  51612. removeIncludedOnlyMesh(mesh: Mesh): void;
  51613. /**
  51614. * Determine if a given mesh will be used in the glow layer
  51615. * @param mesh The mesh to test
  51616. * @returns true if the mesh will be highlighted by the current glow layer
  51617. */
  51618. hasMesh(mesh: AbstractMesh): boolean;
  51619. /**
  51620. * Defines wether the current material of the mesh should be use to render the effect.
  51621. * @param mesh defines the current mesh to render
  51622. */
  51623. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51624. /**
  51625. * Add a mesh to be rendered through its own material and not with emissive only.
  51626. * @param mesh The mesh for which we need to use its material
  51627. */
  51628. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  51629. /**
  51630. * Remove a mesh from being rendered through its own material and not with emissive only.
  51631. * @param mesh The mesh for which we need to not use its material
  51632. */
  51633. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  51634. /**
  51635. * Free any resources and references associated to a mesh.
  51636. * Internal use
  51637. * @param mesh The mesh to free.
  51638. * @hidden
  51639. */
  51640. _disposeMesh(mesh: Mesh): void;
  51641. /**
  51642. * Gets the class name of the effect layer
  51643. * @returns the string with the class name of the effect layer
  51644. */
  51645. getClassName(): string;
  51646. /**
  51647. * Serializes this glow layer
  51648. * @returns a serialized glow layer object
  51649. */
  51650. serialize(): any;
  51651. /**
  51652. * Creates a Glow Layer from parsed glow layer data
  51653. * @param parsedGlowLayer defines glow layer data
  51654. * @param scene defines the current scene
  51655. * @param rootUrl defines the root URL containing the glow layer information
  51656. * @returns a parsed Glow Layer
  51657. */
  51658. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51659. }
  51660. }
  51661. declare module BABYLON {
  51662. /** @hidden */
  51663. export var glowBlurPostProcessPixelShader: {
  51664. name: string;
  51665. shader: string;
  51666. };
  51667. }
  51668. declare module BABYLON {
  51669. interface AbstractScene {
  51670. /**
  51671. * Return a the first highlight layer of the scene with a given name.
  51672. * @param name The name of the highlight layer to look for.
  51673. * @return The highlight layer if found otherwise null.
  51674. */
  51675. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51676. }
  51677. /**
  51678. * Highlight layer options. This helps customizing the behaviour
  51679. * of the highlight layer.
  51680. */
  51681. export interface IHighlightLayerOptions {
  51682. /**
  51683. * Multiplication factor apply to the canvas size to compute the render target size
  51684. * used to generated the glowing objects (the smaller the faster).
  51685. */
  51686. mainTextureRatio: number;
  51687. /**
  51688. * Enforces a fixed size texture to ensure resize independant blur.
  51689. */
  51690. mainTextureFixedSize?: number;
  51691. /**
  51692. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51693. * of the picture to blur (the smaller the faster).
  51694. */
  51695. blurTextureSizeRatio: number;
  51696. /**
  51697. * How big in texel of the blur texture is the vertical blur.
  51698. */
  51699. blurVerticalSize: number;
  51700. /**
  51701. * How big in texel of the blur texture is the horizontal blur.
  51702. */
  51703. blurHorizontalSize: number;
  51704. /**
  51705. * Alpha blending mode used to apply the blur. Default is combine.
  51706. */
  51707. alphaBlendingMode: number;
  51708. /**
  51709. * The camera attached to the layer.
  51710. */
  51711. camera: Nullable<Camera>;
  51712. /**
  51713. * Should we display highlight as a solid stroke?
  51714. */
  51715. isStroke?: boolean;
  51716. /**
  51717. * The rendering group to draw the layer in.
  51718. */
  51719. renderingGroupId: number;
  51720. }
  51721. /**
  51722. * The highlight layer Helps adding a glow effect around a mesh.
  51723. *
  51724. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  51725. * glowy meshes to your scene.
  51726. *
  51727. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51728. */
  51729. export class HighlightLayer extends EffectLayer {
  51730. name: string;
  51731. /**
  51732. * Effect Name of the highlight layer.
  51733. */
  51734. static readonly EffectName: string;
  51735. /**
  51736. * The neutral color used during the preparation of the glow effect.
  51737. * This is black by default as the blend operation is a blend operation.
  51738. */
  51739. static NeutralColor: Color4;
  51740. /**
  51741. * Stencil value used for glowing meshes.
  51742. */
  51743. static GlowingMeshStencilReference: number;
  51744. /**
  51745. * Stencil value used for the other meshes in the scene.
  51746. */
  51747. static NormalMeshStencilReference: number;
  51748. /**
  51749. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51750. */
  51751. innerGlow: boolean;
  51752. /**
  51753. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51754. */
  51755. outerGlow: boolean;
  51756. /**
  51757. * Specifies the horizontal size of the blur.
  51758. */
  51759. /**
  51760. * Gets the horizontal size of the blur.
  51761. */
  51762. blurHorizontalSize: number;
  51763. /**
  51764. * Specifies the vertical size of the blur.
  51765. */
  51766. /**
  51767. * Gets the vertical size of the blur.
  51768. */
  51769. blurVerticalSize: number;
  51770. /**
  51771. * An event triggered when the highlight layer is being blurred.
  51772. */
  51773. onBeforeBlurObservable: Observable<HighlightLayer>;
  51774. /**
  51775. * An event triggered when the highlight layer has been blurred.
  51776. */
  51777. onAfterBlurObservable: Observable<HighlightLayer>;
  51778. private _instanceGlowingMeshStencilReference;
  51779. private _options;
  51780. private _downSamplePostprocess;
  51781. private _horizontalBlurPostprocess;
  51782. private _verticalBlurPostprocess;
  51783. private _blurTexture;
  51784. private _meshes;
  51785. private _excludedMeshes;
  51786. /**
  51787. * Instantiates a new highlight Layer and references it to the scene..
  51788. * @param name The name of the layer
  51789. * @param scene The scene to use the layer in
  51790. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51791. */
  51792. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51793. /**
  51794. * Get the effect name of the layer.
  51795. * @return The effect name
  51796. */
  51797. getEffectName(): string;
  51798. /**
  51799. * Create the merge effect. This is the shader use to blit the information back
  51800. * to the main canvas at the end of the scene rendering.
  51801. */
  51802. protected _createMergeEffect(): Effect;
  51803. /**
  51804. * Creates the render target textures and post processes used in the highlight layer.
  51805. */
  51806. protected _createTextureAndPostProcesses(): void;
  51807. /**
  51808. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51809. */
  51810. needStencil(): boolean;
  51811. /**
  51812. * Checks for the readiness of the element composing the layer.
  51813. * @param subMesh the mesh to check for
  51814. * @param useInstances specify wether or not to use instances to render the mesh
  51815. * @param emissiveTexture the associated emissive texture used to generate the glow
  51816. * @return true if ready otherwise, false
  51817. */
  51818. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51819. /**
  51820. * Implementation specific of rendering the generating effect on the main canvas.
  51821. * @param effect The effect used to render through
  51822. */
  51823. protected _internalRender(effect: Effect): void;
  51824. /**
  51825. * Returns true if the layer contains information to display, otherwise false.
  51826. */
  51827. shouldRender(): boolean;
  51828. /**
  51829. * Returns true if the mesh should render, otherwise false.
  51830. * @param mesh The mesh to render
  51831. * @returns true if it should render otherwise false
  51832. */
  51833. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51834. /**
  51835. * Sets the required values for both the emissive texture and and the main color.
  51836. */
  51837. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51838. /**
  51839. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51840. * @param mesh The mesh to exclude from the highlight layer
  51841. */
  51842. addExcludedMesh(mesh: Mesh): void;
  51843. /**
  51844. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51845. * @param mesh The mesh to highlight
  51846. */
  51847. removeExcludedMesh(mesh: Mesh): void;
  51848. /**
  51849. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51850. * @param mesh mesh to test
  51851. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51852. */
  51853. hasMesh(mesh: AbstractMesh): boolean;
  51854. /**
  51855. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51856. * @param mesh The mesh to highlight
  51857. * @param color The color of the highlight
  51858. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51859. */
  51860. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51861. /**
  51862. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51863. * @param mesh The mesh to highlight
  51864. */
  51865. removeMesh(mesh: Mesh): void;
  51866. /**
  51867. * Force the stencil to the normal expected value for none glowing parts
  51868. */
  51869. private _defaultStencilReference;
  51870. /**
  51871. * Free any resources and references associated to a mesh.
  51872. * Internal use
  51873. * @param mesh The mesh to free.
  51874. * @hidden
  51875. */
  51876. _disposeMesh(mesh: Mesh): void;
  51877. /**
  51878. * Dispose the highlight layer and free resources.
  51879. */
  51880. dispose(): void;
  51881. /**
  51882. * Gets the class name of the effect layer
  51883. * @returns the string with the class name of the effect layer
  51884. */
  51885. getClassName(): string;
  51886. /**
  51887. * Serializes this Highlight layer
  51888. * @returns a serialized Highlight layer object
  51889. */
  51890. serialize(): any;
  51891. /**
  51892. * Creates a Highlight layer from parsed Highlight layer data
  51893. * @param parsedHightlightLayer defines the Highlight layer data
  51894. * @param scene defines the current scene
  51895. * @param rootUrl defines the root URL containing the Highlight layer information
  51896. * @returns a parsed Highlight layer
  51897. */
  51898. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51899. }
  51900. }
  51901. declare module BABYLON {
  51902. interface AbstractScene {
  51903. /**
  51904. * The list of layers (background and foreground) of the scene
  51905. */
  51906. layers: Array<Layer>;
  51907. }
  51908. /**
  51909. * Defines the layer scene component responsible to manage any layers
  51910. * in a given scene.
  51911. */
  51912. export class LayerSceneComponent implements ISceneComponent {
  51913. /**
  51914. * The component name helpfull to identify the component in the list of scene components.
  51915. */
  51916. readonly name: string;
  51917. /**
  51918. * The scene the component belongs to.
  51919. */
  51920. scene: Scene;
  51921. private _engine;
  51922. /**
  51923. * Creates a new instance of the component for the given scene
  51924. * @param scene Defines the scene to register the component in
  51925. */
  51926. constructor(scene: Scene);
  51927. /**
  51928. * Registers the component in a given scene
  51929. */
  51930. register(): void;
  51931. /**
  51932. * Rebuilds the elements related to this component in case of
  51933. * context lost for instance.
  51934. */
  51935. rebuild(): void;
  51936. /**
  51937. * Disposes the component and the associated ressources.
  51938. */
  51939. dispose(): void;
  51940. private _draw;
  51941. private _drawCameraPredicate;
  51942. private _drawCameraBackground;
  51943. private _drawCameraForeground;
  51944. private _drawRenderTargetPredicate;
  51945. private _drawRenderTargetBackground;
  51946. private _drawRenderTargetForeground;
  51947. /**
  51948. * Adds all the elements from the container to the scene
  51949. * @param container the container holding the elements
  51950. */
  51951. addFromContainer(container: AbstractScene): void;
  51952. /**
  51953. * Removes all the elements in the container from the scene
  51954. * @param container contains the elements to remove
  51955. * @param dispose if the removed element should be disposed (default: false)
  51956. */
  51957. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51958. }
  51959. }
  51960. declare module BABYLON {
  51961. /** @hidden */
  51962. export var layerPixelShader: {
  51963. name: string;
  51964. shader: string;
  51965. };
  51966. }
  51967. declare module BABYLON {
  51968. /** @hidden */
  51969. export var layerVertexShader: {
  51970. name: string;
  51971. shader: string;
  51972. };
  51973. }
  51974. declare module BABYLON {
  51975. /**
  51976. * This represents a full screen 2d layer.
  51977. * This can be useful to display a picture in the background of your scene for instance.
  51978. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51979. */
  51980. export class Layer {
  51981. /**
  51982. * Define the name of the layer.
  51983. */
  51984. name: string;
  51985. /**
  51986. * Define the texture the layer should display.
  51987. */
  51988. texture: Nullable<Texture>;
  51989. /**
  51990. * Is the layer in background or foreground.
  51991. */
  51992. isBackground: boolean;
  51993. /**
  51994. * Define the color of the layer (instead of texture).
  51995. */
  51996. color: Color4;
  51997. /**
  51998. * Define the scale of the layer in order to zoom in out of the texture.
  51999. */
  52000. scale: Vector2;
  52001. /**
  52002. * Define an offset for the layer in order to shift the texture.
  52003. */
  52004. offset: Vector2;
  52005. /**
  52006. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52007. */
  52008. alphaBlendingMode: number;
  52009. /**
  52010. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52011. * Alpha test will not mix with the background color in case of transparency.
  52012. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52013. */
  52014. alphaTest: boolean;
  52015. /**
  52016. * Define a mask to restrict the layer to only some of the scene cameras.
  52017. */
  52018. layerMask: number;
  52019. /**
  52020. * Define the list of render target the layer is visible into.
  52021. */
  52022. renderTargetTextures: RenderTargetTexture[];
  52023. /**
  52024. * Define if the layer is only used in renderTarget or if it also
  52025. * renders in the main frame buffer of the canvas.
  52026. */
  52027. renderOnlyInRenderTargetTextures: boolean;
  52028. private _scene;
  52029. private _vertexBuffers;
  52030. private _indexBuffer;
  52031. private _effect;
  52032. private _previousDefines;
  52033. /**
  52034. * An event triggered when the layer is disposed.
  52035. */
  52036. onDisposeObservable: Observable<Layer>;
  52037. private _onDisposeObserver;
  52038. /**
  52039. * Back compatibility with callback before the onDisposeObservable existed.
  52040. * The set callback will be triggered when the layer has been disposed.
  52041. */
  52042. onDispose: () => void;
  52043. /**
  52044. * An event triggered before rendering the scene
  52045. */
  52046. onBeforeRenderObservable: Observable<Layer>;
  52047. private _onBeforeRenderObserver;
  52048. /**
  52049. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52050. * The set callback will be triggered just before rendering the layer.
  52051. */
  52052. onBeforeRender: () => void;
  52053. /**
  52054. * An event triggered after rendering the scene
  52055. */
  52056. onAfterRenderObservable: Observable<Layer>;
  52057. private _onAfterRenderObserver;
  52058. /**
  52059. * Back compatibility with callback before the onAfterRenderObservable existed.
  52060. * The set callback will be triggered just after rendering the layer.
  52061. */
  52062. onAfterRender: () => void;
  52063. /**
  52064. * Instantiates a new layer.
  52065. * This represents a full screen 2d layer.
  52066. * This can be useful to display a picture in the background of your scene for instance.
  52067. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52068. * @param name Define the name of the layer in the scene
  52069. * @param imgUrl Define the url of the texture to display in the layer
  52070. * @param scene Define the scene the layer belongs to
  52071. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52072. * @param color Defines a color for the layer
  52073. */
  52074. constructor(
  52075. /**
  52076. * Define the name of the layer.
  52077. */
  52078. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52079. private _createIndexBuffer;
  52080. /** @hidden */
  52081. _rebuild(): void;
  52082. /**
  52083. * Renders the layer in the scene.
  52084. */
  52085. render(): void;
  52086. /**
  52087. * Disposes and releases the associated ressources.
  52088. */
  52089. dispose(): void;
  52090. }
  52091. }
  52092. declare module BABYLON {
  52093. /** @hidden */
  52094. export var lensFlarePixelShader: {
  52095. name: string;
  52096. shader: string;
  52097. };
  52098. }
  52099. declare module BABYLON {
  52100. /** @hidden */
  52101. export var lensFlareVertexShader: {
  52102. name: string;
  52103. shader: string;
  52104. };
  52105. }
  52106. declare module BABYLON {
  52107. /**
  52108. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52109. * It is usually composed of several `lensFlare`.
  52110. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52111. */
  52112. export class LensFlareSystem {
  52113. /**
  52114. * Define the name of the lens flare system
  52115. */
  52116. name: string;
  52117. /**
  52118. * List of lens flares used in this system.
  52119. */
  52120. lensFlares: LensFlare[];
  52121. /**
  52122. * Define a limit from the border the lens flare can be visible.
  52123. */
  52124. borderLimit: number;
  52125. /**
  52126. * Define a viewport border we do not want to see the lens flare in.
  52127. */
  52128. viewportBorder: number;
  52129. /**
  52130. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52131. */
  52132. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52133. /**
  52134. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52135. */
  52136. layerMask: number;
  52137. /**
  52138. * Define the id of the lens flare system in the scene.
  52139. * (equal to name by default)
  52140. */
  52141. id: string;
  52142. private _scene;
  52143. private _emitter;
  52144. private _vertexBuffers;
  52145. private _indexBuffer;
  52146. private _effect;
  52147. private _positionX;
  52148. private _positionY;
  52149. private _isEnabled;
  52150. /** @hidden */
  52151. static _SceneComponentInitialization: (scene: Scene) => void;
  52152. /**
  52153. * Instantiates a lens flare system.
  52154. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52155. * It is usually composed of several `lensFlare`.
  52156. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52157. * @param name Define the name of the lens flare system in the scene
  52158. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52159. * @param scene Define the scene the lens flare system belongs to
  52160. */
  52161. constructor(
  52162. /**
  52163. * Define the name of the lens flare system
  52164. */
  52165. name: string, emitter: any, scene: Scene);
  52166. /**
  52167. * Define if the lens flare system is enabled.
  52168. */
  52169. isEnabled: boolean;
  52170. /**
  52171. * Get the scene the effects belongs to.
  52172. * @returns the scene holding the lens flare system
  52173. */
  52174. getScene(): Scene;
  52175. /**
  52176. * Get the emitter of the lens flare system.
  52177. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52178. * @returns the emitter of the lens flare system
  52179. */
  52180. getEmitter(): any;
  52181. /**
  52182. * Set the emitter of the lens flare system.
  52183. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52184. * @param newEmitter Define the new emitter of the system
  52185. */
  52186. setEmitter(newEmitter: any): void;
  52187. /**
  52188. * Get the lens flare system emitter position.
  52189. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52190. * @returns the position
  52191. */
  52192. getEmitterPosition(): Vector3;
  52193. /**
  52194. * @hidden
  52195. */
  52196. computeEffectivePosition(globalViewport: Viewport): boolean;
  52197. /** @hidden */
  52198. _isVisible(): boolean;
  52199. /**
  52200. * @hidden
  52201. */
  52202. render(): boolean;
  52203. /**
  52204. * Dispose and release the lens flare with its associated resources.
  52205. */
  52206. dispose(): void;
  52207. /**
  52208. * Parse a lens flare system from a JSON repressentation
  52209. * @param parsedLensFlareSystem Define the JSON to parse
  52210. * @param scene Define the scene the parsed system should be instantiated in
  52211. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52212. * @returns the parsed system
  52213. */
  52214. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52215. /**
  52216. * Serialize the current Lens Flare System into a JSON representation.
  52217. * @returns the serialized JSON
  52218. */
  52219. serialize(): any;
  52220. }
  52221. }
  52222. declare module BABYLON {
  52223. /**
  52224. * This represents one of the lens effect in a `lensFlareSystem`.
  52225. * It controls one of the indiviual texture used in the effect.
  52226. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52227. */
  52228. export class LensFlare {
  52229. /**
  52230. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52231. */
  52232. size: number;
  52233. /**
  52234. * 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.
  52235. */
  52236. position: number;
  52237. /**
  52238. * Define the lens color.
  52239. */
  52240. color: Color3;
  52241. /**
  52242. * Define the lens texture.
  52243. */
  52244. texture: Nullable<Texture>;
  52245. /**
  52246. * Define the alpha mode to render this particular lens.
  52247. */
  52248. alphaMode: number;
  52249. private _system;
  52250. /**
  52251. * Creates a new Lens Flare.
  52252. * This represents one of the lens effect in a `lensFlareSystem`.
  52253. * It controls one of the indiviual texture used in the effect.
  52254. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52255. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52256. * @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.
  52257. * @param color Define the lens color
  52258. * @param imgUrl Define the lens texture url
  52259. * @param system Define the `lensFlareSystem` this flare is part of
  52260. * @returns The newly created Lens Flare
  52261. */
  52262. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52263. /**
  52264. * Instantiates a new Lens Flare.
  52265. * This represents one of the lens effect in a `lensFlareSystem`.
  52266. * It controls one of the indiviual texture used in the effect.
  52267. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52268. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52269. * @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.
  52270. * @param color Define the lens color
  52271. * @param imgUrl Define the lens texture url
  52272. * @param system Define the `lensFlareSystem` this flare is part of
  52273. */
  52274. constructor(
  52275. /**
  52276. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52277. */
  52278. size: number,
  52279. /**
  52280. * 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.
  52281. */
  52282. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52283. /**
  52284. * Dispose and release the lens flare with its associated resources.
  52285. */
  52286. dispose(): void;
  52287. }
  52288. }
  52289. declare module BABYLON {
  52290. interface AbstractScene {
  52291. /**
  52292. * The list of lens flare system added to the scene
  52293. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52294. */
  52295. lensFlareSystems: Array<LensFlareSystem>;
  52296. /**
  52297. * Removes the given lens flare system from this scene.
  52298. * @param toRemove The lens flare system to remove
  52299. * @returns The index of the removed lens flare system
  52300. */
  52301. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52302. /**
  52303. * Adds the given lens flare system to this scene
  52304. * @param newLensFlareSystem The lens flare system to add
  52305. */
  52306. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52307. /**
  52308. * Gets a lens flare system using its name
  52309. * @param name defines the name to look for
  52310. * @returns the lens flare system or null if not found
  52311. */
  52312. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52313. /**
  52314. * Gets a lens flare system using its id
  52315. * @param id defines the id to look for
  52316. * @returns the lens flare system or null if not found
  52317. */
  52318. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52319. }
  52320. /**
  52321. * Defines the lens flare scene component responsible to manage any lens flares
  52322. * in a given scene.
  52323. */
  52324. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52325. /**
  52326. * The component name helpfull to identify the component in the list of scene components.
  52327. */
  52328. readonly name: string;
  52329. /**
  52330. * The scene the component belongs to.
  52331. */
  52332. scene: Scene;
  52333. /**
  52334. * Creates a new instance of the component for the given scene
  52335. * @param scene Defines the scene to register the component in
  52336. */
  52337. constructor(scene: Scene);
  52338. /**
  52339. * Registers the component in a given scene
  52340. */
  52341. register(): void;
  52342. /**
  52343. * Rebuilds the elements related to this component in case of
  52344. * context lost for instance.
  52345. */
  52346. rebuild(): void;
  52347. /**
  52348. * Adds all the elements from the container to the scene
  52349. * @param container the container holding the elements
  52350. */
  52351. addFromContainer(container: AbstractScene): void;
  52352. /**
  52353. * Removes all the elements in the container from the scene
  52354. * @param container contains the elements to remove
  52355. * @param dispose if the removed element should be disposed (default: false)
  52356. */
  52357. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52358. /**
  52359. * Serializes the component data to the specified json object
  52360. * @param serializationObject The object to serialize to
  52361. */
  52362. serialize(serializationObject: any): void;
  52363. /**
  52364. * Disposes the component and the associated ressources.
  52365. */
  52366. dispose(): void;
  52367. private _draw;
  52368. }
  52369. }
  52370. declare module BABYLON {
  52371. /**
  52372. * Defines the shadow generator component responsible to manage any shadow generators
  52373. * in a given scene.
  52374. */
  52375. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52376. /**
  52377. * The component name helpfull to identify the component in the list of scene components.
  52378. */
  52379. readonly name: string;
  52380. /**
  52381. * The scene the component belongs to.
  52382. */
  52383. scene: Scene;
  52384. /**
  52385. * Creates a new instance of the component for the given scene
  52386. * @param scene Defines the scene to register the component in
  52387. */
  52388. constructor(scene: Scene);
  52389. /**
  52390. * Registers the component in a given scene
  52391. */
  52392. register(): void;
  52393. /**
  52394. * Rebuilds the elements related to this component in case of
  52395. * context lost for instance.
  52396. */
  52397. rebuild(): void;
  52398. /**
  52399. * Serializes the component data to the specified json object
  52400. * @param serializationObject The object to serialize to
  52401. */
  52402. serialize(serializationObject: any): void;
  52403. /**
  52404. * Adds all the elements from the container to the scene
  52405. * @param container the container holding the elements
  52406. */
  52407. addFromContainer(container: AbstractScene): void;
  52408. /**
  52409. * Removes all the elements in the container from the scene
  52410. * @param container contains the elements to remove
  52411. * @param dispose if the removed element should be disposed (default: false)
  52412. */
  52413. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52414. /**
  52415. * Rebuilds the elements related to this component in case of
  52416. * context lost for instance.
  52417. */
  52418. dispose(): void;
  52419. private _gatherRenderTargets;
  52420. }
  52421. }
  52422. declare module BABYLON {
  52423. /**
  52424. * A point light is a light defined by an unique point in world space.
  52425. * The light is emitted in every direction from this point.
  52426. * A good example of a point light is a standard light bulb.
  52427. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52428. */
  52429. export class PointLight extends ShadowLight {
  52430. private _shadowAngle;
  52431. /**
  52432. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52433. * This specifies what angle the shadow will use to be created.
  52434. *
  52435. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52436. */
  52437. /**
  52438. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52439. * This specifies what angle the shadow will use to be created.
  52440. *
  52441. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52442. */
  52443. shadowAngle: number;
  52444. /**
  52445. * Gets the direction if it has been set.
  52446. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52447. */
  52448. /**
  52449. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52450. */
  52451. direction: Vector3;
  52452. /**
  52453. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52454. * A PointLight emits the light in every direction.
  52455. * It can cast shadows.
  52456. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52457. * ```javascript
  52458. * var pointLight = new PointLight("pl", camera.position, scene);
  52459. * ```
  52460. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52461. * @param name The light friendly name
  52462. * @param position The position of the point light in the scene
  52463. * @param scene The scene the lights belongs to
  52464. */
  52465. constructor(name: string, position: Vector3, scene: Scene);
  52466. /**
  52467. * Returns the string "PointLight"
  52468. * @returns the class name
  52469. */
  52470. getClassName(): string;
  52471. /**
  52472. * Returns the integer 0.
  52473. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52474. */
  52475. getTypeID(): number;
  52476. /**
  52477. * Specifies wether or not the shadowmap should be a cube texture.
  52478. * @returns true if the shadowmap needs to be a cube texture.
  52479. */
  52480. needCube(): boolean;
  52481. /**
  52482. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52483. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52484. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52485. */
  52486. getShadowDirection(faceIndex?: number): Vector3;
  52487. /**
  52488. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52489. * - fov = PI / 2
  52490. * - aspect ratio : 1.0
  52491. * - z-near and far equal to the active camera minZ and maxZ.
  52492. * Returns the PointLight.
  52493. */
  52494. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52495. protected _buildUniformLayout(): void;
  52496. /**
  52497. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52498. * @param effect The effect to update
  52499. * @param lightIndex The index of the light in the effect to update
  52500. * @returns The point light
  52501. */
  52502. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52503. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52504. /**
  52505. * Prepares the list of defines specific to the light type.
  52506. * @param defines the list of defines
  52507. * @param lightIndex defines the index of the light for the effect
  52508. */
  52509. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52510. }
  52511. }
  52512. declare module BABYLON {
  52513. /**
  52514. * Header information of HDR texture files.
  52515. */
  52516. export interface HDRInfo {
  52517. /**
  52518. * The height of the texture in pixels.
  52519. */
  52520. height: number;
  52521. /**
  52522. * The width of the texture in pixels.
  52523. */
  52524. width: number;
  52525. /**
  52526. * The index of the beginning of the data in the binary file.
  52527. */
  52528. dataPosition: number;
  52529. }
  52530. /**
  52531. * This groups tools to convert HDR texture to native colors array.
  52532. */
  52533. export class HDRTools {
  52534. private static Ldexp;
  52535. private static Rgbe2float;
  52536. private static readStringLine;
  52537. /**
  52538. * Reads header information from an RGBE texture stored in a native array.
  52539. * More information on this format are available here:
  52540. * https://en.wikipedia.org/wiki/RGBE_image_format
  52541. *
  52542. * @param uint8array The binary file stored in native array.
  52543. * @return The header information.
  52544. */
  52545. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52546. /**
  52547. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52548. * This RGBE texture needs to store the information as a panorama.
  52549. *
  52550. * More information on this format are available here:
  52551. * https://en.wikipedia.org/wiki/RGBE_image_format
  52552. *
  52553. * @param buffer The binary file stored in an array buffer.
  52554. * @param size The expected size of the extracted cubemap.
  52555. * @return The Cube Map information.
  52556. */
  52557. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52558. /**
  52559. * Returns the pixels data extracted from an RGBE texture.
  52560. * This pixels will be stored left to right up to down in the R G B order in one array.
  52561. *
  52562. * More information on this format are available here:
  52563. * https://en.wikipedia.org/wiki/RGBE_image_format
  52564. *
  52565. * @param uint8array The binary file stored in an array buffer.
  52566. * @param hdrInfo The header information of the file.
  52567. * @return The pixels data in RGB right to left up to down order.
  52568. */
  52569. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52570. private static RGBE_ReadPixels_RLE;
  52571. }
  52572. }
  52573. declare module BABYLON {
  52574. /**
  52575. * This represents a texture coming from an HDR input.
  52576. *
  52577. * The only supported format is currently panorama picture stored in RGBE format.
  52578. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52579. */
  52580. export class HDRCubeTexture extends BaseTexture {
  52581. private static _facesMapping;
  52582. private _generateHarmonics;
  52583. private _noMipmap;
  52584. private _textureMatrix;
  52585. private _size;
  52586. private _onLoad;
  52587. private _onError;
  52588. /**
  52589. * The texture URL.
  52590. */
  52591. url: string;
  52592. /**
  52593. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52594. */
  52595. coordinatesMode: number;
  52596. protected _isBlocking: boolean;
  52597. /**
  52598. * Sets wether or not the texture is blocking during loading.
  52599. */
  52600. /**
  52601. * Gets wether or not the texture is blocking during loading.
  52602. */
  52603. isBlocking: boolean;
  52604. protected _rotationY: number;
  52605. /**
  52606. * Sets texture matrix rotation angle around Y axis in radians.
  52607. */
  52608. /**
  52609. * Gets texture matrix rotation angle around Y axis radians.
  52610. */
  52611. rotationY: number;
  52612. /**
  52613. * Gets or sets the center of the bounding box associated with the cube texture
  52614. * It must define where the camera used to render the texture was set
  52615. */
  52616. boundingBoxPosition: Vector3;
  52617. private _boundingBoxSize;
  52618. /**
  52619. * Gets or sets the size of the bounding box associated with the cube texture
  52620. * When defined, the cubemap will switch to local mode
  52621. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52622. * @example https://www.babylonjs-playground.com/#RNASML
  52623. */
  52624. boundingBoxSize: Vector3;
  52625. /**
  52626. * Instantiates an HDRTexture from the following parameters.
  52627. *
  52628. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52629. * @param scene The scene the texture will be used in
  52630. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52631. * @param noMipmap Forces to not generate the mipmap if true
  52632. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52633. * @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)
  52634. * @param reserved Reserved flag for internal use.
  52635. */
  52636. 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>);
  52637. /**
  52638. * Get the current class name of the texture useful for serialization or dynamic coding.
  52639. * @returns "HDRCubeTexture"
  52640. */
  52641. getClassName(): string;
  52642. /**
  52643. * Occurs when the file is raw .hdr file.
  52644. */
  52645. private loadTexture;
  52646. clone(): HDRCubeTexture;
  52647. delayLoad(): void;
  52648. /**
  52649. * Get the texture reflection matrix used to rotate/transform the reflection.
  52650. * @returns the reflection matrix
  52651. */
  52652. getReflectionTextureMatrix(): Matrix;
  52653. /**
  52654. * Set the texture reflection matrix used to rotate/transform the reflection.
  52655. * @param value Define the reflection matrix to set
  52656. */
  52657. setReflectionTextureMatrix(value: Matrix): void;
  52658. /**
  52659. * Parses a JSON representation of an HDR Texture in order to create the texture
  52660. * @param parsedTexture Define the JSON representation
  52661. * @param scene Define the scene the texture should be created in
  52662. * @param rootUrl Define the root url in case we need to load relative dependencies
  52663. * @returns the newly created texture after parsing
  52664. */
  52665. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52666. serialize(): any;
  52667. }
  52668. }
  52669. declare module BABYLON {
  52670. /**
  52671. * Class used to control physics engine
  52672. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52673. */
  52674. export class PhysicsEngine implements IPhysicsEngine {
  52675. private _physicsPlugin;
  52676. /**
  52677. * Global value used to control the smallest number supported by the simulation
  52678. */
  52679. static Epsilon: number;
  52680. private _impostors;
  52681. private _joints;
  52682. private _subTimeStep;
  52683. /**
  52684. * Gets the gravity vector used by the simulation
  52685. */
  52686. gravity: Vector3;
  52687. /**
  52688. * Factory used to create the default physics plugin.
  52689. * @returns The default physics plugin
  52690. */
  52691. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52692. /**
  52693. * Creates a new Physics Engine
  52694. * @param gravity defines the gravity vector used by the simulation
  52695. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52696. */
  52697. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52698. /**
  52699. * Sets the gravity vector used by the simulation
  52700. * @param gravity defines the gravity vector to use
  52701. */
  52702. setGravity(gravity: Vector3): void;
  52703. /**
  52704. * Set the time step of the physics engine.
  52705. * Default is 1/60.
  52706. * To slow it down, enter 1/600 for example.
  52707. * To speed it up, 1/30
  52708. * @param newTimeStep defines the new timestep to apply to this world.
  52709. */
  52710. setTimeStep(newTimeStep?: number): void;
  52711. /**
  52712. * Get the time step of the physics engine.
  52713. * @returns the current time step
  52714. */
  52715. getTimeStep(): number;
  52716. /**
  52717. * Set the sub time step of the physics engine.
  52718. * Default is 0 meaning there is no sub steps
  52719. * To increase physics resolution precision, set a small value (like 1 ms)
  52720. * @param subTimeStep defines the new sub timestep used for physics resolution.
  52721. */
  52722. setSubTimeStep(subTimeStep?: number): void;
  52723. /**
  52724. * Get the sub time step of the physics engine.
  52725. * @returns the current sub time step
  52726. */
  52727. getSubTimeStep(): number;
  52728. /**
  52729. * Release all resources
  52730. */
  52731. dispose(): void;
  52732. /**
  52733. * Gets the name of the current physics plugin
  52734. * @returns the name of the plugin
  52735. */
  52736. getPhysicsPluginName(): string;
  52737. /**
  52738. * Adding a new impostor for the impostor tracking.
  52739. * This will be done by the impostor itself.
  52740. * @param impostor the impostor to add
  52741. */
  52742. addImpostor(impostor: PhysicsImpostor): void;
  52743. /**
  52744. * Remove an impostor from the engine.
  52745. * This impostor and its mesh will not longer be updated by the physics engine.
  52746. * @param impostor the impostor to remove
  52747. */
  52748. removeImpostor(impostor: PhysicsImpostor): void;
  52749. /**
  52750. * Add a joint to the physics engine
  52751. * @param mainImpostor defines the main impostor to which the joint is added.
  52752. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52753. * @param joint defines the joint that will connect both impostors.
  52754. */
  52755. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52756. /**
  52757. * Removes a joint from the simulation
  52758. * @param mainImpostor defines the impostor used with the joint
  52759. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52760. * @param joint defines the joint to remove
  52761. */
  52762. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52763. /**
  52764. * Called by the scene. No need to call it.
  52765. * @param delta defines the timespam between frames
  52766. */
  52767. _step(delta: number): void;
  52768. /**
  52769. * Gets the current plugin used to run the simulation
  52770. * @returns current plugin
  52771. */
  52772. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52773. /**
  52774. * Gets the list of physic impostors
  52775. * @returns an array of PhysicsImpostor
  52776. */
  52777. getImpostors(): Array<PhysicsImpostor>;
  52778. /**
  52779. * Gets the impostor for a physics enabled object
  52780. * @param object defines the object impersonated by the impostor
  52781. * @returns the PhysicsImpostor or null if not found
  52782. */
  52783. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52784. /**
  52785. * Gets the impostor for a physics body object
  52786. * @param body defines physics body used by the impostor
  52787. * @returns the PhysicsImpostor or null if not found
  52788. */
  52789. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52790. /**
  52791. * Does a raycast in the physics world
  52792. * @param from when should the ray start?
  52793. * @param to when should the ray end?
  52794. * @returns PhysicsRaycastResult
  52795. */
  52796. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52797. }
  52798. }
  52799. declare module BABYLON {
  52800. /** @hidden */
  52801. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52802. private _useDeltaForWorldStep;
  52803. world: any;
  52804. name: string;
  52805. private _physicsMaterials;
  52806. private _fixedTimeStep;
  52807. private _cannonRaycastResult;
  52808. private _raycastResult;
  52809. private _physicsBodysToRemoveAfterStep;
  52810. BJSCANNON: any;
  52811. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52812. setGravity(gravity: Vector3): void;
  52813. setTimeStep(timeStep: number): void;
  52814. getTimeStep(): number;
  52815. executeStep(delta: number): void;
  52816. private _removeMarkedPhysicsBodiesFromWorld;
  52817. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52818. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52819. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52820. private _processChildMeshes;
  52821. removePhysicsBody(impostor: PhysicsImpostor): void;
  52822. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52823. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52824. private _addMaterial;
  52825. private _checkWithEpsilon;
  52826. private _createShape;
  52827. private _createHeightmap;
  52828. private _minus90X;
  52829. private _plus90X;
  52830. private _tmpPosition;
  52831. private _tmpDeltaPosition;
  52832. private _tmpUnityRotation;
  52833. private _updatePhysicsBodyTransformation;
  52834. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52835. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52836. isSupported(): boolean;
  52837. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52838. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52839. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52840. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52841. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52842. getBodyMass(impostor: PhysicsImpostor): number;
  52843. getBodyFriction(impostor: PhysicsImpostor): number;
  52844. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52845. getBodyRestitution(impostor: PhysicsImpostor): number;
  52846. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52847. sleepBody(impostor: PhysicsImpostor): void;
  52848. wakeUpBody(impostor: PhysicsImpostor): void;
  52849. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52850. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52851. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52852. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52853. getRadius(impostor: PhysicsImpostor): number;
  52854. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52855. dispose(): void;
  52856. private _extendNamespace;
  52857. /**
  52858. * Does a raycast in the physics world
  52859. * @param from when should the ray start?
  52860. * @param to when should the ray end?
  52861. * @returns PhysicsRaycastResult
  52862. */
  52863. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52864. }
  52865. }
  52866. declare module BABYLON {
  52867. /** @hidden */
  52868. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52869. world: any;
  52870. name: string;
  52871. BJSOIMO: any;
  52872. private _raycastResult;
  52873. constructor(iterations?: number, oimoInjection?: any);
  52874. setGravity(gravity: Vector3): void;
  52875. setTimeStep(timeStep: number): void;
  52876. getTimeStep(): number;
  52877. private _tmpImpostorsArray;
  52878. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52879. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52880. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52881. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52882. private _tmpPositionVector;
  52883. removePhysicsBody(impostor: PhysicsImpostor): void;
  52884. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52885. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52886. isSupported(): boolean;
  52887. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52888. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52889. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52890. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52891. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52892. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52893. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52894. getBodyMass(impostor: PhysicsImpostor): number;
  52895. getBodyFriction(impostor: PhysicsImpostor): number;
  52896. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52897. getBodyRestitution(impostor: PhysicsImpostor): number;
  52898. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52899. sleepBody(impostor: PhysicsImpostor): void;
  52900. wakeUpBody(impostor: PhysicsImpostor): void;
  52901. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52902. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52903. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52904. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52905. getRadius(impostor: PhysicsImpostor): number;
  52906. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52907. dispose(): void;
  52908. /**
  52909. * Does a raycast in the physics world
  52910. * @param from when should the ray start?
  52911. * @param to when should the ray end?
  52912. * @returns PhysicsRaycastResult
  52913. */
  52914. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52915. }
  52916. }
  52917. declare module BABYLON {
  52918. /**
  52919. * Class containing static functions to help procedurally build meshes
  52920. */
  52921. export class RibbonBuilder {
  52922. /**
  52923. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52924. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52925. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52926. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52927. * * 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
  52928. * * 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
  52929. * * 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
  52930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52931. * * 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
  52932. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52933. * * 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
  52934. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52935. * * 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
  52936. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52938. * @param name defines the name of the mesh
  52939. * @param options defines the options used to create the mesh
  52940. * @param scene defines the hosting scene
  52941. * @returns the ribbon mesh
  52942. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52943. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52944. */
  52945. static CreateRibbon(name: string, options: {
  52946. pathArray: Vector3[][];
  52947. closeArray?: boolean;
  52948. closePath?: boolean;
  52949. offset?: number;
  52950. updatable?: boolean;
  52951. sideOrientation?: number;
  52952. frontUVs?: Vector4;
  52953. backUVs?: Vector4;
  52954. instance?: Mesh;
  52955. invertUV?: boolean;
  52956. uvs?: Vector2[];
  52957. colors?: Color4[];
  52958. }, scene?: Nullable<Scene>): Mesh;
  52959. }
  52960. }
  52961. declare module BABYLON {
  52962. /**
  52963. * Class containing static functions to help procedurally build meshes
  52964. */
  52965. export class ShapeBuilder {
  52966. /**
  52967. * 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.
  52968. * * 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.
  52969. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52970. * * 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.
  52971. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52972. * * 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
  52973. * * 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
  52974. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52976. * * 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
  52977. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52979. * @param name defines the name of the mesh
  52980. * @param options defines the options used to create the mesh
  52981. * @param scene defines the hosting scene
  52982. * @returns the extruded shape mesh
  52983. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52984. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52985. */
  52986. static ExtrudeShape(name: string, options: {
  52987. shape: Vector3[];
  52988. path: Vector3[];
  52989. scale?: number;
  52990. rotation?: number;
  52991. cap?: number;
  52992. updatable?: boolean;
  52993. sideOrientation?: number;
  52994. frontUVs?: Vector4;
  52995. backUVs?: Vector4;
  52996. instance?: Mesh;
  52997. invertUV?: boolean;
  52998. }, scene?: Nullable<Scene>): Mesh;
  52999. /**
  53000. * Creates an custom extruded shape mesh.
  53001. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53002. * * 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.
  53003. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53004. * * 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
  53005. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53006. * * 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
  53007. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53008. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53009. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53010. * * 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
  53011. * * 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
  53012. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53014. * * 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
  53015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53017. * @param name defines the name of the mesh
  53018. * @param options defines the options used to create the mesh
  53019. * @param scene defines the hosting scene
  53020. * @returns the custom extruded shape mesh
  53021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53022. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53024. */
  53025. static ExtrudeShapeCustom(name: string, options: {
  53026. shape: Vector3[];
  53027. path: Vector3[];
  53028. scaleFunction?: any;
  53029. rotationFunction?: any;
  53030. ribbonCloseArray?: boolean;
  53031. ribbonClosePath?: boolean;
  53032. cap?: number;
  53033. updatable?: boolean;
  53034. sideOrientation?: number;
  53035. frontUVs?: Vector4;
  53036. backUVs?: Vector4;
  53037. instance?: Mesh;
  53038. invertUV?: boolean;
  53039. }, scene?: Nullable<Scene>): Mesh;
  53040. private static _ExtrudeShapeGeneric;
  53041. }
  53042. }
  53043. declare module BABYLON {
  53044. /**
  53045. * AmmoJS Physics plugin
  53046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53047. * @see https://github.com/kripken/ammo.js/
  53048. */
  53049. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53050. private _useDeltaForWorldStep;
  53051. /**
  53052. * Reference to the Ammo library
  53053. */
  53054. bjsAMMO: any;
  53055. /**
  53056. * Created ammoJS world which physics bodies are added to
  53057. */
  53058. world: any;
  53059. /**
  53060. * Name of the plugin
  53061. */
  53062. name: string;
  53063. private _timeStep;
  53064. private _fixedTimeStep;
  53065. private _maxSteps;
  53066. private _tmpQuaternion;
  53067. private _tmpAmmoTransform;
  53068. private _tmpAmmoQuaternion;
  53069. private _tmpAmmoConcreteContactResultCallback;
  53070. private _collisionConfiguration;
  53071. private _dispatcher;
  53072. private _overlappingPairCache;
  53073. private _solver;
  53074. private _softBodySolver;
  53075. private _tmpAmmoVectorA;
  53076. private _tmpAmmoVectorB;
  53077. private _tmpAmmoVectorC;
  53078. private _tmpAmmoVectorD;
  53079. private _tmpContactCallbackResult;
  53080. private _tmpAmmoVectorRCA;
  53081. private _tmpAmmoVectorRCB;
  53082. private _raycastResult;
  53083. private static readonly DISABLE_COLLISION_FLAG;
  53084. private static readonly KINEMATIC_FLAG;
  53085. private static readonly DISABLE_DEACTIVATION_FLAG;
  53086. /**
  53087. * Initializes the ammoJS plugin
  53088. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53089. * @param ammoInjection can be used to inject your own ammo reference
  53090. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53091. */
  53092. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53093. /**
  53094. * Sets the gravity of the physics world (m/(s^2))
  53095. * @param gravity Gravity to set
  53096. */
  53097. setGravity(gravity: Vector3): void;
  53098. /**
  53099. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53100. * @param timeStep timestep to use in seconds
  53101. */
  53102. setTimeStep(timeStep: number): void;
  53103. /**
  53104. * 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)
  53105. * @param fixedTimeStep fixedTimeStep to use in seconds
  53106. */
  53107. setFixedTimeStep(fixedTimeStep: number): void;
  53108. /**
  53109. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53110. * @param maxSteps the maximum number of steps by the physics engine per frame
  53111. */
  53112. setMaxSteps(maxSteps: number): void;
  53113. /**
  53114. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53115. * @returns the current timestep in seconds
  53116. */
  53117. getTimeStep(): number;
  53118. /**
  53119. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  53120. */
  53121. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  53122. private _isImpostorInContact;
  53123. private _isImpostorPairInContact;
  53124. private _stepSimulation;
  53125. /**
  53126. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53127. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53128. * After the step the babylon meshes are set to the position of the physics imposters
  53129. * @param delta amount of time to step forward
  53130. * @param impostors array of imposters to update before/after the step
  53131. */
  53132. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53133. /**
  53134. * Update babylon mesh to match physics world object
  53135. * @param impostor imposter to match
  53136. */
  53137. private _afterSoftStep;
  53138. /**
  53139. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53140. * @param impostor imposter to match
  53141. */
  53142. private _ropeStep;
  53143. /**
  53144. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53145. * @param impostor imposter to match
  53146. */
  53147. private _softbodyOrClothStep;
  53148. private _tmpVector;
  53149. private _tmpMatrix;
  53150. /**
  53151. * Applies an impulse on the imposter
  53152. * @param impostor imposter to apply impulse to
  53153. * @param force amount of force to be applied to the imposter
  53154. * @param contactPoint the location to apply the impulse on the imposter
  53155. */
  53156. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53157. /**
  53158. * Applies a force on the imposter
  53159. * @param impostor imposter to apply force
  53160. * @param force amount of force to be applied to the imposter
  53161. * @param contactPoint the location to apply the force on the imposter
  53162. */
  53163. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53164. /**
  53165. * Creates a physics body using the plugin
  53166. * @param impostor the imposter to create the physics body on
  53167. */
  53168. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53169. /**
  53170. * Removes the physics body from the imposter and disposes of the body's memory
  53171. * @param impostor imposter to remove the physics body from
  53172. */
  53173. removePhysicsBody(impostor: PhysicsImpostor): void;
  53174. /**
  53175. * Generates a joint
  53176. * @param impostorJoint the imposter joint to create the joint with
  53177. */
  53178. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53179. /**
  53180. * Removes a joint
  53181. * @param impostorJoint the imposter joint to remove the joint from
  53182. */
  53183. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53184. private _addMeshVerts;
  53185. /**
  53186. * Initialise the soft body vertices to match its object's (mesh) vertices
  53187. * Softbody vertices (nodes) are in world space and to match this
  53188. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53189. * @param impostor to create the softbody for
  53190. */
  53191. private _softVertexData;
  53192. /**
  53193. * Create an impostor's soft body
  53194. * @param impostor to create the softbody for
  53195. */
  53196. private _createSoftbody;
  53197. /**
  53198. * Create cloth for an impostor
  53199. * @param impostor to create the softbody for
  53200. */
  53201. private _createCloth;
  53202. /**
  53203. * Create rope for an impostor
  53204. * @param impostor to create the softbody for
  53205. */
  53206. private _createRope;
  53207. /**
  53208. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  53209. * @param impostor to create the custom physics shape for
  53210. */
  53211. private _createCustom;
  53212. private _addHullVerts;
  53213. private _createShape;
  53214. /**
  53215. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53216. * @param impostor imposter containing the physics body and babylon object
  53217. */
  53218. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53219. /**
  53220. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53221. * @param impostor imposter containing the physics body and babylon object
  53222. * @param newPosition new position
  53223. * @param newRotation new rotation
  53224. */
  53225. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53226. /**
  53227. * If this plugin is supported
  53228. * @returns true if its supported
  53229. */
  53230. isSupported(): boolean;
  53231. /**
  53232. * Sets the linear velocity of the physics body
  53233. * @param impostor imposter to set the velocity on
  53234. * @param velocity velocity to set
  53235. */
  53236. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53237. /**
  53238. * Sets the angular velocity of the physics body
  53239. * @param impostor imposter to set the velocity on
  53240. * @param velocity velocity to set
  53241. */
  53242. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53243. /**
  53244. * gets the linear velocity
  53245. * @param impostor imposter to get linear velocity from
  53246. * @returns linear velocity
  53247. */
  53248. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53249. /**
  53250. * gets the angular velocity
  53251. * @param impostor imposter to get angular velocity from
  53252. * @returns angular velocity
  53253. */
  53254. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53255. /**
  53256. * Sets the mass of physics body
  53257. * @param impostor imposter to set the mass on
  53258. * @param mass mass to set
  53259. */
  53260. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53261. /**
  53262. * Gets the mass of the physics body
  53263. * @param impostor imposter to get the mass from
  53264. * @returns mass
  53265. */
  53266. getBodyMass(impostor: PhysicsImpostor): number;
  53267. /**
  53268. * Gets friction of the impostor
  53269. * @param impostor impostor to get friction from
  53270. * @returns friction value
  53271. */
  53272. getBodyFriction(impostor: PhysicsImpostor): number;
  53273. /**
  53274. * Sets friction of the impostor
  53275. * @param impostor impostor to set friction on
  53276. * @param friction friction value
  53277. */
  53278. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53279. /**
  53280. * Gets restitution of the impostor
  53281. * @param impostor impostor to get restitution from
  53282. * @returns restitution value
  53283. */
  53284. getBodyRestitution(impostor: PhysicsImpostor): number;
  53285. /**
  53286. * Sets resitution of the impostor
  53287. * @param impostor impostor to set resitution on
  53288. * @param restitution resitution value
  53289. */
  53290. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53291. /**
  53292. * Gets pressure inside the impostor
  53293. * @param impostor impostor to get pressure from
  53294. * @returns pressure value
  53295. */
  53296. getBodyPressure(impostor: PhysicsImpostor): number;
  53297. /**
  53298. * Sets pressure inside a soft body impostor
  53299. * Cloth and rope must remain 0 pressure
  53300. * @param impostor impostor to set pressure on
  53301. * @param pressure pressure value
  53302. */
  53303. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53304. /**
  53305. * Gets stiffness of the impostor
  53306. * @param impostor impostor to get stiffness from
  53307. * @returns pressure value
  53308. */
  53309. getBodyStiffness(impostor: PhysicsImpostor): number;
  53310. /**
  53311. * Sets stiffness of the impostor
  53312. * @param impostor impostor to set stiffness on
  53313. * @param stiffness stiffness value from 0 to 1
  53314. */
  53315. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53316. /**
  53317. * Gets velocityIterations of the impostor
  53318. * @param impostor impostor to get velocity iterations from
  53319. * @returns velocityIterations value
  53320. */
  53321. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53322. /**
  53323. * Sets velocityIterations of the impostor
  53324. * @param impostor impostor to set velocity iterations on
  53325. * @param velocityIterations velocityIterations value
  53326. */
  53327. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53328. /**
  53329. * Gets positionIterations of the impostor
  53330. * @param impostor impostor to get position iterations from
  53331. * @returns positionIterations value
  53332. */
  53333. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53334. /**
  53335. * Sets positionIterations of the impostor
  53336. * @param impostor impostor to set position on
  53337. * @param positionIterations positionIterations value
  53338. */
  53339. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53340. /**
  53341. * Append an anchor to a cloth object
  53342. * @param impostor is the cloth impostor to add anchor to
  53343. * @param otherImpostor is the rigid impostor to anchor to
  53344. * @param width ratio across width from 0 to 1
  53345. * @param height ratio up height from 0 to 1
  53346. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53347. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53348. */
  53349. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53350. /**
  53351. * Append an hook to a rope object
  53352. * @param impostor is the rope impostor to add hook to
  53353. * @param otherImpostor is the rigid impostor to hook to
  53354. * @param length ratio along the rope from 0 to 1
  53355. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53356. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53357. */
  53358. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53359. /**
  53360. * Sleeps the physics body and stops it from being active
  53361. * @param impostor impostor to sleep
  53362. */
  53363. sleepBody(impostor: PhysicsImpostor): void;
  53364. /**
  53365. * Activates the physics body
  53366. * @param impostor impostor to activate
  53367. */
  53368. wakeUpBody(impostor: PhysicsImpostor): void;
  53369. /**
  53370. * Updates the distance parameters of the joint
  53371. * @param joint joint to update
  53372. * @param maxDistance maximum distance of the joint
  53373. * @param minDistance minimum distance of the joint
  53374. */
  53375. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53376. /**
  53377. * Sets a motor on the joint
  53378. * @param joint joint to set motor on
  53379. * @param speed speed of the motor
  53380. * @param maxForce maximum force of the motor
  53381. * @param motorIndex index of the motor
  53382. */
  53383. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53384. /**
  53385. * Sets the motors limit
  53386. * @param joint joint to set limit on
  53387. * @param upperLimit upper limit
  53388. * @param lowerLimit lower limit
  53389. */
  53390. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53391. /**
  53392. * Syncs the position and rotation of a mesh with the impostor
  53393. * @param mesh mesh to sync
  53394. * @param impostor impostor to update the mesh with
  53395. */
  53396. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53397. /**
  53398. * Gets the radius of the impostor
  53399. * @param impostor impostor to get radius from
  53400. * @returns the radius
  53401. */
  53402. getRadius(impostor: PhysicsImpostor): number;
  53403. /**
  53404. * Gets the box size of the impostor
  53405. * @param impostor impostor to get box size from
  53406. * @param result the resulting box size
  53407. */
  53408. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53409. /**
  53410. * Disposes of the impostor
  53411. */
  53412. dispose(): void;
  53413. /**
  53414. * Does a raycast in the physics world
  53415. * @param from when should the ray start?
  53416. * @param to when should the ray end?
  53417. * @returns PhysicsRaycastResult
  53418. */
  53419. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53420. }
  53421. }
  53422. declare module BABYLON {
  53423. interface AbstractScene {
  53424. /**
  53425. * The list of reflection probes added to the scene
  53426. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53427. */
  53428. reflectionProbes: Array<ReflectionProbe>;
  53429. /**
  53430. * Removes the given reflection probe from this scene.
  53431. * @param toRemove The reflection probe to remove
  53432. * @returns The index of the removed reflection probe
  53433. */
  53434. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53435. /**
  53436. * Adds the given reflection probe to this scene.
  53437. * @param newReflectionProbe The reflection probe to add
  53438. */
  53439. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53440. }
  53441. /**
  53442. * Class used to generate realtime reflection / refraction cube textures
  53443. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53444. */
  53445. export class ReflectionProbe {
  53446. /** defines the name of the probe */
  53447. name: string;
  53448. private _scene;
  53449. private _renderTargetTexture;
  53450. private _projectionMatrix;
  53451. private _viewMatrix;
  53452. private _target;
  53453. private _add;
  53454. private _attachedMesh;
  53455. private _invertYAxis;
  53456. /** Gets or sets probe position (center of the cube map) */
  53457. position: Vector3;
  53458. /**
  53459. * Creates a new reflection probe
  53460. * @param name defines the name of the probe
  53461. * @param size defines the texture resolution (for each face)
  53462. * @param scene defines the hosting scene
  53463. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53464. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53465. */
  53466. constructor(
  53467. /** defines the name of the probe */
  53468. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53469. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53470. samples: number;
  53471. /** Gets or sets the refresh rate to use (on every frame by default) */
  53472. refreshRate: number;
  53473. /**
  53474. * Gets the hosting scene
  53475. * @returns a Scene
  53476. */
  53477. getScene(): Scene;
  53478. /** Gets the internal CubeTexture used to render to */
  53479. readonly cubeTexture: RenderTargetTexture;
  53480. /** Gets the list of meshes to render */
  53481. readonly renderList: Nullable<AbstractMesh[]>;
  53482. /**
  53483. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53484. * @param mesh defines the mesh to attach to
  53485. */
  53486. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53487. /**
  53488. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53489. * @param renderingGroupId The rendering group id corresponding to its index
  53490. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53491. */
  53492. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53493. /**
  53494. * Clean all associated resources
  53495. */
  53496. dispose(): void;
  53497. /**
  53498. * Converts the reflection probe information to a readable string for debug purpose.
  53499. * @param fullDetails Supports for multiple levels of logging within scene loading
  53500. * @returns the human readable reflection probe info
  53501. */
  53502. toString(fullDetails?: boolean): string;
  53503. /**
  53504. * Get the class name of the relfection probe.
  53505. * @returns "ReflectionProbe"
  53506. */
  53507. getClassName(): string;
  53508. /**
  53509. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53510. * @returns The JSON representation of the texture
  53511. */
  53512. serialize(): any;
  53513. /**
  53514. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53515. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53516. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53517. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53518. * @returns The parsed reflection probe if successful
  53519. */
  53520. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53521. }
  53522. }
  53523. declare module BABYLON {
  53524. /** @hidden */
  53525. export var _BabylonLoaderRegistered: boolean;
  53526. /**
  53527. * Helps setting up some configuration for the babylon file loader.
  53528. */
  53529. export class BabylonFileLoaderConfiguration {
  53530. /**
  53531. * The loader does not allow injecting custom physix engine into the plugins.
  53532. * Unfortunately in ES6, we need to manually inject them into the plugin.
  53533. * So you could set this variable to your engine import to make it work.
  53534. */
  53535. static LoaderInjectedPhysicsEngine: any;
  53536. }
  53537. }
  53538. declare module BABYLON {
  53539. /**
  53540. * The Physically based simple base material of BJS.
  53541. *
  53542. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53543. * It is used as the base class for both the specGloss and metalRough conventions.
  53544. */
  53545. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53546. /**
  53547. * Number of Simultaneous lights allowed on the material.
  53548. */
  53549. maxSimultaneousLights: number;
  53550. /**
  53551. * If sets to true, disables all the lights affecting the material.
  53552. */
  53553. disableLighting: boolean;
  53554. /**
  53555. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53556. */
  53557. environmentTexture: BaseTexture;
  53558. /**
  53559. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53560. */
  53561. invertNormalMapX: boolean;
  53562. /**
  53563. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53564. */
  53565. invertNormalMapY: boolean;
  53566. /**
  53567. * Normal map used in the model.
  53568. */
  53569. normalTexture: BaseTexture;
  53570. /**
  53571. * Emissivie color used to self-illuminate the model.
  53572. */
  53573. emissiveColor: Color3;
  53574. /**
  53575. * Emissivie texture used to self-illuminate the model.
  53576. */
  53577. emissiveTexture: BaseTexture;
  53578. /**
  53579. * Occlusion Channel Strenght.
  53580. */
  53581. occlusionStrength: number;
  53582. /**
  53583. * Occlusion Texture of the material (adding extra occlusion effects).
  53584. */
  53585. occlusionTexture: BaseTexture;
  53586. /**
  53587. * Defines the alpha limits in alpha test mode.
  53588. */
  53589. alphaCutOff: number;
  53590. /**
  53591. * Gets the current double sided mode.
  53592. */
  53593. /**
  53594. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53595. */
  53596. doubleSided: boolean;
  53597. /**
  53598. * Stores the pre-calculated light information of a mesh in a texture.
  53599. */
  53600. lightmapTexture: BaseTexture;
  53601. /**
  53602. * If true, the light map contains occlusion information instead of lighting info.
  53603. */
  53604. useLightmapAsShadowmap: boolean;
  53605. /**
  53606. * Instantiates a new PBRMaterial instance.
  53607. *
  53608. * @param name The material name
  53609. * @param scene The scene the material will be use in.
  53610. */
  53611. constructor(name: string, scene: Scene);
  53612. getClassName(): string;
  53613. }
  53614. }
  53615. declare module BABYLON {
  53616. /**
  53617. * The PBR material of BJS following the metal roughness convention.
  53618. *
  53619. * This fits to the PBR convention in the GLTF definition:
  53620. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53621. */
  53622. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53623. /**
  53624. * The base color has two different interpretations depending on the value of metalness.
  53625. * When the material is a metal, the base color is the specific measured reflectance value
  53626. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53627. * of the material.
  53628. */
  53629. baseColor: Color3;
  53630. /**
  53631. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53632. * well as opacity information in the alpha channel.
  53633. */
  53634. baseTexture: BaseTexture;
  53635. /**
  53636. * Specifies the metallic scalar value of the material.
  53637. * Can also be used to scale the metalness values of the metallic texture.
  53638. */
  53639. metallic: number;
  53640. /**
  53641. * Specifies the roughness scalar value of the material.
  53642. * Can also be used to scale the roughness values of the metallic texture.
  53643. */
  53644. roughness: number;
  53645. /**
  53646. * Texture containing both the metallic value in the B channel and the
  53647. * roughness value in the G channel to keep better precision.
  53648. */
  53649. metallicRoughnessTexture: BaseTexture;
  53650. /**
  53651. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53652. *
  53653. * @param name The material name
  53654. * @param scene The scene the material will be use in.
  53655. */
  53656. constructor(name: string, scene: Scene);
  53657. /**
  53658. * Return the currrent class name of the material.
  53659. */
  53660. getClassName(): string;
  53661. /**
  53662. * Makes a duplicate of the current material.
  53663. * @param name - name to use for the new material.
  53664. */
  53665. clone(name: string): PBRMetallicRoughnessMaterial;
  53666. /**
  53667. * Serialize the material to a parsable JSON object.
  53668. */
  53669. serialize(): any;
  53670. /**
  53671. * Parses a JSON object correponding to the serialize function.
  53672. */
  53673. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53674. }
  53675. }
  53676. declare module BABYLON {
  53677. /**
  53678. * The PBR material of BJS following the specular glossiness convention.
  53679. *
  53680. * This fits to the PBR convention in the GLTF definition:
  53681. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53682. */
  53683. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53684. /**
  53685. * Specifies the diffuse color of the material.
  53686. */
  53687. diffuseColor: Color3;
  53688. /**
  53689. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53690. * channel.
  53691. */
  53692. diffuseTexture: BaseTexture;
  53693. /**
  53694. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53695. */
  53696. specularColor: Color3;
  53697. /**
  53698. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53699. */
  53700. glossiness: number;
  53701. /**
  53702. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53703. */
  53704. specularGlossinessTexture: BaseTexture;
  53705. /**
  53706. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53707. *
  53708. * @param name The material name
  53709. * @param scene The scene the material will be use in.
  53710. */
  53711. constructor(name: string, scene: Scene);
  53712. /**
  53713. * Return the currrent class name of the material.
  53714. */
  53715. getClassName(): string;
  53716. /**
  53717. * Makes a duplicate of the current material.
  53718. * @param name - name to use for the new material.
  53719. */
  53720. clone(name: string): PBRSpecularGlossinessMaterial;
  53721. /**
  53722. * Serialize the material to a parsable JSON object.
  53723. */
  53724. serialize(): any;
  53725. /**
  53726. * Parses a JSON object correponding to the serialize function.
  53727. */
  53728. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53729. }
  53730. }
  53731. declare module BABYLON {
  53732. /**
  53733. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53734. * It can help converting any input color in a desired output one. This can then be used to create effects
  53735. * from sepia, black and white to sixties or futuristic rendering...
  53736. *
  53737. * The only supported format is currently 3dl.
  53738. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53739. */
  53740. export class ColorGradingTexture extends BaseTexture {
  53741. /**
  53742. * The current texture matrix. (will always be identity in color grading texture)
  53743. */
  53744. private _textureMatrix;
  53745. /**
  53746. * The texture URL.
  53747. */
  53748. url: string;
  53749. /**
  53750. * Empty line regex stored for GC.
  53751. */
  53752. private static _noneEmptyLineRegex;
  53753. private _engine;
  53754. /**
  53755. * Instantiates a ColorGradingTexture from the following parameters.
  53756. *
  53757. * @param url The location of the color gradind data (currently only supporting 3dl)
  53758. * @param scene The scene the texture will be used in
  53759. */
  53760. constructor(url: string, scene: Scene);
  53761. /**
  53762. * Returns the texture matrix used in most of the material.
  53763. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53764. */
  53765. getTextureMatrix(): Matrix;
  53766. /**
  53767. * Occurs when the file being loaded is a .3dl LUT file.
  53768. */
  53769. private load3dlTexture;
  53770. /**
  53771. * Starts the loading process of the texture.
  53772. */
  53773. private loadTexture;
  53774. /**
  53775. * Clones the color gradind texture.
  53776. */
  53777. clone(): ColorGradingTexture;
  53778. /**
  53779. * Called during delayed load for textures.
  53780. */
  53781. delayLoad(): void;
  53782. /**
  53783. * Parses a color grading texture serialized by Babylon.
  53784. * @param parsedTexture The texture information being parsedTexture
  53785. * @param scene The scene to load the texture in
  53786. * @param rootUrl The root url of the data assets to load
  53787. * @return A color gradind texture
  53788. */
  53789. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53790. /**
  53791. * Serializes the LUT texture to json format.
  53792. */
  53793. serialize(): any;
  53794. }
  53795. }
  53796. declare module BABYLON {
  53797. /**
  53798. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53799. */
  53800. export class EquiRectangularCubeTexture extends BaseTexture {
  53801. /** The six faces of the cube. */
  53802. private static _FacesMapping;
  53803. private _noMipmap;
  53804. private _onLoad;
  53805. private _onError;
  53806. /** The size of the cubemap. */
  53807. private _size;
  53808. /** The buffer of the image. */
  53809. private _buffer;
  53810. /** The width of the input image. */
  53811. private _width;
  53812. /** The height of the input image. */
  53813. private _height;
  53814. /** The URL to the image. */
  53815. url: string;
  53816. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53817. coordinatesMode: number;
  53818. /**
  53819. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53820. * @param url The location of the image
  53821. * @param scene The scene the texture will be used in
  53822. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53823. * @param noMipmap Forces to not generate the mipmap if true
  53824. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53825. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53826. * @param onLoad — defines a callback called when texture is loaded
  53827. * @param onError — defines a callback called if there is an error
  53828. */
  53829. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53830. /**
  53831. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53832. */
  53833. private loadImage;
  53834. /**
  53835. * Convert the image buffer into a cubemap and create a CubeTexture.
  53836. */
  53837. private loadTexture;
  53838. /**
  53839. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53840. * @param buffer The ArrayBuffer that should be converted.
  53841. * @returns The buffer as Float32Array.
  53842. */
  53843. private getFloat32ArrayFromArrayBuffer;
  53844. /**
  53845. * Get the current class name of the texture useful for serialization or dynamic coding.
  53846. * @returns "EquiRectangularCubeTexture"
  53847. */
  53848. getClassName(): string;
  53849. /**
  53850. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53851. * @returns A clone of the current EquiRectangularCubeTexture.
  53852. */
  53853. clone(): EquiRectangularCubeTexture;
  53854. }
  53855. }
  53856. declare module BABYLON {
  53857. /**
  53858. * Based on jsTGALoader - Javascript loader for TGA file
  53859. * By Vincent Thibault
  53860. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53861. */
  53862. export class TGATools {
  53863. private static _TYPE_INDEXED;
  53864. private static _TYPE_RGB;
  53865. private static _TYPE_GREY;
  53866. private static _TYPE_RLE_INDEXED;
  53867. private static _TYPE_RLE_RGB;
  53868. private static _TYPE_RLE_GREY;
  53869. private static _ORIGIN_MASK;
  53870. private static _ORIGIN_SHIFT;
  53871. private static _ORIGIN_BL;
  53872. private static _ORIGIN_BR;
  53873. private static _ORIGIN_UL;
  53874. private static _ORIGIN_UR;
  53875. /**
  53876. * Gets the header of a TGA file
  53877. * @param data defines the TGA data
  53878. * @returns the header
  53879. */
  53880. static GetTGAHeader(data: Uint8Array): any;
  53881. /**
  53882. * Uploads TGA content to a Babylon Texture
  53883. * @hidden
  53884. */
  53885. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53886. /** @hidden */
  53887. 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;
  53888. /** @hidden */
  53889. 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;
  53890. /** @hidden */
  53891. 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;
  53892. /** @hidden */
  53893. 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;
  53894. /** @hidden */
  53895. 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;
  53896. /** @hidden */
  53897. 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;
  53898. }
  53899. }
  53900. declare module BABYLON {
  53901. /**
  53902. * Implementation of the TGA Texture Loader.
  53903. * @hidden
  53904. */
  53905. export class _TGATextureLoader implements IInternalTextureLoader {
  53906. /**
  53907. * Defines wether the loader supports cascade loading the different faces.
  53908. */
  53909. readonly supportCascades: boolean;
  53910. /**
  53911. * This returns if the loader support the current file information.
  53912. * @param extension defines the file extension of the file being loaded
  53913. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53914. * @param fallback defines the fallback internal texture if any
  53915. * @param isBase64 defines whether the texture is encoded as a base64
  53916. * @param isBuffer defines whether the texture data are stored as a buffer
  53917. * @returns true if the loader can load the specified file
  53918. */
  53919. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53920. /**
  53921. * Transform the url before loading if required.
  53922. * @param rootUrl the url of the texture
  53923. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53924. * @returns the transformed texture
  53925. */
  53926. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53927. /**
  53928. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53929. * @param rootUrl the url of the texture
  53930. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53931. * @returns the fallback texture
  53932. */
  53933. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53934. /**
  53935. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53936. * @param data contains the texture data
  53937. * @param texture defines the BabylonJS internal texture
  53938. * @param createPolynomials will be true if polynomials have been requested
  53939. * @param onLoad defines the callback to trigger once the texture is ready
  53940. * @param onError defines the callback to trigger in case of error
  53941. */
  53942. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53943. /**
  53944. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53945. * @param data contains the texture data
  53946. * @param texture defines the BabylonJS internal texture
  53947. * @param callback defines the method to call once ready to upload
  53948. */
  53949. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53950. }
  53951. }
  53952. declare module BABYLON {
  53953. /**
  53954. * Info about the .basis files
  53955. */
  53956. class BasisFileInfo {
  53957. /**
  53958. * If the file has alpha
  53959. */
  53960. hasAlpha: boolean;
  53961. /**
  53962. * Info about each image of the basis file
  53963. */
  53964. images: Array<{
  53965. levels: Array<{
  53966. width: number;
  53967. height: number;
  53968. transcodedPixels: ArrayBufferView;
  53969. }>;
  53970. }>;
  53971. }
  53972. /**
  53973. * Result of transcoding a basis file
  53974. */
  53975. class TranscodeResult {
  53976. /**
  53977. * Info about the .basis file
  53978. */
  53979. fileInfo: BasisFileInfo;
  53980. /**
  53981. * Format to use when loading the file
  53982. */
  53983. format: number;
  53984. }
  53985. /**
  53986. * Configuration options for the Basis transcoder
  53987. */
  53988. export class BasisTranscodeConfiguration {
  53989. /**
  53990. * Supported compression formats used to determine the supported output format of the transcoder
  53991. */
  53992. supportedCompressionFormats?: {
  53993. /**
  53994. * etc1 compression format
  53995. */
  53996. etc1?: boolean;
  53997. /**
  53998. * s3tc compression format
  53999. */
  54000. s3tc?: boolean;
  54001. /**
  54002. * pvrtc compression format
  54003. */
  54004. pvrtc?: boolean;
  54005. /**
  54006. * etc2 compression format
  54007. */
  54008. etc2?: boolean;
  54009. };
  54010. /**
  54011. * If mipmap levels should be loaded for transcoded images (Default: true)
  54012. */
  54013. loadMipmapLevels?: boolean;
  54014. /**
  54015. * Index of a single image to load (Default: all images)
  54016. */
  54017. loadSingleImage?: number;
  54018. }
  54019. /**
  54020. * Used to load .Basis files
  54021. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54022. */
  54023. export class BasisTools {
  54024. private static _IgnoreSupportedFormats;
  54025. /**
  54026. * URL to use when loading the basis transcoder
  54027. */
  54028. static JSModuleURL: string;
  54029. /**
  54030. * URL to use when loading the wasm module for the transcoder
  54031. */
  54032. static WasmModuleURL: string;
  54033. /**
  54034. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54035. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54036. * @returns internal format corresponding to the Basis format
  54037. */
  54038. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54039. private static _WorkerPromise;
  54040. private static _Worker;
  54041. private static _actionId;
  54042. private static _CreateWorkerAsync;
  54043. /**
  54044. * Transcodes a loaded image file to compressed pixel data
  54045. * @param imageData image data to transcode
  54046. * @param config configuration options for the transcoding
  54047. * @returns a promise resulting in the transcoded image
  54048. */
  54049. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54050. /**
  54051. * Loads a texture from the transcode result
  54052. * @param texture texture load to
  54053. * @param transcodeResult the result of transcoding the basis file to load from
  54054. */
  54055. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54056. }
  54057. }
  54058. declare module BABYLON {
  54059. /**
  54060. * Loader for .basis file format
  54061. */
  54062. export class _BasisTextureLoader implements IInternalTextureLoader {
  54063. /**
  54064. * Defines whether the loader supports cascade loading the different faces.
  54065. */
  54066. readonly supportCascades: boolean;
  54067. /**
  54068. * This returns if the loader support the current file information.
  54069. * @param extension defines the file extension of the file being loaded
  54070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54071. * @param fallback defines the fallback internal texture if any
  54072. * @param isBase64 defines whether the texture is encoded as a base64
  54073. * @param isBuffer defines whether the texture data are stored as a buffer
  54074. * @returns true if the loader can load the specified file
  54075. */
  54076. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54077. /**
  54078. * Transform the url before loading if required.
  54079. * @param rootUrl the url of the texture
  54080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54081. * @returns the transformed texture
  54082. */
  54083. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54084. /**
  54085. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54086. * @param rootUrl the url of the texture
  54087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54088. * @returns the fallback texture
  54089. */
  54090. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54091. /**
  54092. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54093. * @param data contains the texture data
  54094. * @param texture defines the BabylonJS internal texture
  54095. * @param createPolynomials will be true if polynomials have been requested
  54096. * @param onLoad defines the callback to trigger once the texture is ready
  54097. * @param onError defines the callback to trigger in case of error
  54098. */
  54099. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54100. /**
  54101. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54102. * @param data contains the texture data
  54103. * @param texture defines the BabylonJS internal texture
  54104. * @param callback defines the method to call once ready to upload
  54105. */
  54106. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54107. }
  54108. }
  54109. declare module BABYLON {
  54110. /**
  54111. * 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.
  54112. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54113. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54114. */
  54115. export class CustomProceduralTexture extends ProceduralTexture {
  54116. private _animate;
  54117. private _time;
  54118. private _config;
  54119. private _texturePath;
  54120. /**
  54121. * Instantiates a new Custom Procedural Texture.
  54122. * 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.
  54123. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54124. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54125. * @param name Define the name of the texture
  54126. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54127. * @param size Define the size of the texture to create
  54128. * @param scene Define the scene the texture belongs to
  54129. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54130. * @param generateMipMaps Define if the texture should creates mip maps or not
  54131. */
  54132. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54133. private _loadJson;
  54134. /**
  54135. * Is the texture ready to be used ? (rendered at least once)
  54136. * @returns true if ready, otherwise, false.
  54137. */
  54138. isReady(): boolean;
  54139. /**
  54140. * Render the texture to its associated render target.
  54141. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54142. */
  54143. render(useCameraPostProcess?: boolean): void;
  54144. /**
  54145. * Update the list of dependant textures samplers in the shader.
  54146. */
  54147. updateTextures(): void;
  54148. /**
  54149. * Update the uniform values of the procedural texture in the shader.
  54150. */
  54151. updateShaderUniforms(): void;
  54152. /**
  54153. * Define if the texture animates or not.
  54154. */
  54155. animate: boolean;
  54156. }
  54157. }
  54158. declare module BABYLON {
  54159. /** @hidden */
  54160. export var noisePixelShader: {
  54161. name: string;
  54162. shader: string;
  54163. };
  54164. }
  54165. declare module BABYLON {
  54166. /**
  54167. * Class used to generate noise procedural textures
  54168. */
  54169. export class NoiseProceduralTexture extends ProceduralTexture {
  54170. private _time;
  54171. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54172. brightness: number;
  54173. /** Defines the number of octaves to process */
  54174. octaves: number;
  54175. /** Defines the level of persistence (0.8 by default) */
  54176. persistence: number;
  54177. /** Gets or sets animation speed factor (default is 1) */
  54178. animationSpeedFactor: number;
  54179. /**
  54180. * Creates a new NoiseProceduralTexture
  54181. * @param name defines the name fo the texture
  54182. * @param size defines the size of the texture (default is 256)
  54183. * @param scene defines the hosting scene
  54184. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54185. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54186. */
  54187. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54188. private _updateShaderUniforms;
  54189. protected _getDefines(): string;
  54190. /** Generate the current state of the procedural texture */
  54191. render(useCameraPostProcess?: boolean): void;
  54192. /**
  54193. * Serializes this noise procedural texture
  54194. * @returns a serialized noise procedural texture object
  54195. */
  54196. serialize(): any;
  54197. /**
  54198. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54199. * @param parsedTexture defines parsed texture data
  54200. * @param scene defines the current scene
  54201. * @param rootUrl defines the root URL containing noise procedural texture information
  54202. * @returns a parsed NoiseProceduralTexture
  54203. */
  54204. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54205. }
  54206. }
  54207. declare module BABYLON {
  54208. /**
  54209. * Raw cube texture where the raw buffers are passed in
  54210. */
  54211. export class RawCubeTexture extends CubeTexture {
  54212. /**
  54213. * Creates a cube texture where the raw buffers are passed in.
  54214. * @param scene defines the scene the texture is attached to
  54215. * @param data defines the array of data to use to create each face
  54216. * @param size defines the size of the textures
  54217. * @param format defines the format of the data
  54218. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54219. * @param generateMipMaps defines if the engine should generate the mip levels
  54220. * @param invertY defines if data must be stored with Y axis inverted
  54221. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54222. * @param compression defines the compression used (null by default)
  54223. */
  54224. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54225. /**
  54226. * Updates the raw cube texture.
  54227. * @param data defines the data to store
  54228. * @param format defines the data format
  54229. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54230. * @param invertY defines if data must be stored with Y axis inverted
  54231. * @param compression defines the compression used (null by default)
  54232. * @param level defines which level of the texture to update
  54233. */
  54234. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54235. /**
  54236. * Updates a raw cube texture with RGBD encoded data.
  54237. * @param data defines the array of data [mipmap][face] to use to create each face
  54238. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54239. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54240. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54241. * @returns a promsie that resolves when the operation is complete
  54242. */
  54243. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54244. /**
  54245. * Clones the raw cube texture.
  54246. * @return a new cube texture
  54247. */
  54248. clone(): CubeTexture;
  54249. /** @hidden */
  54250. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54251. }
  54252. }
  54253. declare module BABYLON {
  54254. /**
  54255. * Class used to store 3D textures containing user data
  54256. */
  54257. export class RawTexture3D extends Texture {
  54258. /** Gets or sets the texture format to use */
  54259. format: number;
  54260. private _engine;
  54261. /**
  54262. * Create a new RawTexture3D
  54263. * @param data defines the data of the texture
  54264. * @param width defines the width of the texture
  54265. * @param height defines the height of the texture
  54266. * @param depth defines the depth of the texture
  54267. * @param format defines the texture format to use
  54268. * @param scene defines the hosting scene
  54269. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54270. * @param invertY defines if texture must be stored with Y axis inverted
  54271. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54272. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54273. */
  54274. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54275. /** Gets or sets the texture format to use */
  54276. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54277. /**
  54278. * Update the texture with new data
  54279. * @param data defines the data to store in the texture
  54280. */
  54281. update(data: ArrayBufferView): void;
  54282. }
  54283. }
  54284. declare module BABYLON {
  54285. /**
  54286. * Class used to store 2D array textures containing user data
  54287. */
  54288. export class RawTexture2DArray extends Texture {
  54289. /** Gets or sets the texture format to use */
  54290. format: number;
  54291. private _engine;
  54292. /**
  54293. * Create a new RawTexture2DArray
  54294. * @param data defines the data of the texture
  54295. * @param width defines the width of the texture
  54296. * @param height defines the height of the texture
  54297. * @param depth defines the number of layers of the texture
  54298. * @param format defines the texture format to use
  54299. * @param scene defines the hosting scene
  54300. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54301. * @param invertY defines if texture must be stored with Y axis inverted
  54302. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54303. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54304. */
  54305. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54306. /** Gets or sets the texture format to use */
  54307. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54308. /**
  54309. * Update the texture with new data
  54310. * @param data defines the data to store in the texture
  54311. */
  54312. update(data: ArrayBufferView): void;
  54313. }
  54314. }
  54315. declare module BABYLON {
  54316. /**
  54317. * Creates a refraction texture used by refraction channel of the standard material.
  54318. * It is like a mirror but to see through a material.
  54319. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54320. */
  54321. export class RefractionTexture extends RenderTargetTexture {
  54322. /**
  54323. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54324. * 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.
  54325. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54326. */
  54327. refractionPlane: Plane;
  54328. /**
  54329. * Define how deep under the surface we should see.
  54330. */
  54331. depth: number;
  54332. /**
  54333. * Creates a refraction texture used by refraction channel of the standard material.
  54334. * It is like a mirror but to see through a material.
  54335. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54336. * @param name Define the texture name
  54337. * @param size Define the size of the underlying texture
  54338. * @param scene Define the scene the refraction belongs to
  54339. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54340. */
  54341. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54342. /**
  54343. * Clone the refraction texture.
  54344. * @returns the cloned texture
  54345. */
  54346. clone(): RefractionTexture;
  54347. /**
  54348. * Serialize the texture to a JSON representation you could use in Parse later on
  54349. * @returns the serialized JSON representation
  54350. */
  54351. serialize(): any;
  54352. }
  54353. }
  54354. declare module BABYLON {
  54355. /**
  54356. * Defines the options related to the creation of an HtmlElementTexture
  54357. */
  54358. export interface IHtmlElementTextureOptions {
  54359. /**
  54360. * Defines wether mip maps should be created or not.
  54361. */
  54362. generateMipMaps?: boolean;
  54363. /**
  54364. * Defines the sampling mode of the texture.
  54365. */
  54366. samplingMode?: number;
  54367. /**
  54368. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54369. */
  54370. engine: Nullable<ThinEngine>;
  54371. /**
  54372. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54373. */
  54374. scene: Nullable<Scene>;
  54375. }
  54376. /**
  54377. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54378. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54379. * is automatically managed.
  54380. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54381. * in your application.
  54382. *
  54383. * As the update is not automatic, you need to call them manually.
  54384. */
  54385. export class HtmlElementTexture extends BaseTexture {
  54386. /**
  54387. * The texture URL.
  54388. */
  54389. element: HTMLVideoElement | HTMLCanvasElement;
  54390. private static readonly DefaultOptions;
  54391. private _textureMatrix;
  54392. private _engine;
  54393. private _isVideo;
  54394. private _generateMipMaps;
  54395. private _samplingMode;
  54396. /**
  54397. * Instantiates a HtmlElementTexture from the following parameters.
  54398. *
  54399. * @param name Defines the name of the texture
  54400. * @param element Defines the video or canvas the texture is filled with
  54401. * @param options Defines the other none mandatory texture creation options
  54402. */
  54403. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54404. private _createInternalTexture;
  54405. /**
  54406. * Returns the texture matrix used in most of the material.
  54407. */
  54408. getTextureMatrix(): Matrix;
  54409. /**
  54410. * Updates the content of the texture.
  54411. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54412. */
  54413. update(invertY?: Nullable<boolean>): void;
  54414. }
  54415. }
  54416. declare module BABYLON {
  54417. /**
  54418. * Enum used to define the target of a block
  54419. */
  54420. export enum NodeMaterialBlockTargets {
  54421. /** Vertex shader */
  54422. Vertex = 1,
  54423. /** Fragment shader */
  54424. Fragment = 2,
  54425. /** Neutral */
  54426. Neutral = 4,
  54427. /** Vertex and Fragment */
  54428. VertexAndFragment = 3
  54429. }
  54430. }
  54431. declare module BABYLON {
  54432. /**
  54433. * Defines the kind of connection point for node based material
  54434. */
  54435. export enum NodeMaterialBlockConnectionPointTypes {
  54436. /** Float */
  54437. Float = 1,
  54438. /** Int */
  54439. Int = 2,
  54440. /** Vector2 */
  54441. Vector2 = 4,
  54442. /** Vector3 */
  54443. Vector3 = 8,
  54444. /** Vector4 */
  54445. Vector4 = 16,
  54446. /** Color3 */
  54447. Color3 = 32,
  54448. /** Color4 */
  54449. Color4 = 64,
  54450. /** Matrix */
  54451. Matrix = 128,
  54452. /** Detect type based on connection */
  54453. AutoDetect = 1024,
  54454. /** Output type that will be defined by input type */
  54455. BasedOnInput = 2048
  54456. }
  54457. }
  54458. declare module BABYLON {
  54459. /**
  54460. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54461. */
  54462. export enum NodeMaterialBlockConnectionPointMode {
  54463. /** Value is an uniform */
  54464. Uniform = 0,
  54465. /** Value is a mesh attribute */
  54466. Attribute = 1,
  54467. /** Value is a varying between vertex and fragment shaders */
  54468. Varying = 2,
  54469. /** Mode is undefined */
  54470. Undefined = 3
  54471. }
  54472. }
  54473. declare module BABYLON {
  54474. /**
  54475. * Enum used to define system values e.g. values automatically provided by the system
  54476. */
  54477. export enum NodeMaterialSystemValues {
  54478. /** World */
  54479. World = 1,
  54480. /** View */
  54481. View = 2,
  54482. /** Projection */
  54483. Projection = 3,
  54484. /** ViewProjection */
  54485. ViewProjection = 4,
  54486. /** WorldView */
  54487. WorldView = 5,
  54488. /** WorldViewProjection */
  54489. WorldViewProjection = 6,
  54490. /** CameraPosition */
  54491. CameraPosition = 7,
  54492. /** Fog Color */
  54493. FogColor = 8,
  54494. /** Delta time */
  54495. DeltaTime = 9
  54496. }
  54497. }
  54498. declare module BABYLON {
  54499. /**
  54500. * Root class for all node material optimizers
  54501. */
  54502. export class NodeMaterialOptimizer {
  54503. /**
  54504. * Function used to optimize a NodeMaterial graph
  54505. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54506. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54507. */
  54508. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54509. }
  54510. }
  54511. declare module BABYLON {
  54512. /**
  54513. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54514. */
  54515. export class TransformBlock extends NodeMaterialBlock {
  54516. /**
  54517. * Defines the value to use to complement W value to transform it to a Vector4
  54518. */
  54519. complementW: number;
  54520. /**
  54521. * Defines the value to use to complement z value to transform it to a Vector4
  54522. */
  54523. complementZ: number;
  54524. /**
  54525. * Creates a new TransformBlock
  54526. * @param name defines the block name
  54527. */
  54528. constructor(name: string);
  54529. /**
  54530. * Gets the current class name
  54531. * @returns the class name
  54532. */
  54533. getClassName(): string;
  54534. /**
  54535. * Gets the vector input
  54536. */
  54537. readonly vector: NodeMaterialConnectionPoint;
  54538. /**
  54539. * Gets the output component
  54540. */
  54541. readonly output: NodeMaterialConnectionPoint;
  54542. /**
  54543. * Gets the matrix transform input
  54544. */
  54545. readonly transform: NodeMaterialConnectionPoint;
  54546. protected _buildBlock(state: NodeMaterialBuildState): this;
  54547. serialize(): any;
  54548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54549. protected _dumpPropertiesCode(): string;
  54550. }
  54551. }
  54552. declare module BABYLON {
  54553. /**
  54554. * Block used to output the vertex position
  54555. */
  54556. export class VertexOutputBlock extends NodeMaterialBlock {
  54557. /**
  54558. * Creates a new VertexOutputBlock
  54559. * @param name defines the block name
  54560. */
  54561. constructor(name: string);
  54562. /**
  54563. * Gets the current class name
  54564. * @returns the class name
  54565. */
  54566. getClassName(): string;
  54567. /**
  54568. * Gets the vector input component
  54569. */
  54570. readonly vector: NodeMaterialConnectionPoint;
  54571. protected _buildBlock(state: NodeMaterialBuildState): this;
  54572. }
  54573. }
  54574. declare module BABYLON {
  54575. /**
  54576. * Block used to output the final color
  54577. */
  54578. export class FragmentOutputBlock extends NodeMaterialBlock {
  54579. /**
  54580. * Create a new FragmentOutputBlock
  54581. * @param name defines the block name
  54582. */
  54583. constructor(name: string);
  54584. /**
  54585. * Gets the current class name
  54586. * @returns the class name
  54587. */
  54588. getClassName(): string;
  54589. /**
  54590. * Gets the rgba input component
  54591. */
  54592. readonly rgba: NodeMaterialConnectionPoint;
  54593. /**
  54594. * Gets the rgb input component
  54595. */
  54596. readonly rgb: NodeMaterialConnectionPoint;
  54597. /**
  54598. * Gets the a input component
  54599. */
  54600. readonly a: NodeMaterialConnectionPoint;
  54601. protected _buildBlock(state: NodeMaterialBuildState): this;
  54602. }
  54603. }
  54604. declare module BABYLON {
  54605. /**
  54606. * Block used to read a reflection texture from a sampler
  54607. */
  54608. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54609. private _define3DName;
  54610. private _defineCubicName;
  54611. private _defineExplicitName;
  54612. private _defineProjectionName;
  54613. private _defineLocalCubicName;
  54614. private _defineSphericalName;
  54615. private _definePlanarName;
  54616. private _defineEquirectangularName;
  54617. private _defineMirroredEquirectangularFixedName;
  54618. private _defineEquirectangularFixedName;
  54619. private _defineSkyboxName;
  54620. private _cubeSamplerName;
  54621. private _2DSamplerName;
  54622. private _positionUVWName;
  54623. private _directionWName;
  54624. private _reflectionCoordsName;
  54625. private _reflection2DCoordsName;
  54626. private _reflectionColorName;
  54627. private _reflectionMatrixName;
  54628. /**
  54629. * Gets or sets the texture associated with the node
  54630. */
  54631. texture: Nullable<BaseTexture>;
  54632. /**
  54633. * Create a new TextureBlock
  54634. * @param name defines the block name
  54635. */
  54636. constructor(name: string);
  54637. /**
  54638. * Gets the current class name
  54639. * @returns the class name
  54640. */
  54641. getClassName(): string;
  54642. /**
  54643. * Gets the world position input component
  54644. */
  54645. readonly position: NodeMaterialConnectionPoint;
  54646. /**
  54647. * Gets the world position input component
  54648. */
  54649. readonly worldPosition: NodeMaterialConnectionPoint;
  54650. /**
  54651. * Gets the world normal input component
  54652. */
  54653. readonly worldNormal: NodeMaterialConnectionPoint;
  54654. /**
  54655. * Gets the world input component
  54656. */
  54657. readonly world: NodeMaterialConnectionPoint;
  54658. /**
  54659. * Gets the camera (or eye) position component
  54660. */
  54661. readonly cameraPosition: NodeMaterialConnectionPoint;
  54662. /**
  54663. * Gets the view input component
  54664. */
  54665. readonly view: NodeMaterialConnectionPoint;
  54666. /**
  54667. * Gets the rgb output component
  54668. */
  54669. readonly rgb: NodeMaterialConnectionPoint;
  54670. /**
  54671. * Gets the r output component
  54672. */
  54673. readonly r: NodeMaterialConnectionPoint;
  54674. /**
  54675. * Gets the g output component
  54676. */
  54677. readonly g: NodeMaterialConnectionPoint;
  54678. /**
  54679. * Gets the b output component
  54680. */
  54681. readonly b: NodeMaterialConnectionPoint;
  54682. autoConfigure(material: NodeMaterial): void;
  54683. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54684. isReady(): boolean;
  54685. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54686. private _injectVertexCode;
  54687. private _writeOutput;
  54688. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54689. protected _dumpPropertiesCode(): string;
  54690. serialize(): any;
  54691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54692. }
  54693. }
  54694. declare module BABYLON {
  54695. /**
  54696. * Interface used to configure the node material editor
  54697. */
  54698. export interface INodeMaterialEditorOptions {
  54699. /** Define the URl to load node editor script */
  54700. editorURL?: string;
  54701. }
  54702. /** @hidden */
  54703. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54704. /** BONES */
  54705. NUM_BONE_INFLUENCERS: number;
  54706. BonesPerMesh: number;
  54707. BONETEXTURE: boolean;
  54708. /** MORPH TARGETS */
  54709. MORPHTARGETS: boolean;
  54710. MORPHTARGETS_NORMAL: boolean;
  54711. MORPHTARGETS_TANGENT: boolean;
  54712. MORPHTARGETS_UV: boolean;
  54713. NUM_MORPH_INFLUENCERS: number;
  54714. /** IMAGE PROCESSING */
  54715. IMAGEPROCESSING: boolean;
  54716. VIGNETTE: boolean;
  54717. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54718. VIGNETTEBLENDMODEOPAQUE: boolean;
  54719. TONEMAPPING: boolean;
  54720. TONEMAPPING_ACES: boolean;
  54721. CONTRAST: boolean;
  54722. EXPOSURE: boolean;
  54723. COLORCURVES: boolean;
  54724. COLORGRADING: boolean;
  54725. COLORGRADING3D: boolean;
  54726. SAMPLER3DGREENDEPTH: boolean;
  54727. SAMPLER3DBGRMAP: boolean;
  54728. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54729. /** MISC. */
  54730. BUMPDIRECTUV: number;
  54731. constructor();
  54732. setValue(name: string, value: boolean): void;
  54733. }
  54734. /**
  54735. * Class used to configure NodeMaterial
  54736. */
  54737. export interface INodeMaterialOptions {
  54738. /**
  54739. * Defines if blocks should emit comments
  54740. */
  54741. emitComments: boolean;
  54742. }
  54743. /**
  54744. * Class used to create a node based material built by assembling shader blocks
  54745. */
  54746. export class NodeMaterial extends PushMaterial {
  54747. private static _BuildIdGenerator;
  54748. private _options;
  54749. private _vertexCompilationState;
  54750. private _fragmentCompilationState;
  54751. private _sharedData;
  54752. private _buildId;
  54753. private _buildWasSuccessful;
  54754. private _cachedWorldViewMatrix;
  54755. private _cachedWorldViewProjectionMatrix;
  54756. private _optimizers;
  54757. private _animationFrame;
  54758. /** Define the URl to load node editor script */
  54759. static EditorURL: string;
  54760. private BJSNODEMATERIALEDITOR;
  54761. /** Get the inspector from bundle or global */
  54762. private _getGlobalNodeMaterialEditor;
  54763. /**
  54764. * Gets or sets data used by visual editor
  54765. * @see https://nme.babylonjs.com
  54766. */
  54767. editorData: any;
  54768. /**
  54769. * 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)
  54770. */
  54771. ignoreAlpha: boolean;
  54772. /**
  54773. * Defines the maximum number of lights that can be used in the material
  54774. */
  54775. maxSimultaneousLights: number;
  54776. /**
  54777. * Observable raised when the material is built
  54778. */
  54779. onBuildObservable: Observable<NodeMaterial>;
  54780. /**
  54781. * Gets or sets the root nodes of the material vertex shader
  54782. */
  54783. _vertexOutputNodes: NodeMaterialBlock[];
  54784. /**
  54785. * Gets or sets the root nodes of the material fragment (pixel) shader
  54786. */
  54787. _fragmentOutputNodes: NodeMaterialBlock[];
  54788. /** Gets or sets options to control the node material overall behavior */
  54789. options: INodeMaterialOptions;
  54790. /**
  54791. * Default configuration related to image processing available in the standard Material.
  54792. */
  54793. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54794. /**
  54795. * Gets the image processing configuration used either in this material.
  54796. */
  54797. /**
  54798. * Sets the Default image processing configuration used either in the this material.
  54799. *
  54800. * If sets to null, the scene one is in use.
  54801. */
  54802. imageProcessingConfiguration: ImageProcessingConfiguration;
  54803. /**
  54804. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54805. */
  54806. attachedBlocks: NodeMaterialBlock[];
  54807. /**
  54808. * Create a new node based material
  54809. * @param name defines the material name
  54810. * @param scene defines the hosting scene
  54811. * @param options defines creation option
  54812. */
  54813. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54814. /**
  54815. * Gets the current class name of the material e.g. "NodeMaterial"
  54816. * @returns the class name
  54817. */
  54818. getClassName(): string;
  54819. /**
  54820. * Keep track of the image processing observer to allow dispose and replace.
  54821. */
  54822. private _imageProcessingObserver;
  54823. /**
  54824. * Attaches a new image processing configuration to the Standard Material.
  54825. * @param configuration
  54826. */
  54827. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54828. /**
  54829. * Get a block by its name
  54830. * @param name defines the name of the block to retrieve
  54831. * @returns the required block or null if not found
  54832. */
  54833. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54834. /**
  54835. * Get a block by its name
  54836. * @param predicate defines the predicate used to find the good candidate
  54837. * @returns the required block or null if not found
  54838. */
  54839. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54840. /**
  54841. * Get an input block by its name
  54842. * @param predicate defines the predicate used to find the good candidate
  54843. * @returns the required input block or null if not found
  54844. */
  54845. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54846. /**
  54847. * Gets the list of input blocks attached to this material
  54848. * @returns an array of InputBlocks
  54849. */
  54850. getInputBlocks(): InputBlock[];
  54851. /**
  54852. * Adds a new optimizer to the list of optimizers
  54853. * @param optimizer defines the optimizers to add
  54854. * @returns the current material
  54855. */
  54856. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54857. /**
  54858. * Remove an optimizer from the list of optimizers
  54859. * @param optimizer defines the optimizers to remove
  54860. * @returns the current material
  54861. */
  54862. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54863. /**
  54864. * Add a new block to the list of output nodes
  54865. * @param node defines the node to add
  54866. * @returns the current material
  54867. */
  54868. addOutputNode(node: NodeMaterialBlock): this;
  54869. /**
  54870. * Remove a block from the list of root nodes
  54871. * @param node defines the node to remove
  54872. * @returns the current material
  54873. */
  54874. removeOutputNode(node: NodeMaterialBlock): this;
  54875. private _addVertexOutputNode;
  54876. private _removeVertexOutputNode;
  54877. private _addFragmentOutputNode;
  54878. private _removeFragmentOutputNode;
  54879. /**
  54880. * Specifies if the material will require alpha blending
  54881. * @returns a boolean specifying if alpha blending is needed
  54882. */
  54883. needAlphaBlending(): boolean;
  54884. /**
  54885. * Specifies if this material should be rendered in alpha test mode
  54886. * @returns a boolean specifying if an alpha test is needed.
  54887. */
  54888. needAlphaTesting(): boolean;
  54889. private _initializeBlock;
  54890. private _resetDualBlocks;
  54891. /**
  54892. * Remove a block from the current node material
  54893. * @param block defines the block to remove
  54894. */
  54895. removeBlock(block: NodeMaterialBlock): void;
  54896. /**
  54897. * Build the material and generates the inner effect
  54898. * @param verbose defines if the build should log activity
  54899. */
  54900. build(verbose?: boolean): void;
  54901. /**
  54902. * Runs an otpimization phase to try to improve the shader code
  54903. */
  54904. optimize(): void;
  54905. private _prepareDefinesForAttributes;
  54906. /**
  54907. * Get if the submesh is ready to be used and all its information available.
  54908. * Child classes can use it to update shaders
  54909. * @param mesh defines the mesh to check
  54910. * @param subMesh defines which submesh to check
  54911. * @param useInstances specifies that instances should be used
  54912. * @returns a boolean indicating that the submesh is ready or not
  54913. */
  54914. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54915. /**
  54916. * Get a string representing the shaders built by the current node graph
  54917. */
  54918. readonly compiledShaders: string;
  54919. /**
  54920. * Binds the world matrix to the material
  54921. * @param world defines the world transformation matrix
  54922. */
  54923. bindOnlyWorldMatrix(world: Matrix): void;
  54924. /**
  54925. * Binds the submesh to this material by preparing the effect and shader to draw
  54926. * @param world defines the world transformation matrix
  54927. * @param mesh defines the mesh containing the submesh
  54928. * @param subMesh defines the submesh to bind the material to
  54929. */
  54930. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54931. /**
  54932. * Gets the active textures from the material
  54933. * @returns an array of textures
  54934. */
  54935. getActiveTextures(): BaseTexture[];
  54936. /**
  54937. * Gets the list of texture blocks
  54938. * @returns an array of texture blocks
  54939. */
  54940. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54941. /**
  54942. * Specifies if the material uses a texture
  54943. * @param texture defines the texture to check against the material
  54944. * @returns a boolean specifying if the material uses the texture
  54945. */
  54946. hasTexture(texture: BaseTexture): boolean;
  54947. /**
  54948. * Disposes the material
  54949. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54950. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54951. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54952. */
  54953. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54954. /** Creates the node editor window. */
  54955. private _createNodeEditor;
  54956. /**
  54957. * Launch the node material editor
  54958. * @param config Define the configuration of the editor
  54959. * @return a promise fulfilled when the node editor is visible
  54960. */
  54961. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54962. /**
  54963. * Clear the current material
  54964. */
  54965. clear(): void;
  54966. /**
  54967. * Clear the current material and set it to a default state
  54968. */
  54969. setToDefault(): void;
  54970. /**
  54971. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54972. * @param url defines the url to load from
  54973. * @returns a promise that will fullfil when the material is fully loaded
  54974. */
  54975. loadAsync(url: string): Promise<void>;
  54976. private _gatherBlocks;
  54977. /**
  54978. * Generate a string containing the code declaration required to create an equivalent of this material
  54979. * @returns a string
  54980. */
  54981. generateCode(): string;
  54982. /**
  54983. * Serializes this material in a JSON representation
  54984. * @returns the serialized material object
  54985. */
  54986. serialize(): any;
  54987. private _restoreConnections;
  54988. /**
  54989. * Clear the current graph and load a new one from a serialization object
  54990. * @param source defines the JSON representation of the material
  54991. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54992. */
  54993. loadFromSerialization(source: any, rootUrl?: string): void;
  54994. /**
  54995. * Creates a node material from parsed material data
  54996. * @param source defines the JSON representation of the material
  54997. * @param scene defines the hosting scene
  54998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54999. * @returns a new node material
  55000. */
  55001. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55002. /**
  55003. * Creates a new node material set to default basic configuration
  55004. * @param name defines the name of the material
  55005. * @param scene defines the hosting scene
  55006. * @returns a new NodeMaterial
  55007. */
  55008. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55009. }
  55010. }
  55011. declare module BABYLON {
  55012. /**
  55013. * Block used to read a texture from a sampler
  55014. */
  55015. export class TextureBlock extends NodeMaterialBlock {
  55016. private _defineName;
  55017. private _linearDefineName;
  55018. private _tempTextureRead;
  55019. private _samplerName;
  55020. private _transformedUVName;
  55021. private _textureTransformName;
  55022. private _textureInfoName;
  55023. private _mainUVName;
  55024. private _mainUVDefineName;
  55025. /**
  55026. * Gets or sets the texture associated with the node
  55027. */
  55028. texture: Nullable<Texture>;
  55029. /**
  55030. * Create a new TextureBlock
  55031. * @param name defines the block name
  55032. */
  55033. constructor(name: string);
  55034. /**
  55035. * Gets the current class name
  55036. * @returns the class name
  55037. */
  55038. getClassName(): string;
  55039. /**
  55040. * Gets the uv input component
  55041. */
  55042. readonly uv: NodeMaterialConnectionPoint;
  55043. /**
  55044. * Gets the rgba output component
  55045. */
  55046. readonly rgba: NodeMaterialConnectionPoint;
  55047. /**
  55048. * Gets the rgb output component
  55049. */
  55050. readonly rgb: NodeMaterialConnectionPoint;
  55051. /**
  55052. * Gets the r output component
  55053. */
  55054. readonly r: NodeMaterialConnectionPoint;
  55055. /**
  55056. * Gets the g output component
  55057. */
  55058. readonly g: NodeMaterialConnectionPoint;
  55059. /**
  55060. * Gets the b output component
  55061. */
  55062. readonly b: NodeMaterialConnectionPoint;
  55063. /**
  55064. * Gets the a output component
  55065. */
  55066. readonly a: NodeMaterialConnectionPoint;
  55067. readonly target: NodeMaterialBlockTargets;
  55068. autoConfigure(material: NodeMaterial): void;
  55069. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55070. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55071. private _getTextureBase;
  55072. isReady(): boolean;
  55073. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55074. private readonly _isMixed;
  55075. private _injectVertexCode;
  55076. private _writeTextureRead;
  55077. private _writeOutput;
  55078. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55079. protected _dumpPropertiesCode(): string;
  55080. serialize(): any;
  55081. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55082. }
  55083. }
  55084. declare module BABYLON {
  55085. /**
  55086. * Class used to store shared data between 2 NodeMaterialBuildState
  55087. */
  55088. export class NodeMaterialBuildStateSharedData {
  55089. /**
  55090. * Gets the list of emitted varyings
  55091. */
  55092. temps: string[];
  55093. /**
  55094. * Gets the list of emitted varyings
  55095. */
  55096. varyings: string[];
  55097. /**
  55098. * Gets the varying declaration string
  55099. */
  55100. varyingDeclaration: string;
  55101. /**
  55102. * Input blocks
  55103. */
  55104. inputBlocks: InputBlock[];
  55105. /**
  55106. * Input blocks
  55107. */
  55108. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55109. /**
  55110. * Bindable blocks (Blocks that need to set data to the effect)
  55111. */
  55112. bindableBlocks: NodeMaterialBlock[];
  55113. /**
  55114. * List of blocks that can provide a compilation fallback
  55115. */
  55116. blocksWithFallbacks: NodeMaterialBlock[];
  55117. /**
  55118. * List of blocks that can provide a define update
  55119. */
  55120. blocksWithDefines: NodeMaterialBlock[];
  55121. /**
  55122. * List of blocks that can provide a repeatable content
  55123. */
  55124. repeatableContentBlocks: NodeMaterialBlock[];
  55125. /**
  55126. * List of blocks that can provide a dynamic list of uniforms
  55127. */
  55128. dynamicUniformBlocks: NodeMaterialBlock[];
  55129. /**
  55130. * List of blocks that can block the isReady function for the material
  55131. */
  55132. blockingBlocks: NodeMaterialBlock[];
  55133. /**
  55134. * Gets the list of animated inputs
  55135. */
  55136. animatedInputs: InputBlock[];
  55137. /**
  55138. * Build Id used to avoid multiple recompilations
  55139. */
  55140. buildId: number;
  55141. /** List of emitted variables */
  55142. variableNames: {
  55143. [key: string]: number;
  55144. };
  55145. /** List of emitted defines */
  55146. defineNames: {
  55147. [key: string]: number;
  55148. };
  55149. /** Should emit comments? */
  55150. emitComments: boolean;
  55151. /** Emit build activity */
  55152. verbose: boolean;
  55153. /** Gets or sets the hosting scene */
  55154. scene: Scene;
  55155. /**
  55156. * Gets the compilation hints emitted at compilation time
  55157. */
  55158. hints: {
  55159. needWorldViewMatrix: boolean;
  55160. needWorldViewProjectionMatrix: boolean;
  55161. needAlphaBlending: boolean;
  55162. needAlphaTesting: boolean;
  55163. };
  55164. /**
  55165. * List of compilation checks
  55166. */
  55167. checks: {
  55168. emitVertex: boolean;
  55169. emitFragment: boolean;
  55170. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55171. };
  55172. /** Creates a new shared data */
  55173. constructor();
  55174. /**
  55175. * Emits console errors and exceptions if there is a failing check
  55176. */
  55177. emitErrors(): void;
  55178. }
  55179. }
  55180. declare module BABYLON {
  55181. /**
  55182. * Class used to store node based material build state
  55183. */
  55184. export class NodeMaterialBuildState {
  55185. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55186. supportUniformBuffers: boolean;
  55187. /**
  55188. * Gets the list of emitted attributes
  55189. */
  55190. attributes: string[];
  55191. /**
  55192. * Gets the list of emitted uniforms
  55193. */
  55194. uniforms: string[];
  55195. /**
  55196. * Gets the list of emitted constants
  55197. */
  55198. constants: string[];
  55199. /**
  55200. * Gets the list of emitted samplers
  55201. */
  55202. samplers: string[];
  55203. /**
  55204. * Gets the list of emitted functions
  55205. */
  55206. functions: {
  55207. [key: string]: string;
  55208. };
  55209. /**
  55210. * Gets the list of emitted extensions
  55211. */
  55212. extensions: {
  55213. [key: string]: string;
  55214. };
  55215. /**
  55216. * Gets the target of the compilation state
  55217. */
  55218. target: NodeMaterialBlockTargets;
  55219. /**
  55220. * Gets the list of emitted counters
  55221. */
  55222. counters: {
  55223. [key: string]: number;
  55224. };
  55225. /**
  55226. * Shared data between multiple NodeMaterialBuildState instances
  55227. */
  55228. sharedData: NodeMaterialBuildStateSharedData;
  55229. /** @hidden */
  55230. _vertexState: NodeMaterialBuildState;
  55231. /** @hidden */
  55232. _attributeDeclaration: string;
  55233. /** @hidden */
  55234. _uniformDeclaration: string;
  55235. /** @hidden */
  55236. _constantDeclaration: string;
  55237. /** @hidden */
  55238. _samplerDeclaration: string;
  55239. /** @hidden */
  55240. _varyingTransfer: string;
  55241. private _repeatableContentAnchorIndex;
  55242. /** @hidden */
  55243. _builtCompilationString: string;
  55244. /**
  55245. * Gets the emitted compilation strings
  55246. */
  55247. compilationString: string;
  55248. /**
  55249. * Finalize the compilation strings
  55250. * @param state defines the current compilation state
  55251. */
  55252. finalize(state: NodeMaterialBuildState): void;
  55253. /** @hidden */
  55254. readonly _repeatableContentAnchor: string;
  55255. /** @hidden */
  55256. _getFreeVariableName(prefix: string): string;
  55257. /** @hidden */
  55258. _getFreeDefineName(prefix: string): string;
  55259. /** @hidden */
  55260. _excludeVariableName(name: string): void;
  55261. /** @hidden */
  55262. _emit2DSampler(name: string): void;
  55263. /** @hidden */
  55264. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55265. /** @hidden */
  55266. _emitExtension(name: string, extension: string): void;
  55267. /** @hidden */
  55268. _emitFunction(name: string, code: string, comments: string): void;
  55269. /** @hidden */
  55270. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55271. replaceStrings?: {
  55272. search: RegExp;
  55273. replace: string;
  55274. }[];
  55275. repeatKey?: string;
  55276. }): string;
  55277. /** @hidden */
  55278. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55279. repeatKey?: string;
  55280. removeAttributes?: boolean;
  55281. removeUniforms?: boolean;
  55282. removeVaryings?: boolean;
  55283. removeIfDef?: boolean;
  55284. replaceStrings?: {
  55285. search: RegExp;
  55286. replace: string;
  55287. }[];
  55288. }, storeKey?: string): void;
  55289. /** @hidden */
  55290. _registerTempVariable(name: string): boolean;
  55291. /** @hidden */
  55292. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55293. /** @hidden */
  55294. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55295. /** @hidden */
  55296. _emitFloat(value: number): string;
  55297. }
  55298. }
  55299. declare module BABYLON {
  55300. /**
  55301. * Defines a block that can be used inside a node based material
  55302. */
  55303. export class NodeMaterialBlock {
  55304. private _buildId;
  55305. private _buildTarget;
  55306. private _target;
  55307. private _isFinalMerger;
  55308. private _isInput;
  55309. protected _isUnique: boolean;
  55310. /** @hidden */
  55311. _codeVariableName: string;
  55312. /** @hidden */
  55313. _inputs: NodeMaterialConnectionPoint[];
  55314. /** @hidden */
  55315. _outputs: NodeMaterialConnectionPoint[];
  55316. /** @hidden */
  55317. _preparationId: number;
  55318. /**
  55319. * Gets or sets the name of the block
  55320. */
  55321. name: string;
  55322. /**
  55323. * Gets or sets the unique id of the node
  55324. */
  55325. uniqueId: number;
  55326. /**
  55327. * Gets or sets the comments associated with this block
  55328. */
  55329. comments: string;
  55330. /**
  55331. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  55332. */
  55333. readonly isUnique: boolean;
  55334. /**
  55335. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55336. */
  55337. readonly isFinalMerger: boolean;
  55338. /**
  55339. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55340. */
  55341. readonly isInput: boolean;
  55342. /**
  55343. * Gets or sets the build Id
  55344. */
  55345. buildId: number;
  55346. /**
  55347. * Gets or sets the target of the block
  55348. */
  55349. target: NodeMaterialBlockTargets;
  55350. /**
  55351. * Gets the list of input points
  55352. */
  55353. readonly inputs: NodeMaterialConnectionPoint[];
  55354. /** Gets the list of output points */
  55355. readonly outputs: NodeMaterialConnectionPoint[];
  55356. /**
  55357. * Find an input by its name
  55358. * @param name defines the name of the input to look for
  55359. * @returns the input or null if not found
  55360. */
  55361. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55362. /**
  55363. * Find an output by its name
  55364. * @param name defines the name of the outputto look for
  55365. * @returns the output or null if not found
  55366. */
  55367. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55368. /**
  55369. * Creates a new NodeMaterialBlock
  55370. * @param name defines the block name
  55371. * @param target defines the target of that block (Vertex by default)
  55372. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55373. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55374. */
  55375. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55376. /**
  55377. * Initialize the block and prepare the context for build
  55378. * @param state defines the state that will be used for the build
  55379. */
  55380. initialize(state: NodeMaterialBuildState): void;
  55381. /**
  55382. * Bind data to effect. Will only be called for blocks with isBindable === true
  55383. * @param effect defines the effect to bind data to
  55384. * @param nodeMaterial defines the hosting NodeMaterial
  55385. * @param mesh defines the mesh that will be rendered
  55386. */
  55387. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55388. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55389. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55390. protected _writeFloat(value: number): string;
  55391. /**
  55392. * Gets the current class name e.g. "NodeMaterialBlock"
  55393. * @returns the class name
  55394. */
  55395. getClassName(): string;
  55396. /**
  55397. * Register a new input. Must be called inside a block constructor
  55398. * @param name defines the connection point name
  55399. * @param type defines the connection point type
  55400. * @param isOptional defines a boolean indicating that this input can be omitted
  55401. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55402. * @returns the current block
  55403. */
  55404. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55405. /**
  55406. * Register a new output. Must be called inside a block constructor
  55407. * @param name defines the connection point name
  55408. * @param type defines the connection point type
  55409. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55410. * @returns the current block
  55411. */
  55412. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55413. /**
  55414. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55415. * @param forOutput defines an optional connection point to check compatibility with
  55416. * @returns the first available input or null
  55417. */
  55418. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55419. /**
  55420. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55421. * @param forBlock defines an optional block to check compatibility with
  55422. * @returns the first available input or null
  55423. */
  55424. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55425. /**
  55426. * Gets the sibling of the given output
  55427. * @param current defines the current output
  55428. * @returns the next output in the list or null
  55429. */
  55430. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55431. /**
  55432. * Connect current block with another block
  55433. * @param other defines the block to connect with
  55434. * @param options define the various options to help pick the right connections
  55435. * @returns the current block
  55436. */
  55437. connectTo(other: NodeMaterialBlock, options?: {
  55438. input?: string;
  55439. output?: string;
  55440. outputSwizzle?: string;
  55441. }): this | undefined;
  55442. protected _buildBlock(state: NodeMaterialBuildState): void;
  55443. /**
  55444. * Add uniforms, samplers and uniform buffers at compilation time
  55445. * @param state defines the state to update
  55446. * @param nodeMaterial defines the node material requesting the update
  55447. * @param defines defines the material defines to update
  55448. * @param uniformBuffers defines the list of uniform buffer names
  55449. */
  55450. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55451. /**
  55452. * Add potential fallbacks if shader compilation fails
  55453. * @param mesh defines the mesh to be rendered
  55454. * @param fallbacks defines the current prioritized list of fallbacks
  55455. */
  55456. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55457. /**
  55458. * Initialize defines for shader compilation
  55459. * @param mesh defines the mesh to be rendered
  55460. * @param nodeMaterial defines the node material requesting the update
  55461. * @param defines defines the material defines to update
  55462. * @param useInstances specifies that instances should be used
  55463. */
  55464. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55465. /**
  55466. * Update defines for shader compilation
  55467. * @param mesh defines the mesh to be rendered
  55468. * @param nodeMaterial defines the node material requesting the update
  55469. * @param defines defines the material defines to update
  55470. * @param useInstances specifies that instances should be used
  55471. */
  55472. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55473. /**
  55474. * Lets the block try to connect some inputs automatically
  55475. * @param material defines the hosting NodeMaterial
  55476. */
  55477. autoConfigure(material: NodeMaterial): void;
  55478. /**
  55479. * Function called when a block is declared as repeatable content generator
  55480. * @param vertexShaderState defines the current compilation state for the vertex shader
  55481. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55482. * @param mesh defines the mesh to be rendered
  55483. * @param defines defines the material defines to update
  55484. */
  55485. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55486. /**
  55487. * Checks if the block is ready
  55488. * @param mesh defines the mesh to be rendered
  55489. * @param nodeMaterial defines the node material requesting the update
  55490. * @param defines defines the material defines to update
  55491. * @param useInstances specifies that instances should be used
  55492. * @returns true if the block is ready
  55493. */
  55494. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55495. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55496. private _processBuild;
  55497. /**
  55498. * Compile the current node and generate the shader code
  55499. * @param state defines the current compilation state (uniforms, samplers, current string)
  55500. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55501. * @returns true if already built
  55502. */
  55503. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55504. protected _inputRename(name: string): string;
  55505. protected _outputRename(name: string): string;
  55506. protected _dumpPropertiesCode(): string;
  55507. /** @hidden */
  55508. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55509. /** @hidden */
  55510. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  55511. /**
  55512. * Clone the current block to a new identical block
  55513. * @param scene defines the hosting scene
  55514. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55515. * @returns a copy of the current block
  55516. */
  55517. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55518. /**
  55519. * Serializes this block in a JSON representation
  55520. * @returns the serialized block object
  55521. */
  55522. serialize(): any;
  55523. /** @hidden */
  55524. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55525. /**
  55526. * Release resources
  55527. */
  55528. dispose(): void;
  55529. }
  55530. }
  55531. declare module BABYLON {
  55532. /**
  55533. * Enum defining the type of animations supported by InputBlock
  55534. */
  55535. export enum AnimatedInputBlockTypes {
  55536. /** No animation */
  55537. None = 0,
  55538. /** Time based animation. Will only work for floats */
  55539. Time = 1
  55540. }
  55541. }
  55542. declare module BABYLON {
  55543. /**
  55544. * Block used to expose an input value
  55545. */
  55546. export class InputBlock extends NodeMaterialBlock {
  55547. private _mode;
  55548. private _associatedVariableName;
  55549. private _storedValue;
  55550. private _valueCallback;
  55551. private _type;
  55552. private _animationType;
  55553. /** Gets or set a value used to limit the range of float values */
  55554. min: number;
  55555. /** Gets or set a value used to limit the range of float values */
  55556. max: number;
  55557. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55558. matrixMode: number;
  55559. /** @hidden */
  55560. _systemValue: Nullable<NodeMaterialSystemValues>;
  55561. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55562. visibleInInspector: boolean;
  55563. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  55564. isConstant: boolean;
  55565. /** Gets or sets the group to use to display this block in the Inspector */
  55566. groupInInspector: string;
  55567. /**
  55568. * Gets or sets the connection point type (default is float)
  55569. */
  55570. readonly type: NodeMaterialBlockConnectionPointTypes;
  55571. /**
  55572. * Creates a new InputBlock
  55573. * @param name defines the block name
  55574. * @param target defines the target of that block (Vertex by default)
  55575. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55576. */
  55577. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55578. /**
  55579. * Gets the output component
  55580. */
  55581. readonly output: NodeMaterialConnectionPoint;
  55582. /**
  55583. * Set the source of this connection point to a vertex attribute
  55584. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55585. * @returns the current connection point
  55586. */
  55587. setAsAttribute(attributeName?: string): InputBlock;
  55588. /**
  55589. * Set the source of this connection point to a system value
  55590. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55591. * @returns the current connection point
  55592. */
  55593. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55594. /**
  55595. * Gets or sets the value of that point.
  55596. * Please note that this value will be ignored if valueCallback is defined
  55597. */
  55598. value: any;
  55599. /**
  55600. * Gets or sets a callback used to get the value of that point.
  55601. * Please note that setting this value will force the connection point to ignore the value property
  55602. */
  55603. valueCallback: () => any;
  55604. /**
  55605. * Gets or sets the associated variable name in the shader
  55606. */
  55607. associatedVariableName: string;
  55608. /** Gets or sets the type of animation applied to the input */
  55609. animationType: AnimatedInputBlockTypes;
  55610. /**
  55611. * Gets a boolean indicating that this connection point not defined yet
  55612. */
  55613. readonly isUndefined: boolean;
  55614. /**
  55615. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55616. * In this case the connection point name must be the name of the uniform to use.
  55617. * Can only be set on inputs
  55618. */
  55619. isUniform: boolean;
  55620. /**
  55621. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55622. * In this case the connection point name must be the name of the attribute to use
  55623. * Can only be set on inputs
  55624. */
  55625. isAttribute: boolean;
  55626. /**
  55627. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55628. * Can only be set on exit points
  55629. */
  55630. isVarying: boolean;
  55631. /**
  55632. * Gets a boolean indicating that the current connection point is a system value
  55633. */
  55634. readonly isSystemValue: boolean;
  55635. /**
  55636. * Gets or sets the current well known value or null if not defined as a system value
  55637. */
  55638. systemValue: Nullable<NodeMaterialSystemValues>;
  55639. /**
  55640. * Gets the current class name
  55641. * @returns the class name
  55642. */
  55643. getClassName(): string;
  55644. /**
  55645. * Animate the input if animationType !== None
  55646. * @param scene defines the rendering scene
  55647. */
  55648. animate(scene: Scene): void;
  55649. private _emitDefine;
  55650. initialize(state: NodeMaterialBuildState): void;
  55651. /**
  55652. * Set the input block to its default value (based on its type)
  55653. */
  55654. setDefaultValue(): void;
  55655. private _emitConstant;
  55656. private _emit;
  55657. /** @hidden */
  55658. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55659. /** @hidden */
  55660. _transmit(effect: Effect, scene: Scene): void;
  55661. protected _buildBlock(state: NodeMaterialBuildState): void;
  55662. protected _dumpPropertiesCode(): string;
  55663. serialize(): any;
  55664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55665. }
  55666. }
  55667. declare module BABYLON {
  55668. /**
  55669. * Enum used to define the compatibility state between two connection points
  55670. */
  55671. export enum NodeMaterialConnectionPointCompatibilityStates {
  55672. /** Points are compatibles */
  55673. Compatible = 0,
  55674. /** Points are incompatible because of their types */
  55675. TypeIncompatible = 1,
  55676. /** Points are incompatible because of their targets (vertex vs fragment) */
  55677. TargetIncompatible = 2
  55678. }
  55679. /**
  55680. * Defines the direction of a connection point
  55681. */
  55682. export enum NodeMaterialConnectionPointDirection {
  55683. /** Input */
  55684. Input = 0,
  55685. /** Output */
  55686. Output = 1
  55687. }
  55688. /**
  55689. * Defines a connection point for a block
  55690. */
  55691. export class NodeMaterialConnectionPoint {
  55692. /** @hidden */
  55693. _ownerBlock: NodeMaterialBlock;
  55694. /** @hidden */
  55695. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55696. private _endpoints;
  55697. private _associatedVariableName;
  55698. private _direction;
  55699. /** @hidden */
  55700. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55701. /** @hidden */
  55702. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55703. private _type;
  55704. /** @hidden */
  55705. _enforceAssociatedVariableName: boolean;
  55706. /** Gets the direction of the point */
  55707. readonly direction: NodeMaterialConnectionPointDirection;
  55708. /**
  55709. * Gets or sets the additional types supported by this connection point
  55710. */
  55711. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55712. /**
  55713. * Gets or sets the additional types excluded by this connection point
  55714. */
  55715. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55716. /**
  55717. * Observable triggered when this point is connected
  55718. */
  55719. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  55720. /**
  55721. * Gets or sets the associated variable name in the shader
  55722. */
  55723. associatedVariableName: string;
  55724. /**
  55725. * Gets or sets the connection point type (default is float)
  55726. */
  55727. type: NodeMaterialBlockConnectionPointTypes;
  55728. /**
  55729. * Gets or sets the connection point name
  55730. */
  55731. name: string;
  55732. /**
  55733. * Gets or sets a boolean indicating that this connection point can be omitted
  55734. */
  55735. isOptional: boolean;
  55736. /**
  55737. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55738. */
  55739. define: string;
  55740. /** @hidden */
  55741. _prioritizeVertex: boolean;
  55742. private _target;
  55743. /** Gets or sets the target of that connection point */
  55744. target: NodeMaterialBlockTargets;
  55745. /**
  55746. * Gets a boolean indicating that the current point is connected
  55747. */
  55748. readonly isConnected: boolean;
  55749. /**
  55750. * Gets a boolean indicating that the current point is connected to an input block
  55751. */
  55752. readonly isConnectedToInputBlock: boolean;
  55753. /**
  55754. * Gets a the connected input block (if any)
  55755. */
  55756. readonly connectInputBlock: Nullable<InputBlock>;
  55757. /** Get the other side of the connection (if any) */
  55758. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55759. /** Get the block that owns this connection point */
  55760. readonly ownerBlock: NodeMaterialBlock;
  55761. /** Get the block connected on the other side of this connection (if any) */
  55762. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55763. /** Get the block connected on the endpoints of this connection (if any) */
  55764. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55765. /** Gets the list of connected endpoints */
  55766. readonly endpoints: NodeMaterialConnectionPoint[];
  55767. /** Gets a boolean indicating if that output point is connected to at least one input */
  55768. readonly hasEndpoints: boolean;
  55769. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  55770. readonly isConnectedInVertexShader: boolean;
  55771. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  55772. readonly isConnectedInFragmentShader: boolean;
  55773. /**
  55774. * Creates a new connection point
  55775. * @param name defines the connection point name
  55776. * @param ownerBlock defines the block hosting this connection point
  55777. * @param direction defines the direction of the connection point
  55778. */
  55779. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  55780. /**
  55781. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55782. * @returns the class name
  55783. */
  55784. getClassName(): string;
  55785. /**
  55786. * Gets a boolean indicating if the current point can be connected to another point
  55787. * @param connectionPoint defines the other connection point
  55788. * @returns a boolean
  55789. */
  55790. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55791. /**
  55792. * Gets a number indicating if the current point can be connected to another point
  55793. * @param connectionPoint defines the other connection point
  55794. * @returns a number defining the compatibility state
  55795. */
  55796. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  55797. /**
  55798. * Connect this point to another connection point
  55799. * @param connectionPoint defines the other connection point
  55800. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55801. * @returns the current connection point
  55802. */
  55803. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55804. /**
  55805. * Disconnect this point from one of his endpoint
  55806. * @param endpoint defines the other connection point
  55807. * @returns the current connection point
  55808. */
  55809. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55810. /**
  55811. * Serializes this point in a JSON representation
  55812. * @returns the serialized point object
  55813. */
  55814. serialize(): any;
  55815. /**
  55816. * Release resources
  55817. */
  55818. dispose(): void;
  55819. }
  55820. }
  55821. declare module BABYLON {
  55822. /**
  55823. * Block used to add support for vertex skinning (bones)
  55824. */
  55825. export class BonesBlock extends NodeMaterialBlock {
  55826. /**
  55827. * Creates a new BonesBlock
  55828. * @param name defines the block name
  55829. */
  55830. constructor(name: string);
  55831. /**
  55832. * Initialize the block and prepare the context for build
  55833. * @param state defines the state that will be used for the build
  55834. */
  55835. initialize(state: NodeMaterialBuildState): void;
  55836. /**
  55837. * Gets the current class name
  55838. * @returns the class name
  55839. */
  55840. getClassName(): string;
  55841. /**
  55842. * Gets the matrix indices input component
  55843. */
  55844. readonly matricesIndices: NodeMaterialConnectionPoint;
  55845. /**
  55846. * Gets the matrix weights input component
  55847. */
  55848. readonly matricesWeights: NodeMaterialConnectionPoint;
  55849. /**
  55850. * Gets the extra matrix indices input component
  55851. */
  55852. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55853. /**
  55854. * Gets the extra matrix weights input component
  55855. */
  55856. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55857. /**
  55858. * Gets the world input component
  55859. */
  55860. readonly world: NodeMaterialConnectionPoint;
  55861. /**
  55862. * Gets the output component
  55863. */
  55864. readonly output: NodeMaterialConnectionPoint;
  55865. autoConfigure(material: NodeMaterial): void;
  55866. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55867. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55868. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55869. protected _buildBlock(state: NodeMaterialBuildState): this;
  55870. }
  55871. }
  55872. declare module BABYLON {
  55873. /**
  55874. * Block used to add support for instances
  55875. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55876. */
  55877. export class InstancesBlock extends NodeMaterialBlock {
  55878. /**
  55879. * Creates a new InstancesBlock
  55880. * @param name defines the block name
  55881. */
  55882. constructor(name: string);
  55883. /**
  55884. * Gets the current class name
  55885. * @returns the class name
  55886. */
  55887. getClassName(): string;
  55888. /**
  55889. * Gets the first world row input component
  55890. */
  55891. readonly world0: NodeMaterialConnectionPoint;
  55892. /**
  55893. * Gets the second world row input component
  55894. */
  55895. readonly world1: NodeMaterialConnectionPoint;
  55896. /**
  55897. * Gets the third world row input component
  55898. */
  55899. readonly world2: NodeMaterialConnectionPoint;
  55900. /**
  55901. * Gets the forth world row input component
  55902. */
  55903. readonly world3: NodeMaterialConnectionPoint;
  55904. /**
  55905. * Gets the world input component
  55906. */
  55907. readonly world: NodeMaterialConnectionPoint;
  55908. /**
  55909. * Gets the output component
  55910. */
  55911. readonly output: NodeMaterialConnectionPoint;
  55912. autoConfigure(material: NodeMaterial): void;
  55913. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55914. protected _buildBlock(state: NodeMaterialBuildState): this;
  55915. }
  55916. }
  55917. declare module BABYLON {
  55918. /**
  55919. * Block used to add morph targets support to vertex shader
  55920. */
  55921. export class MorphTargetsBlock extends NodeMaterialBlock {
  55922. private _repeatableContentAnchor;
  55923. private _repeatebleContentGenerated;
  55924. /**
  55925. * Create a new MorphTargetsBlock
  55926. * @param name defines the block name
  55927. */
  55928. constructor(name: string);
  55929. /**
  55930. * Gets the current class name
  55931. * @returns the class name
  55932. */
  55933. getClassName(): string;
  55934. /**
  55935. * Gets the position input component
  55936. */
  55937. readonly position: NodeMaterialConnectionPoint;
  55938. /**
  55939. * Gets the normal input component
  55940. */
  55941. readonly normal: NodeMaterialConnectionPoint;
  55942. /**
  55943. * Gets the tangent input component
  55944. */
  55945. readonly tangent: NodeMaterialConnectionPoint;
  55946. /**
  55947. * Gets the tangent input component
  55948. */
  55949. readonly uv: NodeMaterialConnectionPoint;
  55950. /**
  55951. * Gets the position output component
  55952. */
  55953. readonly positionOutput: NodeMaterialConnectionPoint;
  55954. /**
  55955. * Gets the normal output component
  55956. */
  55957. readonly normalOutput: NodeMaterialConnectionPoint;
  55958. /**
  55959. * Gets the tangent output component
  55960. */
  55961. readonly tangentOutput: NodeMaterialConnectionPoint;
  55962. /**
  55963. * Gets the tangent output component
  55964. */
  55965. readonly uvOutput: NodeMaterialConnectionPoint;
  55966. initialize(state: NodeMaterialBuildState): void;
  55967. autoConfigure(material: NodeMaterial): void;
  55968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55969. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55970. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55971. protected _buildBlock(state: NodeMaterialBuildState): this;
  55972. }
  55973. }
  55974. declare module BABYLON {
  55975. /**
  55976. * Block used to get data information from a light
  55977. */
  55978. export class LightInformationBlock extends NodeMaterialBlock {
  55979. private _lightDataUniformName;
  55980. private _lightColorUniformName;
  55981. private _lightTypeDefineName;
  55982. /**
  55983. * Gets or sets the light associated with this block
  55984. */
  55985. light: Nullable<Light>;
  55986. /**
  55987. * Creates a new LightInformationBlock
  55988. * @param name defines the block name
  55989. */
  55990. constructor(name: string);
  55991. /**
  55992. * Gets the current class name
  55993. * @returns the class name
  55994. */
  55995. getClassName(): string;
  55996. /**
  55997. * Gets the world position input component
  55998. */
  55999. readonly worldPosition: NodeMaterialConnectionPoint;
  56000. /**
  56001. * Gets the direction output component
  56002. */
  56003. readonly direction: NodeMaterialConnectionPoint;
  56004. /**
  56005. * Gets the direction output component
  56006. */
  56007. readonly color: NodeMaterialConnectionPoint;
  56008. /**
  56009. * Gets the direction output component
  56010. */
  56011. readonly intensity: NodeMaterialConnectionPoint;
  56012. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56014. protected _buildBlock(state: NodeMaterialBuildState): this;
  56015. serialize(): any;
  56016. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56017. }
  56018. }
  56019. declare module BABYLON {
  56020. /**
  56021. * Block used to add image processing support to fragment shader
  56022. */
  56023. export class ImageProcessingBlock extends NodeMaterialBlock {
  56024. /**
  56025. * Create a new ImageProcessingBlock
  56026. * @param name defines the block name
  56027. */
  56028. constructor(name: string);
  56029. /**
  56030. * Gets the current class name
  56031. * @returns the class name
  56032. */
  56033. getClassName(): string;
  56034. /**
  56035. * Gets the color input component
  56036. */
  56037. readonly color: NodeMaterialConnectionPoint;
  56038. /**
  56039. * Gets the output component
  56040. */
  56041. readonly output: NodeMaterialConnectionPoint;
  56042. /**
  56043. * Initialize the block and prepare the context for build
  56044. * @param state defines the state that will be used for the build
  56045. */
  56046. initialize(state: NodeMaterialBuildState): void;
  56047. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56048. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56049. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56050. protected _buildBlock(state: NodeMaterialBuildState): this;
  56051. }
  56052. }
  56053. declare module BABYLON {
  56054. /**
  56055. * Block used to pertub normals based on a normal map
  56056. */
  56057. export class PerturbNormalBlock extends NodeMaterialBlock {
  56058. private _tangentSpaceParameterName;
  56059. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56060. invertX: boolean;
  56061. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56062. invertY: boolean;
  56063. /**
  56064. * Create a new PerturbNormalBlock
  56065. * @param name defines the block name
  56066. */
  56067. constructor(name: string);
  56068. /**
  56069. * Gets the current class name
  56070. * @returns the class name
  56071. */
  56072. getClassName(): string;
  56073. /**
  56074. * Gets the world position input component
  56075. */
  56076. readonly worldPosition: NodeMaterialConnectionPoint;
  56077. /**
  56078. * Gets the world normal input component
  56079. */
  56080. readonly worldNormal: NodeMaterialConnectionPoint;
  56081. /**
  56082. * Gets the uv input component
  56083. */
  56084. readonly uv: NodeMaterialConnectionPoint;
  56085. /**
  56086. * Gets the normal map color input component
  56087. */
  56088. readonly normalMapColor: NodeMaterialConnectionPoint;
  56089. /**
  56090. * Gets the strength input component
  56091. */
  56092. readonly strength: NodeMaterialConnectionPoint;
  56093. /**
  56094. * Gets the output component
  56095. */
  56096. readonly output: NodeMaterialConnectionPoint;
  56097. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56098. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56099. autoConfigure(material: NodeMaterial): void;
  56100. protected _buildBlock(state: NodeMaterialBuildState): this;
  56101. protected _dumpPropertiesCode(): string;
  56102. serialize(): any;
  56103. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56104. }
  56105. }
  56106. declare module BABYLON {
  56107. /**
  56108. * Block used to discard a pixel if a value is smaller than a cutoff
  56109. */
  56110. export class DiscardBlock extends NodeMaterialBlock {
  56111. /**
  56112. * Create a new DiscardBlock
  56113. * @param name defines the block name
  56114. */
  56115. constructor(name: string);
  56116. /**
  56117. * Gets the current class name
  56118. * @returns the class name
  56119. */
  56120. getClassName(): string;
  56121. /**
  56122. * Gets the color input component
  56123. */
  56124. readonly value: NodeMaterialConnectionPoint;
  56125. /**
  56126. * Gets the cutoff input component
  56127. */
  56128. readonly cutoff: NodeMaterialConnectionPoint;
  56129. protected _buildBlock(state: NodeMaterialBuildState): this;
  56130. }
  56131. }
  56132. declare module BABYLON {
  56133. /**
  56134. * Block used to test if the fragment shader is front facing
  56135. */
  56136. export class FrontFacingBlock extends NodeMaterialBlock {
  56137. /**
  56138. * Creates a new FrontFacingBlock
  56139. * @param name defines the block name
  56140. */
  56141. constructor(name: string);
  56142. /**
  56143. * Gets the current class name
  56144. * @returns the class name
  56145. */
  56146. getClassName(): string;
  56147. /**
  56148. * Gets the output component
  56149. */
  56150. readonly output: NodeMaterialConnectionPoint;
  56151. protected _buildBlock(state: NodeMaterialBuildState): this;
  56152. }
  56153. }
  56154. declare module BABYLON {
  56155. /**
  56156. * Block used to get the derivative value on x and y of a given input
  56157. */
  56158. export class DerivativeBlock extends NodeMaterialBlock {
  56159. /**
  56160. * Create a new DerivativeBlock
  56161. * @param name defines the block name
  56162. */
  56163. constructor(name: string);
  56164. /**
  56165. * Gets the current class name
  56166. * @returns the class name
  56167. */
  56168. getClassName(): string;
  56169. /**
  56170. * Gets the input component
  56171. */
  56172. readonly input: NodeMaterialConnectionPoint;
  56173. /**
  56174. * Gets the derivative output on x
  56175. */
  56176. readonly dx: NodeMaterialConnectionPoint;
  56177. /**
  56178. * Gets the derivative output on y
  56179. */
  56180. readonly dy: NodeMaterialConnectionPoint;
  56181. protected _buildBlock(state: NodeMaterialBuildState): this;
  56182. }
  56183. }
  56184. declare module BABYLON {
  56185. /**
  56186. * Block used to add support for scene fog
  56187. */
  56188. export class FogBlock extends NodeMaterialBlock {
  56189. private _fogDistanceName;
  56190. private _fogParameters;
  56191. /**
  56192. * Create a new FogBlock
  56193. * @param name defines the block name
  56194. */
  56195. constructor(name: string);
  56196. /**
  56197. * Gets the current class name
  56198. * @returns the class name
  56199. */
  56200. getClassName(): string;
  56201. /**
  56202. * Gets the world position input component
  56203. */
  56204. readonly worldPosition: NodeMaterialConnectionPoint;
  56205. /**
  56206. * Gets the view input component
  56207. */
  56208. readonly view: NodeMaterialConnectionPoint;
  56209. /**
  56210. * Gets the color input component
  56211. */
  56212. readonly input: NodeMaterialConnectionPoint;
  56213. /**
  56214. * Gets the fog color input component
  56215. */
  56216. readonly fogColor: NodeMaterialConnectionPoint;
  56217. /**
  56218. * Gets the output component
  56219. */
  56220. readonly output: NodeMaterialConnectionPoint;
  56221. autoConfigure(material: NodeMaterial): void;
  56222. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56223. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56224. protected _buildBlock(state: NodeMaterialBuildState): this;
  56225. }
  56226. }
  56227. declare module BABYLON {
  56228. /**
  56229. * Block used to add light in the fragment shader
  56230. */
  56231. export class LightBlock extends NodeMaterialBlock {
  56232. private _lightId;
  56233. /**
  56234. * Gets or sets the light associated with this block
  56235. */
  56236. light: Nullable<Light>;
  56237. /**
  56238. * Create a new LightBlock
  56239. * @param name defines the block name
  56240. */
  56241. constructor(name: string);
  56242. /**
  56243. * Gets the current class name
  56244. * @returns the class name
  56245. */
  56246. getClassName(): string;
  56247. /**
  56248. * Gets the world position input component
  56249. */
  56250. readonly worldPosition: NodeMaterialConnectionPoint;
  56251. /**
  56252. * Gets the world normal input component
  56253. */
  56254. readonly worldNormal: NodeMaterialConnectionPoint;
  56255. /**
  56256. * Gets the camera (or eye) position component
  56257. */
  56258. readonly cameraPosition: NodeMaterialConnectionPoint;
  56259. /**
  56260. * Gets the glossiness component
  56261. */
  56262. readonly glossiness: NodeMaterialConnectionPoint;
  56263. /**
  56264. * Gets the glossinness power component
  56265. */
  56266. readonly glossPower: NodeMaterialConnectionPoint;
  56267. /**
  56268. * Gets the diffuse color component
  56269. */
  56270. readonly diffuseColor: NodeMaterialConnectionPoint;
  56271. /**
  56272. * Gets the specular color component
  56273. */
  56274. readonly specularColor: NodeMaterialConnectionPoint;
  56275. /**
  56276. * Gets the diffuse output component
  56277. */
  56278. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56279. /**
  56280. * Gets the specular output component
  56281. */
  56282. readonly specularOutput: NodeMaterialConnectionPoint;
  56283. autoConfigure(material: NodeMaterial): void;
  56284. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56285. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56286. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56287. private _injectVertexCode;
  56288. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56289. serialize(): any;
  56290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56291. }
  56292. }
  56293. declare module BABYLON {
  56294. /**
  56295. * Block used to multiply 2 values
  56296. */
  56297. export class MultiplyBlock extends NodeMaterialBlock {
  56298. /**
  56299. * Creates a new MultiplyBlock
  56300. * @param name defines the block name
  56301. */
  56302. constructor(name: string);
  56303. /**
  56304. * Gets the current class name
  56305. * @returns the class name
  56306. */
  56307. getClassName(): string;
  56308. /**
  56309. * Gets the left operand input component
  56310. */
  56311. readonly left: NodeMaterialConnectionPoint;
  56312. /**
  56313. * Gets the right operand input component
  56314. */
  56315. readonly right: NodeMaterialConnectionPoint;
  56316. /**
  56317. * Gets the output component
  56318. */
  56319. readonly output: NodeMaterialConnectionPoint;
  56320. protected _buildBlock(state: NodeMaterialBuildState): this;
  56321. }
  56322. }
  56323. declare module BABYLON {
  56324. /**
  56325. * Block used to add 2 vectors
  56326. */
  56327. export class AddBlock extends NodeMaterialBlock {
  56328. /**
  56329. * Creates a new AddBlock
  56330. * @param name defines the block name
  56331. */
  56332. constructor(name: string);
  56333. /**
  56334. * Gets the current class name
  56335. * @returns the class name
  56336. */
  56337. getClassName(): string;
  56338. /**
  56339. * Gets the left operand input component
  56340. */
  56341. readonly left: NodeMaterialConnectionPoint;
  56342. /**
  56343. * Gets the right operand input component
  56344. */
  56345. readonly right: NodeMaterialConnectionPoint;
  56346. /**
  56347. * Gets the output component
  56348. */
  56349. readonly output: NodeMaterialConnectionPoint;
  56350. protected _buildBlock(state: NodeMaterialBuildState): this;
  56351. }
  56352. }
  56353. declare module BABYLON {
  56354. /**
  56355. * Block used to scale a vector by a float
  56356. */
  56357. export class ScaleBlock extends NodeMaterialBlock {
  56358. /**
  56359. * Creates a new ScaleBlock
  56360. * @param name defines the block name
  56361. */
  56362. constructor(name: string);
  56363. /**
  56364. * Gets the current class name
  56365. * @returns the class name
  56366. */
  56367. getClassName(): string;
  56368. /**
  56369. * Gets the input component
  56370. */
  56371. readonly input: NodeMaterialConnectionPoint;
  56372. /**
  56373. * Gets the factor input component
  56374. */
  56375. readonly factor: NodeMaterialConnectionPoint;
  56376. /**
  56377. * Gets the output component
  56378. */
  56379. readonly output: NodeMaterialConnectionPoint;
  56380. protected _buildBlock(state: NodeMaterialBuildState): this;
  56381. }
  56382. }
  56383. declare module BABYLON {
  56384. /**
  56385. * Block used to clamp a float
  56386. */
  56387. export class ClampBlock extends NodeMaterialBlock {
  56388. /** Gets or sets the minimum range */
  56389. minimum: number;
  56390. /** Gets or sets the maximum range */
  56391. maximum: number;
  56392. /**
  56393. * Creates a new ClampBlock
  56394. * @param name defines the block name
  56395. */
  56396. constructor(name: string);
  56397. /**
  56398. * Gets the current class name
  56399. * @returns the class name
  56400. */
  56401. getClassName(): string;
  56402. /**
  56403. * Gets the value input component
  56404. */
  56405. readonly value: NodeMaterialConnectionPoint;
  56406. /**
  56407. * Gets the output component
  56408. */
  56409. readonly output: NodeMaterialConnectionPoint;
  56410. protected _buildBlock(state: NodeMaterialBuildState): this;
  56411. protected _dumpPropertiesCode(): string;
  56412. serialize(): any;
  56413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56414. }
  56415. }
  56416. declare module BABYLON {
  56417. /**
  56418. * Block used to apply a cross product between 2 vectors
  56419. */
  56420. export class CrossBlock extends NodeMaterialBlock {
  56421. /**
  56422. * Creates a new CrossBlock
  56423. * @param name defines the block name
  56424. */
  56425. constructor(name: string);
  56426. /**
  56427. * Gets the current class name
  56428. * @returns the class name
  56429. */
  56430. getClassName(): string;
  56431. /**
  56432. * Gets the left operand input component
  56433. */
  56434. readonly left: NodeMaterialConnectionPoint;
  56435. /**
  56436. * Gets the right operand input component
  56437. */
  56438. readonly right: NodeMaterialConnectionPoint;
  56439. /**
  56440. * Gets the output component
  56441. */
  56442. readonly output: NodeMaterialConnectionPoint;
  56443. protected _buildBlock(state: NodeMaterialBuildState): this;
  56444. }
  56445. }
  56446. declare module BABYLON {
  56447. /**
  56448. * Block used to apply a dot product between 2 vectors
  56449. */
  56450. export class DotBlock extends NodeMaterialBlock {
  56451. /**
  56452. * Creates a new DotBlock
  56453. * @param name defines the block name
  56454. */
  56455. constructor(name: string);
  56456. /**
  56457. * Gets the current class name
  56458. * @returns the class name
  56459. */
  56460. getClassName(): string;
  56461. /**
  56462. * Gets the left operand input component
  56463. */
  56464. readonly left: NodeMaterialConnectionPoint;
  56465. /**
  56466. * Gets the right operand input component
  56467. */
  56468. readonly right: NodeMaterialConnectionPoint;
  56469. /**
  56470. * Gets the output component
  56471. */
  56472. readonly output: NodeMaterialConnectionPoint;
  56473. protected _buildBlock(state: NodeMaterialBuildState): this;
  56474. }
  56475. }
  56476. declare module BABYLON {
  56477. /**
  56478. * Block used to remap a float from a range to a new one
  56479. */
  56480. export class RemapBlock extends NodeMaterialBlock {
  56481. /**
  56482. * Gets or sets the source range
  56483. */
  56484. sourceRange: Vector2;
  56485. /**
  56486. * Gets or sets the target range
  56487. */
  56488. targetRange: Vector2;
  56489. /**
  56490. * Creates a new RemapBlock
  56491. * @param name defines the block name
  56492. */
  56493. constructor(name: string);
  56494. /**
  56495. * Gets the current class name
  56496. * @returns the class name
  56497. */
  56498. getClassName(): string;
  56499. /**
  56500. * Gets the input component
  56501. */
  56502. readonly input: NodeMaterialConnectionPoint;
  56503. /**
  56504. * Gets the source min input component
  56505. */
  56506. readonly sourceMin: NodeMaterialConnectionPoint;
  56507. /**
  56508. * Gets the source max input component
  56509. */
  56510. readonly sourceMax: NodeMaterialConnectionPoint;
  56511. /**
  56512. * Gets the target min input component
  56513. */
  56514. readonly targetMin: NodeMaterialConnectionPoint;
  56515. /**
  56516. * Gets the target max input component
  56517. */
  56518. readonly targetMax: NodeMaterialConnectionPoint;
  56519. /**
  56520. * Gets the output component
  56521. */
  56522. readonly output: NodeMaterialConnectionPoint;
  56523. protected _buildBlock(state: NodeMaterialBuildState): this;
  56524. protected _dumpPropertiesCode(): string;
  56525. serialize(): any;
  56526. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56527. }
  56528. }
  56529. declare module BABYLON {
  56530. /**
  56531. * Block used to normalize a vector
  56532. */
  56533. export class NormalizeBlock extends NodeMaterialBlock {
  56534. /**
  56535. * Creates a new NormalizeBlock
  56536. * @param name defines the block name
  56537. */
  56538. constructor(name: string);
  56539. /**
  56540. * Gets the current class name
  56541. * @returns the class name
  56542. */
  56543. getClassName(): string;
  56544. /**
  56545. * Gets the input component
  56546. */
  56547. readonly input: NodeMaterialConnectionPoint;
  56548. /**
  56549. * Gets the output component
  56550. */
  56551. readonly output: NodeMaterialConnectionPoint;
  56552. protected _buildBlock(state: NodeMaterialBuildState): this;
  56553. }
  56554. }
  56555. declare module BABYLON {
  56556. /**
  56557. * Operations supported by the Trigonometry block
  56558. */
  56559. export enum TrigonometryBlockOperations {
  56560. /** Cos */
  56561. Cos = 0,
  56562. /** Sin */
  56563. Sin = 1,
  56564. /** Abs */
  56565. Abs = 2,
  56566. /** Exp */
  56567. Exp = 3,
  56568. /** Exp2 */
  56569. Exp2 = 4,
  56570. /** Round */
  56571. Round = 5,
  56572. /** Floor */
  56573. Floor = 6,
  56574. /** Ceiling */
  56575. Ceiling = 7,
  56576. /** Square root */
  56577. Sqrt = 8,
  56578. /** Log */
  56579. Log = 9,
  56580. /** Tangent */
  56581. Tan = 10,
  56582. /** Arc tangent */
  56583. ArcTan = 11,
  56584. /** Arc cosinus */
  56585. ArcCos = 12,
  56586. /** Arc sinus */
  56587. ArcSin = 13,
  56588. /** Fraction */
  56589. Fract = 14,
  56590. /** Sign */
  56591. Sign = 15,
  56592. /** To radians (from degrees) */
  56593. Radians = 16,
  56594. /** To degrees (from radians) */
  56595. Degrees = 17
  56596. }
  56597. /**
  56598. * Block used to apply trigonometry operation to floats
  56599. */
  56600. export class TrigonometryBlock extends NodeMaterialBlock {
  56601. /**
  56602. * Gets or sets the operation applied by the block
  56603. */
  56604. operation: TrigonometryBlockOperations;
  56605. /**
  56606. * Creates a new TrigonometryBlock
  56607. * @param name defines the block name
  56608. */
  56609. constructor(name: string);
  56610. /**
  56611. * Gets the current class name
  56612. * @returns the class name
  56613. */
  56614. getClassName(): string;
  56615. /**
  56616. * Gets the input component
  56617. */
  56618. readonly input: NodeMaterialConnectionPoint;
  56619. /**
  56620. * Gets the output component
  56621. */
  56622. readonly output: NodeMaterialConnectionPoint;
  56623. protected _buildBlock(state: NodeMaterialBuildState): this;
  56624. serialize(): any;
  56625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56626. protected _dumpPropertiesCode(): string;
  56627. }
  56628. }
  56629. declare module BABYLON {
  56630. /**
  56631. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56632. */
  56633. export class ColorMergerBlock extends NodeMaterialBlock {
  56634. /**
  56635. * Create a new ColorMergerBlock
  56636. * @param name defines the block name
  56637. */
  56638. constructor(name: string);
  56639. /**
  56640. * Gets the current class name
  56641. * @returns the class name
  56642. */
  56643. getClassName(): string;
  56644. /**
  56645. * Gets the rgb component (input)
  56646. */
  56647. readonly rgbIn: NodeMaterialConnectionPoint;
  56648. /**
  56649. * Gets the r component (input)
  56650. */
  56651. readonly r: NodeMaterialConnectionPoint;
  56652. /**
  56653. * Gets the g component (input)
  56654. */
  56655. readonly g: NodeMaterialConnectionPoint;
  56656. /**
  56657. * Gets the b component (input)
  56658. */
  56659. readonly b: NodeMaterialConnectionPoint;
  56660. /**
  56661. * Gets the a component (input)
  56662. */
  56663. readonly a: NodeMaterialConnectionPoint;
  56664. /**
  56665. * Gets the rgba component (output)
  56666. */
  56667. readonly rgba: NodeMaterialConnectionPoint;
  56668. /**
  56669. * Gets the rgb component (output)
  56670. */
  56671. readonly rgbOut: NodeMaterialConnectionPoint;
  56672. /**
  56673. * Gets the rgb component (output)
  56674. * @deprecated Please use rgbOut instead.
  56675. */
  56676. readonly rgb: NodeMaterialConnectionPoint;
  56677. protected _buildBlock(state: NodeMaterialBuildState): this;
  56678. }
  56679. }
  56680. declare module BABYLON {
  56681. /**
  56682. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56683. */
  56684. export class VectorMergerBlock extends NodeMaterialBlock {
  56685. /**
  56686. * Create a new VectorMergerBlock
  56687. * @param name defines the block name
  56688. */
  56689. constructor(name: string);
  56690. /**
  56691. * Gets the current class name
  56692. * @returns the class name
  56693. */
  56694. getClassName(): string;
  56695. /**
  56696. * Gets the xyz component (input)
  56697. */
  56698. readonly xyzIn: NodeMaterialConnectionPoint;
  56699. /**
  56700. * Gets the xy component (input)
  56701. */
  56702. readonly xyIn: NodeMaterialConnectionPoint;
  56703. /**
  56704. * Gets the x component (input)
  56705. */
  56706. readonly x: NodeMaterialConnectionPoint;
  56707. /**
  56708. * Gets the y component (input)
  56709. */
  56710. readonly y: NodeMaterialConnectionPoint;
  56711. /**
  56712. * Gets the z component (input)
  56713. */
  56714. readonly z: NodeMaterialConnectionPoint;
  56715. /**
  56716. * Gets the w component (input)
  56717. */
  56718. readonly w: NodeMaterialConnectionPoint;
  56719. /**
  56720. * Gets the xyzw component (output)
  56721. */
  56722. readonly xyzw: NodeMaterialConnectionPoint;
  56723. /**
  56724. * Gets the xyz component (output)
  56725. */
  56726. readonly xyzOut: NodeMaterialConnectionPoint;
  56727. /**
  56728. * Gets the xy component (output)
  56729. */
  56730. readonly xyOut: NodeMaterialConnectionPoint;
  56731. /**
  56732. * Gets the xy component (output)
  56733. * @deprecated Please use xyOut instead.
  56734. */
  56735. readonly xy: NodeMaterialConnectionPoint;
  56736. /**
  56737. * Gets the xyz component (output)
  56738. * @deprecated Please use xyzOut instead.
  56739. */
  56740. readonly xyz: NodeMaterialConnectionPoint;
  56741. protected _buildBlock(state: NodeMaterialBuildState): this;
  56742. }
  56743. }
  56744. declare module BABYLON {
  56745. /**
  56746. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56747. */
  56748. export class ColorSplitterBlock extends NodeMaterialBlock {
  56749. /**
  56750. * Create a new ColorSplitterBlock
  56751. * @param name defines the block name
  56752. */
  56753. constructor(name: string);
  56754. /**
  56755. * Gets the current class name
  56756. * @returns the class name
  56757. */
  56758. getClassName(): string;
  56759. /**
  56760. * Gets the rgba component (input)
  56761. */
  56762. readonly rgba: NodeMaterialConnectionPoint;
  56763. /**
  56764. * Gets the rgb component (input)
  56765. */
  56766. readonly rgbIn: NodeMaterialConnectionPoint;
  56767. /**
  56768. * Gets the rgb component (output)
  56769. */
  56770. readonly rgbOut: NodeMaterialConnectionPoint;
  56771. /**
  56772. * Gets the r component (output)
  56773. */
  56774. readonly r: NodeMaterialConnectionPoint;
  56775. /**
  56776. * Gets the g component (output)
  56777. */
  56778. readonly g: NodeMaterialConnectionPoint;
  56779. /**
  56780. * Gets the b component (output)
  56781. */
  56782. readonly b: NodeMaterialConnectionPoint;
  56783. /**
  56784. * Gets the a component (output)
  56785. */
  56786. readonly a: NodeMaterialConnectionPoint;
  56787. protected _inputRename(name: string): string;
  56788. protected _outputRename(name: string): string;
  56789. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56790. }
  56791. }
  56792. declare module BABYLON {
  56793. /**
  56794. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56795. */
  56796. export class VectorSplitterBlock extends NodeMaterialBlock {
  56797. /**
  56798. * Create a new VectorSplitterBlock
  56799. * @param name defines the block name
  56800. */
  56801. constructor(name: string);
  56802. /**
  56803. * Gets the current class name
  56804. * @returns the class name
  56805. */
  56806. getClassName(): string;
  56807. /**
  56808. * Gets the xyzw component (input)
  56809. */
  56810. readonly xyzw: NodeMaterialConnectionPoint;
  56811. /**
  56812. * Gets the xyz component (input)
  56813. */
  56814. readonly xyzIn: NodeMaterialConnectionPoint;
  56815. /**
  56816. * Gets the xy component (input)
  56817. */
  56818. readonly xyIn: NodeMaterialConnectionPoint;
  56819. /**
  56820. * Gets the xyz component (output)
  56821. */
  56822. readonly xyzOut: NodeMaterialConnectionPoint;
  56823. /**
  56824. * Gets the xy component (output)
  56825. */
  56826. readonly xyOut: NodeMaterialConnectionPoint;
  56827. /**
  56828. * Gets the x component (output)
  56829. */
  56830. readonly x: NodeMaterialConnectionPoint;
  56831. /**
  56832. * Gets the y component (output)
  56833. */
  56834. readonly y: NodeMaterialConnectionPoint;
  56835. /**
  56836. * Gets the z component (output)
  56837. */
  56838. readonly z: NodeMaterialConnectionPoint;
  56839. /**
  56840. * Gets the w component (output)
  56841. */
  56842. readonly w: NodeMaterialConnectionPoint;
  56843. protected _inputRename(name: string): string;
  56844. protected _outputRename(name: string): string;
  56845. protected _buildBlock(state: NodeMaterialBuildState): this;
  56846. }
  56847. }
  56848. declare module BABYLON {
  56849. /**
  56850. * Block used to lerp between 2 values
  56851. */
  56852. export class LerpBlock extends NodeMaterialBlock {
  56853. /**
  56854. * Creates a new LerpBlock
  56855. * @param name defines the block name
  56856. */
  56857. constructor(name: string);
  56858. /**
  56859. * Gets the current class name
  56860. * @returns the class name
  56861. */
  56862. getClassName(): string;
  56863. /**
  56864. * Gets the left operand input component
  56865. */
  56866. readonly left: NodeMaterialConnectionPoint;
  56867. /**
  56868. * Gets the right operand input component
  56869. */
  56870. readonly right: NodeMaterialConnectionPoint;
  56871. /**
  56872. * Gets the gradient operand input component
  56873. */
  56874. readonly gradient: NodeMaterialConnectionPoint;
  56875. /**
  56876. * Gets the output component
  56877. */
  56878. readonly output: NodeMaterialConnectionPoint;
  56879. protected _buildBlock(state: NodeMaterialBuildState): this;
  56880. }
  56881. }
  56882. declare module BABYLON {
  56883. /**
  56884. * Block used to divide 2 vectors
  56885. */
  56886. export class DivideBlock extends NodeMaterialBlock {
  56887. /**
  56888. * Creates a new DivideBlock
  56889. * @param name defines the block name
  56890. */
  56891. constructor(name: string);
  56892. /**
  56893. * Gets the current class name
  56894. * @returns the class name
  56895. */
  56896. getClassName(): string;
  56897. /**
  56898. * Gets the left operand input component
  56899. */
  56900. readonly left: NodeMaterialConnectionPoint;
  56901. /**
  56902. * Gets the right operand input component
  56903. */
  56904. readonly right: NodeMaterialConnectionPoint;
  56905. /**
  56906. * Gets the output component
  56907. */
  56908. readonly output: NodeMaterialConnectionPoint;
  56909. protected _buildBlock(state: NodeMaterialBuildState): this;
  56910. }
  56911. }
  56912. declare module BABYLON {
  56913. /**
  56914. * Block used to subtract 2 vectors
  56915. */
  56916. export class SubtractBlock extends NodeMaterialBlock {
  56917. /**
  56918. * Creates a new SubtractBlock
  56919. * @param name defines the block name
  56920. */
  56921. constructor(name: string);
  56922. /**
  56923. * Gets the current class name
  56924. * @returns the class name
  56925. */
  56926. getClassName(): string;
  56927. /**
  56928. * Gets the left operand input component
  56929. */
  56930. readonly left: NodeMaterialConnectionPoint;
  56931. /**
  56932. * Gets the right operand input component
  56933. */
  56934. readonly right: NodeMaterialConnectionPoint;
  56935. /**
  56936. * Gets the output component
  56937. */
  56938. readonly output: NodeMaterialConnectionPoint;
  56939. protected _buildBlock(state: NodeMaterialBuildState): this;
  56940. }
  56941. }
  56942. declare module BABYLON {
  56943. /**
  56944. * Block used to step a value
  56945. */
  56946. export class StepBlock extends NodeMaterialBlock {
  56947. /**
  56948. * Creates a new StepBlock
  56949. * @param name defines the block name
  56950. */
  56951. constructor(name: string);
  56952. /**
  56953. * Gets the current class name
  56954. * @returns the class name
  56955. */
  56956. getClassName(): string;
  56957. /**
  56958. * Gets the value operand input component
  56959. */
  56960. readonly value: NodeMaterialConnectionPoint;
  56961. /**
  56962. * Gets the edge operand input component
  56963. */
  56964. readonly edge: NodeMaterialConnectionPoint;
  56965. /**
  56966. * Gets the output component
  56967. */
  56968. readonly output: NodeMaterialConnectionPoint;
  56969. protected _buildBlock(state: NodeMaterialBuildState): this;
  56970. }
  56971. }
  56972. declare module BABYLON {
  56973. /**
  56974. * Block used to get the opposite (1 - x) of a value
  56975. */
  56976. export class OneMinusBlock extends NodeMaterialBlock {
  56977. /**
  56978. * Creates a new OneMinusBlock
  56979. * @param name defines the block name
  56980. */
  56981. constructor(name: string);
  56982. /**
  56983. * Gets the current class name
  56984. * @returns the class name
  56985. */
  56986. getClassName(): string;
  56987. /**
  56988. * Gets the input component
  56989. */
  56990. readonly input: NodeMaterialConnectionPoint;
  56991. /**
  56992. * Gets the output component
  56993. */
  56994. readonly output: NodeMaterialConnectionPoint;
  56995. protected _buildBlock(state: NodeMaterialBuildState): this;
  56996. }
  56997. }
  56998. declare module BABYLON {
  56999. /**
  57000. * Block used to get the view direction
  57001. */
  57002. export class ViewDirectionBlock extends NodeMaterialBlock {
  57003. /**
  57004. * Creates a new ViewDirectionBlock
  57005. * @param name defines the block name
  57006. */
  57007. constructor(name: string);
  57008. /**
  57009. * Gets the current class name
  57010. * @returns the class name
  57011. */
  57012. getClassName(): string;
  57013. /**
  57014. * Gets the world position component
  57015. */
  57016. readonly worldPosition: NodeMaterialConnectionPoint;
  57017. /**
  57018. * Gets the camera position component
  57019. */
  57020. readonly cameraPosition: NodeMaterialConnectionPoint;
  57021. /**
  57022. * Gets the output component
  57023. */
  57024. readonly output: NodeMaterialConnectionPoint;
  57025. autoConfigure(material: NodeMaterial): void;
  57026. protected _buildBlock(state: NodeMaterialBuildState): this;
  57027. }
  57028. }
  57029. declare module BABYLON {
  57030. /**
  57031. * Block used to compute fresnel value
  57032. */
  57033. export class FresnelBlock extends NodeMaterialBlock {
  57034. /**
  57035. * Create a new FresnelBlock
  57036. * @param name defines the block name
  57037. */
  57038. constructor(name: string);
  57039. /**
  57040. * Gets the current class name
  57041. * @returns the class name
  57042. */
  57043. getClassName(): string;
  57044. /**
  57045. * Gets the world normal input component
  57046. */
  57047. readonly worldNormal: NodeMaterialConnectionPoint;
  57048. /**
  57049. * Gets the view direction input component
  57050. */
  57051. readonly viewDirection: NodeMaterialConnectionPoint;
  57052. /**
  57053. * Gets the bias input component
  57054. */
  57055. readonly bias: NodeMaterialConnectionPoint;
  57056. /**
  57057. * Gets the camera (or eye) position component
  57058. */
  57059. readonly power: NodeMaterialConnectionPoint;
  57060. /**
  57061. * Gets the fresnel output component
  57062. */
  57063. readonly fresnel: NodeMaterialConnectionPoint;
  57064. autoConfigure(material: NodeMaterial): void;
  57065. protected _buildBlock(state: NodeMaterialBuildState): this;
  57066. }
  57067. }
  57068. declare module BABYLON {
  57069. /**
  57070. * Block used to get the max of 2 values
  57071. */
  57072. export class MaxBlock extends NodeMaterialBlock {
  57073. /**
  57074. * Creates a new MaxBlock
  57075. * @param name defines the block name
  57076. */
  57077. constructor(name: string);
  57078. /**
  57079. * Gets the current class name
  57080. * @returns the class name
  57081. */
  57082. getClassName(): string;
  57083. /**
  57084. * Gets the left operand input component
  57085. */
  57086. readonly left: NodeMaterialConnectionPoint;
  57087. /**
  57088. * Gets the right operand input component
  57089. */
  57090. readonly right: NodeMaterialConnectionPoint;
  57091. /**
  57092. * Gets the output component
  57093. */
  57094. readonly output: NodeMaterialConnectionPoint;
  57095. protected _buildBlock(state: NodeMaterialBuildState): this;
  57096. }
  57097. }
  57098. declare module BABYLON {
  57099. /**
  57100. * Block used to get the min of 2 values
  57101. */
  57102. export class MinBlock extends NodeMaterialBlock {
  57103. /**
  57104. * Creates a new MinBlock
  57105. * @param name defines the block name
  57106. */
  57107. constructor(name: string);
  57108. /**
  57109. * Gets the current class name
  57110. * @returns the class name
  57111. */
  57112. getClassName(): string;
  57113. /**
  57114. * Gets the left operand input component
  57115. */
  57116. readonly left: NodeMaterialConnectionPoint;
  57117. /**
  57118. * Gets the right operand input component
  57119. */
  57120. readonly right: NodeMaterialConnectionPoint;
  57121. /**
  57122. * Gets the output component
  57123. */
  57124. readonly output: NodeMaterialConnectionPoint;
  57125. protected _buildBlock(state: NodeMaterialBuildState): this;
  57126. }
  57127. }
  57128. declare module BABYLON {
  57129. /**
  57130. * Block used to get the distance between 2 values
  57131. */
  57132. export class DistanceBlock extends NodeMaterialBlock {
  57133. /**
  57134. * Creates a new DistanceBlock
  57135. * @param name defines the block name
  57136. */
  57137. constructor(name: string);
  57138. /**
  57139. * Gets the current class name
  57140. * @returns the class name
  57141. */
  57142. getClassName(): string;
  57143. /**
  57144. * Gets the left operand input component
  57145. */
  57146. readonly left: NodeMaterialConnectionPoint;
  57147. /**
  57148. * Gets the right operand input component
  57149. */
  57150. readonly right: NodeMaterialConnectionPoint;
  57151. /**
  57152. * Gets the output component
  57153. */
  57154. readonly output: NodeMaterialConnectionPoint;
  57155. protected _buildBlock(state: NodeMaterialBuildState): this;
  57156. }
  57157. }
  57158. declare module BABYLON {
  57159. /**
  57160. * Block used to get the length of a vector
  57161. */
  57162. export class LengthBlock extends NodeMaterialBlock {
  57163. /**
  57164. * Creates a new LengthBlock
  57165. * @param name defines the block name
  57166. */
  57167. constructor(name: string);
  57168. /**
  57169. * Gets the current class name
  57170. * @returns the class name
  57171. */
  57172. getClassName(): string;
  57173. /**
  57174. * Gets the value input component
  57175. */
  57176. readonly value: NodeMaterialConnectionPoint;
  57177. /**
  57178. * Gets the output component
  57179. */
  57180. readonly output: NodeMaterialConnectionPoint;
  57181. protected _buildBlock(state: NodeMaterialBuildState): this;
  57182. }
  57183. }
  57184. declare module BABYLON {
  57185. /**
  57186. * Block used to get negative version of a value (i.e. x * -1)
  57187. */
  57188. export class NegateBlock extends NodeMaterialBlock {
  57189. /**
  57190. * Creates a new NegateBlock
  57191. * @param name defines the block name
  57192. */
  57193. constructor(name: string);
  57194. /**
  57195. * Gets the current class name
  57196. * @returns the class name
  57197. */
  57198. getClassName(): string;
  57199. /**
  57200. * Gets the value input component
  57201. */
  57202. readonly value: NodeMaterialConnectionPoint;
  57203. /**
  57204. * Gets the output component
  57205. */
  57206. readonly output: NodeMaterialConnectionPoint;
  57207. protected _buildBlock(state: NodeMaterialBuildState): this;
  57208. }
  57209. }
  57210. declare module BABYLON {
  57211. /**
  57212. * Block used to get the value of the first parameter raised to the power of the second
  57213. */
  57214. export class PowBlock extends NodeMaterialBlock {
  57215. /**
  57216. * Creates a new PowBlock
  57217. * @param name defines the block name
  57218. */
  57219. constructor(name: string);
  57220. /**
  57221. * Gets the current class name
  57222. * @returns the class name
  57223. */
  57224. getClassName(): string;
  57225. /**
  57226. * Gets the value operand input component
  57227. */
  57228. readonly value: NodeMaterialConnectionPoint;
  57229. /**
  57230. * Gets the power operand input component
  57231. */
  57232. readonly power: NodeMaterialConnectionPoint;
  57233. /**
  57234. * Gets the output component
  57235. */
  57236. readonly output: NodeMaterialConnectionPoint;
  57237. protected _buildBlock(state: NodeMaterialBuildState): this;
  57238. }
  57239. }
  57240. declare module BABYLON {
  57241. /**
  57242. * Block used to get a random number
  57243. */
  57244. export class RandomNumberBlock extends NodeMaterialBlock {
  57245. /**
  57246. * Creates a new RandomNumberBlock
  57247. * @param name defines the block name
  57248. */
  57249. constructor(name: string);
  57250. /**
  57251. * Gets the current class name
  57252. * @returns the class name
  57253. */
  57254. getClassName(): string;
  57255. /**
  57256. * Gets the seed input component
  57257. */
  57258. readonly seed: NodeMaterialConnectionPoint;
  57259. /**
  57260. * Gets the output component
  57261. */
  57262. readonly output: NodeMaterialConnectionPoint;
  57263. protected _buildBlock(state: NodeMaterialBuildState): this;
  57264. }
  57265. }
  57266. declare module BABYLON {
  57267. /**
  57268. * Block used to compute arc tangent of 2 values
  57269. */
  57270. export class ArcTan2Block extends NodeMaterialBlock {
  57271. /**
  57272. * Creates a new ArcTan2Block
  57273. * @param name defines the block name
  57274. */
  57275. constructor(name: string);
  57276. /**
  57277. * Gets the current class name
  57278. * @returns the class name
  57279. */
  57280. getClassName(): string;
  57281. /**
  57282. * Gets the x operand input component
  57283. */
  57284. readonly x: NodeMaterialConnectionPoint;
  57285. /**
  57286. * Gets the y operand input component
  57287. */
  57288. readonly y: NodeMaterialConnectionPoint;
  57289. /**
  57290. * Gets the output component
  57291. */
  57292. readonly output: NodeMaterialConnectionPoint;
  57293. protected _buildBlock(state: NodeMaterialBuildState): this;
  57294. }
  57295. }
  57296. declare module BABYLON {
  57297. /**
  57298. * Block used to smooth step a value
  57299. */
  57300. export class SmoothStepBlock extends NodeMaterialBlock {
  57301. /**
  57302. * Creates a new SmoothStepBlock
  57303. * @param name defines the block name
  57304. */
  57305. constructor(name: string);
  57306. /**
  57307. * Gets the current class name
  57308. * @returns the class name
  57309. */
  57310. getClassName(): string;
  57311. /**
  57312. * Gets the value operand input component
  57313. */
  57314. readonly value: NodeMaterialConnectionPoint;
  57315. /**
  57316. * Gets the first edge operand input component
  57317. */
  57318. readonly edge0: NodeMaterialConnectionPoint;
  57319. /**
  57320. * Gets the second edge operand input component
  57321. */
  57322. readonly edge1: NodeMaterialConnectionPoint;
  57323. /**
  57324. * Gets the output component
  57325. */
  57326. readonly output: NodeMaterialConnectionPoint;
  57327. protected _buildBlock(state: NodeMaterialBuildState): this;
  57328. }
  57329. }
  57330. declare module BABYLON {
  57331. /**
  57332. * Block used to get the reciprocal (1 / x) of a value
  57333. */
  57334. export class ReciprocalBlock extends NodeMaterialBlock {
  57335. /**
  57336. * Creates a new ReciprocalBlock
  57337. * @param name defines the block name
  57338. */
  57339. constructor(name: string);
  57340. /**
  57341. * Gets the current class name
  57342. * @returns the class name
  57343. */
  57344. getClassName(): string;
  57345. /**
  57346. * Gets the input component
  57347. */
  57348. readonly input: NodeMaterialConnectionPoint;
  57349. /**
  57350. * Gets the output component
  57351. */
  57352. readonly output: NodeMaterialConnectionPoint;
  57353. protected _buildBlock(state: NodeMaterialBuildState): this;
  57354. }
  57355. }
  57356. declare module BABYLON {
  57357. /**
  57358. * Block used to replace a color by another one
  57359. */
  57360. export class ReplaceColorBlock extends NodeMaterialBlock {
  57361. /**
  57362. * Creates a new ReplaceColorBlock
  57363. * @param name defines the block name
  57364. */
  57365. constructor(name: string);
  57366. /**
  57367. * Gets the current class name
  57368. * @returns the class name
  57369. */
  57370. getClassName(): string;
  57371. /**
  57372. * Gets the value input component
  57373. */
  57374. readonly value: NodeMaterialConnectionPoint;
  57375. /**
  57376. * Gets the reference input component
  57377. */
  57378. readonly reference: NodeMaterialConnectionPoint;
  57379. /**
  57380. * Gets the distance input component
  57381. */
  57382. readonly distance: NodeMaterialConnectionPoint;
  57383. /**
  57384. * Gets the replacement input component
  57385. */
  57386. readonly replacement: NodeMaterialConnectionPoint;
  57387. /**
  57388. * Gets the output component
  57389. */
  57390. readonly output: NodeMaterialConnectionPoint;
  57391. protected _buildBlock(state: NodeMaterialBuildState): this;
  57392. }
  57393. }
  57394. declare module BABYLON {
  57395. /**
  57396. * Block used to posterize a value
  57397. * @see https://en.wikipedia.org/wiki/Posterization
  57398. */
  57399. export class PosterizeBlock extends NodeMaterialBlock {
  57400. /**
  57401. * Creates a new PosterizeBlock
  57402. * @param name defines the block name
  57403. */
  57404. constructor(name: string);
  57405. /**
  57406. * Gets the current class name
  57407. * @returns the class name
  57408. */
  57409. getClassName(): string;
  57410. /**
  57411. * Gets the value input component
  57412. */
  57413. readonly value: NodeMaterialConnectionPoint;
  57414. /**
  57415. * Gets the steps input component
  57416. */
  57417. readonly steps: NodeMaterialConnectionPoint;
  57418. /**
  57419. * Gets the output component
  57420. */
  57421. readonly output: NodeMaterialConnectionPoint;
  57422. protected _buildBlock(state: NodeMaterialBuildState): this;
  57423. }
  57424. }
  57425. declare module BABYLON {
  57426. /**
  57427. * Operations supported by the Wave block
  57428. */
  57429. export enum WaveBlockKind {
  57430. /** SawTooth */
  57431. SawTooth = 0,
  57432. /** Square */
  57433. Square = 1,
  57434. /** Triangle */
  57435. Triangle = 2
  57436. }
  57437. /**
  57438. * Block used to apply wave operation to floats
  57439. */
  57440. export class WaveBlock extends NodeMaterialBlock {
  57441. /**
  57442. * Gets or sets the kibnd of wave to be applied by the block
  57443. */
  57444. kind: WaveBlockKind;
  57445. /**
  57446. * Creates a new WaveBlock
  57447. * @param name defines the block name
  57448. */
  57449. constructor(name: string);
  57450. /**
  57451. * Gets the current class name
  57452. * @returns the class name
  57453. */
  57454. getClassName(): string;
  57455. /**
  57456. * Gets the input component
  57457. */
  57458. readonly input: NodeMaterialConnectionPoint;
  57459. /**
  57460. * Gets the output component
  57461. */
  57462. readonly output: NodeMaterialConnectionPoint;
  57463. protected _buildBlock(state: NodeMaterialBuildState): this;
  57464. serialize(): any;
  57465. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57466. }
  57467. }
  57468. declare module BABYLON {
  57469. /**
  57470. * Class used to store a color step for the GradientBlock
  57471. */
  57472. export class GradientBlockColorStep {
  57473. /**
  57474. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  57475. */
  57476. step: number;
  57477. /**
  57478. * Gets or sets the color associated with this step
  57479. */
  57480. color: Color3;
  57481. /**
  57482. * Creates a new GradientBlockColorStep
  57483. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  57484. * @param color defines the color associated with this step
  57485. */
  57486. constructor(
  57487. /**
  57488. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  57489. */
  57490. step: number,
  57491. /**
  57492. * Gets or sets the color associated with this step
  57493. */
  57494. color: Color3);
  57495. }
  57496. /**
  57497. * Block used to return a color from a gradient based on an input value between 0 and 1
  57498. */
  57499. export class GradientBlock extends NodeMaterialBlock {
  57500. /**
  57501. * Gets or sets the list of color steps
  57502. */
  57503. colorSteps: GradientBlockColorStep[];
  57504. /**
  57505. * Creates a new GradientBlock
  57506. * @param name defines the block name
  57507. */
  57508. constructor(name: string);
  57509. /**
  57510. * Gets the current class name
  57511. * @returns the class name
  57512. */
  57513. getClassName(): string;
  57514. /**
  57515. * Gets the gradient input component
  57516. */
  57517. readonly gradient: NodeMaterialConnectionPoint;
  57518. /**
  57519. * Gets the output component
  57520. */
  57521. readonly output: NodeMaterialConnectionPoint;
  57522. private _writeColorConstant;
  57523. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57524. serialize(): any;
  57525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57526. protected _dumpPropertiesCode(): string;
  57527. }
  57528. }
  57529. declare module BABYLON {
  57530. /**
  57531. * Block used to normalize lerp between 2 values
  57532. */
  57533. export class NLerpBlock extends NodeMaterialBlock {
  57534. /**
  57535. * Creates a new NLerpBlock
  57536. * @param name defines the block name
  57537. */
  57538. constructor(name: string);
  57539. /**
  57540. * Gets the current class name
  57541. * @returns the class name
  57542. */
  57543. getClassName(): string;
  57544. /**
  57545. * Gets the left operand input component
  57546. */
  57547. readonly left: NodeMaterialConnectionPoint;
  57548. /**
  57549. * Gets the right operand input component
  57550. */
  57551. readonly right: NodeMaterialConnectionPoint;
  57552. /**
  57553. * Gets the gradient operand input component
  57554. */
  57555. readonly gradient: NodeMaterialConnectionPoint;
  57556. /**
  57557. * Gets the output component
  57558. */
  57559. readonly output: NodeMaterialConnectionPoint;
  57560. protected _buildBlock(state: NodeMaterialBuildState): this;
  57561. }
  57562. }
  57563. declare module BABYLON {
  57564. /**
  57565. * block used to Generate a Worley Noise 3D Noise Pattern
  57566. */
  57567. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  57568. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57569. manhattanDistance: boolean;
  57570. /**
  57571. * Creates a new WorleyNoise3DBlock
  57572. * @param name defines the block name
  57573. */
  57574. constructor(name: string);
  57575. /**
  57576. * Gets the current class name
  57577. * @returns the class name
  57578. */
  57579. getClassName(): string;
  57580. /**
  57581. * Gets the seed input component
  57582. */
  57583. readonly seed: NodeMaterialConnectionPoint;
  57584. /**
  57585. * Gets the jitter input component
  57586. */
  57587. readonly jitter: NodeMaterialConnectionPoint;
  57588. /**
  57589. * Gets the output component
  57590. */
  57591. readonly output: NodeMaterialConnectionPoint;
  57592. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57593. /**
  57594. * Exposes the properties to the UI?
  57595. */
  57596. protected _dumpPropertiesCode(): string;
  57597. /**
  57598. * Exposes the properties to the Seralize?
  57599. */
  57600. serialize(): any;
  57601. /**
  57602. * Exposes the properties to the deseralize?
  57603. */
  57604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57605. }
  57606. }
  57607. declare module BABYLON {
  57608. /**
  57609. * block used to Generate a Simplex Perlin 3d Noise Pattern
  57610. */
  57611. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  57612. /**
  57613. * Creates a new SimplexPerlin3DBlock
  57614. * @param name defines the block name
  57615. */
  57616. constructor(name: string);
  57617. /**
  57618. * Gets the current class name
  57619. * @returns the class name
  57620. */
  57621. getClassName(): string;
  57622. /**
  57623. * Gets the seed operand input component
  57624. */
  57625. readonly seed: NodeMaterialConnectionPoint;
  57626. /**
  57627. * Gets the output component
  57628. */
  57629. readonly output: NodeMaterialConnectionPoint;
  57630. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57631. }
  57632. }
  57633. declare module BABYLON {
  57634. /**
  57635. * Block used to blend normals
  57636. */
  57637. export class NormalBlendBlock extends NodeMaterialBlock {
  57638. /**
  57639. * Creates a new NormalBlendBlock
  57640. * @param name defines the block name
  57641. */
  57642. constructor(name: string);
  57643. /**
  57644. * Gets the current class name
  57645. * @returns the class name
  57646. */
  57647. getClassName(): string;
  57648. /**
  57649. * Gets the first input component
  57650. */
  57651. readonly normalMap0: NodeMaterialConnectionPoint;
  57652. /**
  57653. * Gets the second input component
  57654. */
  57655. readonly normalMap1: NodeMaterialConnectionPoint;
  57656. /**
  57657. * Gets the output component
  57658. */
  57659. readonly output: NodeMaterialConnectionPoint;
  57660. protected _buildBlock(state: NodeMaterialBuildState): this;
  57661. }
  57662. }
  57663. declare module BABYLON {
  57664. /**
  57665. * Block used to rotate a 2d vector by a given angle
  57666. */
  57667. export class Rotate2dBlock extends NodeMaterialBlock {
  57668. /**
  57669. * Creates a new Rotate2dBlock
  57670. * @param name defines the block name
  57671. */
  57672. constructor(name: string);
  57673. /**
  57674. * Gets the current class name
  57675. * @returns the class name
  57676. */
  57677. getClassName(): string;
  57678. /**
  57679. * Gets the input vector
  57680. */
  57681. readonly input: NodeMaterialConnectionPoint;
  57682. /**
  57683. * Gets the input angle
  57684. */
  57685. readonly angle: NodeMaterialConnectionPoint;
  57686. /**
  57687. * Gets the output component
  57688. */
  57689. readonly output: NodeMaterialConnectionPoint;
  57690. autoConfigure(material: NodeMaterial): void;
  57691. protected _buildBlock(state: NodeMaterialBuildState): this;
  57692. }
  57693. }
  57694. declare module BABYLON {
  57695. /**
  57696. * Block used to get the reflected vector from a direction and a normal
  57697. */
  57698. export class ReflectBlock extends NodeMaterialBlock {
  57699. /**
  57700. * Creates a new ReflectBlock
  57701. * @param name defines the block name
  57702. */
  57703. constructor(name: string);
  57704. /**
  57705. * Gets the current class name
  57706. * @returns the class name
  57707. */
  57708. getClassName(): string;
  57709. /**
  57710. * Gets the incident component
  57711. */
  57712. readonly incident: NodeMaterialConnectionPoint;
  57713. /**
  57714. * Gets the normal component
  57715. */
  57716. readonly normal: NodeMaterialConnectionPoint;
  57717. /**
  57718. * Gets the output component
  57719. */
  57720. readonly output: NodeMaterialConnectionPoint;
  57721. protected _buildBlock(state: NodeMaterialBuildState): this;
  57722. }
  57723. }
  57724. declare module BABYLON {
  57725. /**
  57726. * Block used to get the refracted vector from a direction and a normal
  57727. */
  57728. export class RefractBlock extends NodeMaterialBlock {
  57729. /**
  57730. * Creates a new RefractBlock
  57731. * @param name defines the block name
  57732. */
  57733. constructor(name: string);
  57734. /**
  57735. * Gets the current class name
  57736. * @returns the class name
  57737. */
  57738. getClassName(): string;
  57739. /**
  57740. * Gets the incident component
  57741. */
  57742. readonly incident: NodeMaterialConnectionPoint;
  57743. /**
  57744. * Gets the normal component
  57745. */
  57746. readonly normal: NodeMaterialConnectionPoint;
  57747. /**
  57748. * Gets the index of refraction component
  57749. */
  57750. readonly ior: NodeMaterialConnectionPoint;
  57751. /**
  57752. * Gets the output component
  57753. */
  57754. readonly output: NodeMaterialConnectionPoint;
  57755. protected _buildBlock(state: NodeMaterialBuildState): this;
  57756. }
  57757. }
  57758. declare module BABYLON {
  57759. /**
  57760. * Block used to desaturate a color
  57761. */
  57762. export class DesaturateBlock extends NodeMaterialBlock {
  57763. /**
  57764. * Creates a new DesaturateBlock
  57765. * @param name defines the block name
  57766. */
  57767. constructor(name: string);
  57768. /**
  57769. * Gets the current class name
  57770. * @returns the class name
  57771. */
  57772. getClassName(): string;
  57773. /**
  57774. * Gets the color operand input component
  57775. */
  57776. readonly color: NodeMaterialConnectionPoint;
  57777. /**
  57778. * Gets the level operand input component
  57779. */
  57780. readonly level: NodeMaterialConnectionPoint;
  57781. /**
  57782. * Gets the output component
  57783. */
  57784. readonly output: NodeMaterialConnectionPoint;
  57785. protected _buildBlock(state: NodeMaterialBuildState): this;
  57786. }
  57787. }
  57788. declare module BABYLON {
  57789. /**
  57790. * Effect Render Options
  57791. */
  57792. export interface IEffectRendererOptions {
  57793. /**
  57794. * Defines the vertices positions.
  57795. */
  57796. positions?: number[];
  57797. /**
  57798. * Defines the indices.
  57799. */
  57800. indices?: number[];
  57801. }
  57802. /**
  57803. * Helper class to render one or more effects
  57804. */
  57805. export class EffectRenderer {
  57806. private engine;
  57807. private static _DefaultOptions;
  57808. private _vertexBuffers;
  57809. private _indexBuffer;
  57810. private _ringBufferIndex;
  57811. private _ringScreenBuffer;
  57812. private _fullscreenViewport;
  57813. private _getNextFrameBuffer;
  57814. /**
  57815. * Creates an effect renderer
  57816. * @param engine the engine to use for rendering
  57817. * @param options defines the options of the effect renderer
  57818. */
  57819. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  57820. /**
  57821. * Sets the current viewport in normalized coordinates 0-1
  57822. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57823. */
  57824. setViewport(viewport?: Viewport): void;
  57825. /**
  57826. * Binds the embedded attributes buffer to the effect.
  57827. * @param effect Defines the effect to bind the attributes for
  57828. */
  57829. bindBuffers(effect: Effect): void;
  57830. /**
  57831. * Sets the current effect wrapper to use during draw.
  57832. * The effect needs to be ready before calling this api.
  57833. * This also sets the default full screen position attribute.
  57834. * @param effectWrapper Defines the effect to draw with
  57835. */
  57836. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57837. /**
  57838. * Draws a full screen quad.
  57839. */
  57840. draw(): void;
  57841. /**
  57842. * renders one or more effects to a specified texture
  57843. * @param effectWrappers list of effects to renderer
  57844. * @param outputTexture texture to draw to, if null it will render to the screen
  57845. */
  57846. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57847. /**
  57848. * Disposes of the effect renderer
  57849. */
  57850. dispose(): void;
  57851. }
  57852. /**
  57853. * Options to create an EffectWrapper
  57854. */
  57855. interface EffectWrapperCreationOptions {
  57856. /**
  57857. * Engine to use to create the effect
  57858. */
  57859. engine: ThinEngine;
  57860. /**
  57861. * Fragment shader for the effect
  57862. */
  57863. fragmentShader: string;
  57864. /**
  57865. * Vertex shader for the effect
  57866. */
  57867. vertexShader?: string;
  57868. /**
  57869. * Attributes to use in the shader
  57870. */
  57871. attributeNames?: Array<string>;
  57872. /**
  57873. * Uniforms to use in the shader
  57874. */
  57875. uniformNames?: Array<string>;
  57876. /**
  57877. * Texture sampler names to use in the shader
  57878. */
  57879. samplerNames?: Array<string>;
  57880. /**
  57881. * The friendly name of the effect displayed in Spector.
  57882. */
  57883. name?: string;
  57884. }
  57885. /**
  57886. * Wraps an effect to be used for rendering
  57887. */
  57888. export class EffectWrapper {
  57889. /**
  57890. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57891. */
  57892. onApplyObservable: Observable<{}>;
  57893. /**
  57894. * The underlying effect
  57895. */
  57896. effect: Effect;
  57897. /**
  57898. * Creates an effect to be renderer
  57899. * @param creationOptions options to create the effect
  57900. */
  57901. constructor(creationOptions: EffectWrapperCreationOptions);
  57902. /**
  57903. * Disposes of the effect wrapper
  57904. */
  57905. dispose(): void;
  57906. }
  57907. }
  57908. declare module BABYLON {
  57909. /**
  57910. * Helper class to push actions to a pool of workers.
  57911. */
  57912. export class WorkerPool implements IDisposable {
  57913. private _workerInfos;
  57914. private _pendingActions;
  57915. /**
  57916. * Constructor
  57917. * @param workers Array of workers to use for actions
  57918. */
  57919. constructor(workers: Array<Worker>);
  57920. /**
  57921. * Terminates all workers and clears any pending actions.
  57922. */
  57923. dispose(): void;
  57924. /**
  57925. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57926. * pended until a worker has completed its action.
  57927. * @param action The action to perform. Call onComplete when the action is complete.
  57928. */
  57929. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57930. private _execute;
  57931. }
  57932. }
  57933. declare module BABYLON {
  57934. /**
  57935. * Configuration for Draco compression
  57936. */
  57937. export interface IDracoCompressionConfiguration {
  57938. /**
  57939. * Configuration for the decoder.
  57940. */
  57941. decoder: {
  57942. /**
  57943. * The url to the WebAssembly module.
  57944. */
  57945. wasmUrl?: string;
  57946. /**
  57947. * The url to the WebAssembly binary.
  57948. */
  57949. wasmBinaryUrl?: string;
  57950. /**
  57951. * The url to the fallback JavaScript module.
  57952. */
  57953. fallbackUrl?: string;
  57954. };
  57955. }
  57956. /**
  57957. * Draco compression (https://google.github.io/draco/)
  57958. *
  57959. * This class wraps the Draco module.
  57960. *
  57961. * **Encoder**
  57962. *
  57963. * The encoder is not currently implemented.
  57964. *
  57965. * **Decoder**
  57966. *
  57967. * 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.
  57968. *
  57969. * To update the configuration, use the following code:
  57970. * ```javascript
  57971. * DracoCompression.Configuration = {
  57972. * decoder: {
  57973. * wasmUrl: "<url to the WebAssembly library>",
  57974. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57975. * fallbackUrl: "<url to the fallback JavaScript library>",
  57976. * }
  57977. * };
  57978. * ```
  57979. *
  57980. * 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.
  57981. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57982. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57983. *
  57984. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57985. * ```javascript
  57986. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57987. * ```
  57988. *
  57989. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57990. */
  57991. export class DracoCompression implements IDisposable {
  57992. private _workerPoolPromise?;
  57993. private _decoderModulePromise?;
  57994. /**
  57995. * The configuration. Defaults to the following urls:
  57996. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57997. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57998. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57999. */
  58000. static Configuration: IDracoCompressionConfiguration;
  58001. /**
  58002. * Returns true if the decoder configuration is available.
  58003. */
  58004. static readonly DecoderAvailable: boolean;
  58005. /**
  58006. * Default number of workers to create when creating the draco compression object.
  58007. */
  58008. static DefaultNumWorkers: number;
  58009. private static GetDefaultNumWorkers;
  58010. private static _Default;
  58011. /**
  58012. * Default instance for the draco compression object.
  58013. */
  58014. static readonly Default: DracoCompression;
  58015. /**
  58016. * Constructor
  58017. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58018. */
  58019. constructor(numWorkers?: number);
  58020. /**
  58021. * Stop all async operations and release resources.
  58022. */
  58023. dispose(): void;
  58024. /**
  58025. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58026. * @returns a promise that resolves when ready
  58027. */
  58028. whenReadyAsync(): Promise<void>;
  58029. /**
  58030. * Decode Draco compressed mesh data to vertex data.
  58031. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58032. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58033. * @returns A promise that resolves with the decoded vertex data
  58034. */
  58035. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58036. [kind: string]: number;
  58037. }): Promise<VertexData>;
  58038. }
  58039. }
  58040. declare module BABYLON {
  58041. /**
  58042. * Class for building Constructive Solid Geometry
  58043. */
  58044. export class CSG {
  58045. private polygons;
  58046. /**
  58047. * The world matrix
  58048. */
  58049. matrix: Matrix;
  58050. /**
  58051. * Stores the position
  58052. */
  58053. position: Vector3;
  58054. /**
  58055. * Stores the rotation
  58056. */
  58057. rotation: Vector3;
  58058. /**
  58059. * Stores the rotation quaternion
  58060. */
  58061. rotationQuaternion: Nullable<Quaternion>;
  58062. /**
  58063. * Stores the scaling vector
  58064. */
  58065. scaling: Vector3;
  58066. /**
  58067. * Convert the Mesh to CSG
  58068. * @param mesh The Mesh to convert to CSG
  58069. * @returns A new CSG from the Mesh
  58070. */
  58071. static FromMesh(mesh: Mesh): CSG;
  58072. /**
  58073. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58074. * @param polygons Polygons used to construct a CSG solid
  58075. */
  58076. private static FromPolygons;
  58077. /**
  58078. * Clones, or makes a deep copy, of the CSG
  58079. * @returns A new CSG
  58080. */
  58081. clone(): CSG;
  58082. /**
  58083. * Unions this CSG with another CSG
  58084. * @param csg The CSG to union against this CSG
  58085. * @returns The unioned CSG
  58086. */
  58087. union(csg: CSG): CSG;
  58088. /**
  58089. * Unions this CSG with another CSG in place
  58090. * @param csg The CSG to union against this CSG
  58091. */
  58092. unionInPlace(csg: CSG): void;
  58093. /**
  58094. * Subtracts this CSG with another CSG
  58095. * @param csg The CSG to subtract against this CSG
  58096. * @returns A new CSG
  58097. */
  58098. subtract(csg: CSG): CSG;
  58099. /**
  58100. * Subtracts this CSG with another CSG in place
  58101. * @param csg The CSG to subtact against this CSG
  58102. */
  58103. subtractInPlace(csg: CSG): void;
  58104. /**
  58105. * Intersect this CSG with another CSG
  58106. * @param csg The CSG to intersect against this CSG
  58107. * @returns A new CSG
  58108. */
  58109. intersect(csg: CSG): CSG;
  58110. /**
  58111. * Intersects this CSG with another CSG in place
  58112. * @param csg The CSG to intersect against this CSG
  58113. */
  58114. intersectInPlace(csg: CSG): void;
  58115. /**
  58116. * Return a new CSG solid with solid and empty space switched. This solid is
  58117. * not modified.
  58118. * @returns A new CSG solid with solid and empty space switched
  58119. */
  58120. inverse(): CSG;
  58121. /**
  58122. * Inverses the CSG in place
  58123. */
  58124. inverseInPlace(): void;
  58125. /**
  58126. * This is used to keep meshes transformations so they can be restored
  58127. * when we build back a Babylon Mesh
  58128. * NB : All CSG operations are performed in world coordinates
  58129. * @param csg The CSG to copy the transform attributes from
  58130. * @returns This CSG
  58131. */
  58132. copyTransformAttributes(csg: CSG): CSG;
  58133. /**
  58134. * Build Raw mesh from CSG
  58135. * Coordinates here are in world space
  58136. * @param name The name of the mesh geometry
  58137. * @param scene The Scene
  58138. * @param keepSubMeshes Specifies if the submeshes should be kept
  58139. * @returns A new Mesh
  58140. */
  58141. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58142. /**
  58143. * Build Mesh from CSG taking material and transforms into account
  58144. * @param name The name of the Mesh
  58145. * @param material The material of the Mesh
  58146. * @param scene The Scene
  58147. * @param keepSubMeshes Specifies if submeshes should be kept
  58148. * @returns The new Mesh
  58149. */
  58150. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58151. }
  58152. }
  58153. declare module BABYLON {
  58154. /**
  58155. * Class used to create a trail following a mesh
  58156. */
  58157. export class TrailMesh extends Mesh {
  58158. private _generator;
  58159. private _autoStart;
  58160. private _running;
  58161. private _diameter;
  58162. private _length;
  58163. private _sectionPolygonPointsCount;
  58164. private _sectionVectors;
  58165. private _sectionNormalVectors;
  58166. private _beforeRenderObserver;
  58167. /**
  58168. * @constructor
  58169. * @param name The value used by scene.getMeshByName() to do a lookup.
  58170. * @param generator The mesh to generate a trail.
  58171. * @param scene The scene to add this mesh to.
  58172. * @param diameter Diameter of trailing mesh. Default is 1.
  58173. * @param length Length of trailing mesh. Default is 60.
  58174. * @param autoStart Automatically start trailing mesh. Default true.
  58175. */
  58176. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58177. /**
  58178. * "TrailMesh"
  58179. * @returns "TrailMesh"
  58180. */
  58181. getClassName(): string;
  58182. private _createMesh;
  58183. /**
  58184. * Start trailing mesh.
  58185. */
  58186. start(): void;
  58187. /**
  58188. * Stop trailing mesh.
  58189. */
  58190. stop(): void;
  58191. /**
  58192. * Update trailing mesh geometry.
  58193. */
  58194. update(): void;
  58195. /**
  58196. * Returns a new TrailMesh object.
  58197. * @param name is a string, the name given to the new mesh
  58198. * @param newGenerator use new generator object for cloned trail mesh
  58199. * @returns a new mesh
  58200. */
  58201. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58202. /**
  58203. * Serializes this trail mesh
  58204. * @param serializationObject object to write serialization to
  58205. */
  58206. serialize(serializationObject: any): void;
  58207. /**
  58208. * Parses a serialized trail mesh
  58209. * @param parsedMesh the serialized mesh
  58210. * @param scene the scene to create the trail mesh in
  58211. * @returns the created trail mesh
  58212. */
  58213. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58214. }
  58215. }
  58216. declare module BABYLON {
  58217. /**
  58218. * Class containing static functions to help procedurally build meshes
  58219. */
  58220. export class TiledBoxBuilder {
  58221. /**
  58222. * Creates a box mesh
  58223. * 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)
  58224. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58226. * * 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
  58227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58228. * @param name defines the name of the mesh
  58229. * @param options defines the options used to create the mesh
  58230. * @param scene defines the hosting scene
  58231. * @returns the box mesh
  58232. */
  58233. static CreateTiledBox(name: string, options: {
  58234. pattern?: number;
  58235. width?: number;
  58236. height?: number;
  58237. depth?: number;
  58238. tileSize?: number;
  58239. tileWidth?: number;
  58240. tileHeight?: number;
  58241. alignHorizontal?: number;
  58242. alignVertical?: number;
  58243. faceUV?: Vector4[];
  58244. faceColors?: Color4[];
  58245. sideOrientation?: number;
  58246. updatable?: boolean;
  58247. }, scene?: Nullable<Scene>): Mesh;
  58248. }
  58249. }
  58250. declare module BABYLON {
  58251. /**
  58252. * Class containing static functions to help procedurally build meshes
  58253. */
  58254. export class TorusKnotBuilder {
  58255. /**
  58256. * Creates a torus knot mesh
  58257. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58258. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58259. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58260. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58262. * * 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
  58263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58264. * @param name defines the name of the mesh
  58265. * @param options defines the options used to create the mesh
  58266. * @param scene defines the hosting scene
  58267. * @returns the torus knot mesh
  58268. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58269. */
  58270. static CreateTorusKnot(name: string, options: {
  58271. radius?: number;
  58272. tube?: number;
  58273. radialSegments?: number;
  58274. tubularSegments?: number;
  58275. p?: number;
  58276. q?: number;
  58277. updatable?: boolean;
  58278. sideOrientation?: number;
  58279. frontUVs?: Vector4;
  58280. backUVs?: Vector4;
  58281. }, scene: any): Mesh;
  58282. }
  58283. }
  58284. declare module BABYLON {
  58285. /**
  58286. * Polygon
  58287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58288. */
  58289. export class Polygon {
  58290. /**
  58291. * Creates a rectangle
  58292. * @param xmin bottom X coord
  58293. * @param ymin bottom Y coord
  58294. * @param xmax top X coord
  58295. * @param ymax top Y coord
  58296. * @returns points that make the resulting rectation
  58297. */
  58298. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58299. /**
  58300. * Creates a circle
  58301. * @param radius radius of circle
  58302. * @param cx scale in x
  58303. * @param cy scale in y
  58304. * @param numberOfSides number of sides that make up the circle
  58305. * @returns points that make the resulting circle
  58306. */
  58307. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58308. /**
  58309. * Creates a polygon from input string
  58310. * @param input Input polygon data
  58311. * @returns the parsed points
  58312. */
  58313. static Parse(input: string): Vector2[];
  58314. /**
  58315. * Starts building a polygon from x and y coordinates
  58316. * @param x x coordinate
  58317. * @param y y coordinate
  58318. * @returns the started path2
  58319. */
  58320. static StartingAt(x: number, y: number): Path2;
  58321. }
  58322. /**
  58323. * Builds a polygon
  58324. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58325. */
  58326. export class PolygonMeshBuilder {
  58327. private _points;
  58328. private _outlinepoints;
  58329. private _holes;
  58330. private _name;
  58331. private _scene;
  58332. private _epoints;
  58333. private _eholes;
  58334. private _addToepoint;
  58335. /**
  58336. * Babylon reference to the earcut plugin.
  58337. */
  58338. bjsEarcut: any;
  58339. /**
  58340. * Creates a PolygonMeshBuilder
  58341. * @param name name of the builder
  58342. * @param contours Path of the polygon
  58343. * @param scene scene to add to when creating the mesh
  58344. * @param earcutInjection can be used to inject your own earcut reference
  58345. */
  58346. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58347. /**
  58348. * Adds a whole within the polygon
  58349. * @param hole Array of points defining the hole
  58350. * @returns this
  58351. */
  58352. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58353. /**
  58354. * Creates the polygon
  58355. * @param updatable If the mesh should be updatable
  58356. * @param depth The depth of the mesh created
  58357. * @returns the created mesh
  58358. */
  58359. build(updatable?: boolean, depth?: number): Mesh;
  58360. /**
  58361. * Creates the polygon
  58362. * @param depth The depth of the mesh created
  58363. * @returns the created VertexData
  58364. */
  58365. buildVertexData(depth?: number): VertexData;
  58366. /**
  58367. * Adds a side to the polygon
  58368. * @param positions points that make the polygon
  58369. * @param normals normals of the polygon
  58370. * @param uvs uvs of the polygon
  58371. * @param indices indices of the polygon
  58372. * @param bounds bounds of the polygon
  58373. * @param points points of the polygon
  58374. * @param depth depth of the polygon
  58375. * @param flip flip of the polygon
  58376. */
  58377. private addSide;
  58378. }
  58379. }
  58380. declare module BABYLON {
  58381. /**
  58382. * Class containing static functions to help procedurally build meshes
  58383. */
  58384. export class PolygonBuilder {
  58385. /**
  58386. * Creates a polygon mesh
  58387. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58388. * * 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
  58389. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58391. * * 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)
  58392. * * Remember you can only change the shape positions, not their number when updating a polygon
  58393. * @param name defines the name of the mesh
  58394. * @param options defines the options used to create the mesh
  58395. * @param scene defines the hosting scene
  58396. * @param earcutInjection can be used to inject your own earcut reference
  58397. * @returns the polygon mesh
  58398. */
  58399. static CreatePolygon(name: string, options: {
  58400. shape: Vector3[];
  58401. holes?: Vector3[][];
  58402. depth?: number;
  58403. faceUV?: Vector4[];
  58404. faceColors?: Color4[];
  58405. updatable?: boolean;
  58406. sideOrientation?: number;
  58407. frontUVs?: Vector4;
  58408. backUVs?: Vector4;
  58409. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58410. /**
  58411. * Creates an extruded polygon mesh, with depth in the Y direction.
  58412. * * 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)
  58413. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58414. * @param name defines the name of the mesh
  58415. * @param options defines the options used to create the mesh
  58416. * @param scene defines the hosting scene
  58417. * @param earcutInjection can be used to inject your own earcut reference
  58418. * @returns the polygon mesh
  58419. */
  58420. static ExtrudePolygon(name: string, options: {
  58421. shape: Vector3[];
  58422. holes?: Vector3[][];
  58423. depth?: number;
  58424. faceUV?: Vector4[];
  58425. faceColors?: Color4[];
  58426. updatable?: boolean;
  58427. sideOrientation?: number;
  58428. frontUVs?: Vector4;
  58429. backUVs?: Vector4;
  58430. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58431. }
  58432. }
  58433. declare module BABYLON {
  58434. /**
  58435. * Class containing static functions to help procedurally build meshes
  58436. */
  58437. export class LatheBuilder {
  58438. /**
  58439. * Creates lathe mesh.
  58440. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58441. * * 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
  58442. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58443. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58444. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58445. * * 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
  58446. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58447. * * 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
  58448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58449. * * 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
  58450. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58452. * @param name defines the name of the mesh
  58453. * @param options defines the options used to create the mesh
  58454. * @param scene defines the hosting scene
  58455. * @returns the lathe mesh
  58456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58457. */
  58458. static CreateLathe(name: string, options: {
  58459. shape: Vector3[];
  58460. radius?: number;
  58461. tessellation?: number;
  58462. clip?: number;
  58463. arc?: number;
  58464. closed?: boolean;
  58465. updatable?: boolean;
  58466. sideOrientation?: number;
  58467. frontUVs?: Vector4;
  58468. backUVs?: Vector4;
  58469. cap?: number;
  58470. invertUV?: boolean;
  58471. }, scene?: Nullable<Scene>): Mesh;
  58472. }
  58473. }
  58474. declare module BABYLON {
  58475. /**
  58476. * Class containing static functions to help procedurally build meshes
  58477. */
  58478. export class TiledPlaneBuilder {
  58479. /**
  58480. * Creates a tiled plane mesh
  58481. * * The parameter `pattern` will, depending on value, do nothing or
  58482. * * * flip (reflect about central vertical) alternate tiles across and up
  58483. * * * flip every tile on alternate rows
  58484. * * * rotate (180 degs) alternate tiles across and up
  58485. * * * rotate every tile on alternate rows
  58486. * * * flip and rotate alternate tiles across and up
  58487. * * * flip and rotate every tile on alternate rows
  58488. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58489. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58490. * * 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
  58491. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58492. * * 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)
  58493. * * 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)
  58494. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58495. * @param name defines the name of the mesh
  58496. * @param options defines the options used to create the mesh
  58497. * @param scene defines the hosting scene
  58498. * @returns the box mesh
  58499. */
  58500. static CreateTiledPlane(name: string, options: {
  58501. pattern?: number;
  58502. tileSize?: number;
  58503. tileWidth?: number;
  58504. tileHeight?: number;
  58505. size?: number;
  58506. width?: number;
  58507. height?: number;
  58508. alignHorizontal?: number;
  58509. alignVertical?: number;
  58510. sideOrientation?: number;
  58511. frontUVs?: Vector4;
  58512. backUVs?: Vector4;
  58513. updatable?: boolean;
  58514. }, scene?: Nullable<Scene>): Mesh;
  58515. }
  58516. }
  58517. declare module BABYLON {
  58518. /**
  58519. * Class containing static functions to help procedurally build meshes
  58520. */
  58521. export class TubeBuilder {
  58522. /**
  58523. * Creates a tube mesh.
  58524. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58525. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58526. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58527. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58528. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58529. * * 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)
  58530. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58531. * * 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
  58532. * * 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
  58533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58534. * * 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
  58535. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58537. * @param name defines the name of the mesh
  58538. * @param options defines the options used to create the mesh
  58539. * @param scene defines the hosting scene
  58540. * @returns the tube mesh
  58541. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58542. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58543. */
  58544. static CreateTube(name: string, options: {
  58545. path: Vector3[];
  58546. radius?: number;
  58547. tessellation?: number;
  58548. radiusFunction?: {
  58549. (i: number, distance: number): number;
  58550. };
  58551. cap?: number;
  58552. arc?: number;
  58553. updatable?: boolean;
  58554. sideOrientation?: number;
  58555. frontUVs?: Vector4;
  58556. backUVs?: Vector4;
  58557. instance?: Mesh;
  58558. invertUV?: boolean;
  58559. }, scene?: Nullable<Scene>): Mesh;
  58560. }
  58561. }
  58562. declare module BABYLON {
  58563. /**
  58564. * Class containing static functions to help procedurally build meshes
  58565. */
  58566. export class IcoSphereBuilder {
  58567. /**
  58568. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58569. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58570. * * 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`)
  58571. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58572. * * 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
  58573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58574. * * 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
  58575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58576. * @param name defines the name of the mesh
  58577. * @param options defines the options used to create the mesh
  58578. * @param scene defines the hosting scene
  58579. * @returns the icosahedron mesh
  58580. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58581. */
  58582. static CreateIcoSphere(name: string, options: {
  58583. radius?: number;
  58584. radiusX?: number;
  58585. radiusY?: number;
  58586. radiusZ?: number;
  58587. flat?: boolean;
  58588. subdivisions?: number;
  58589. sideOrientation?: number;
  58590. frontUVs?: Vector4;
  58591. backUVs?: Vector4;
  58592. updatable?: boolean;
  58593. }, scene?: Nullable<Scene>): Mesh;
  58594. }
  58595. }
  58596. declare module BABYLON {
  58597. /**
  58598. * Class containing static functions to help procedurally build meshes
  58599. */
  58600. export class DecalBuilder {
  58601. /**
  58602. * Creates a decal mesh.
  58603. * 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
  58604. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58605. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58606. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58607. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58608. * @param name defines the name of the mesh
  58609. * @param sourceMesh defines the mesh where the decal must be applied
  58610. * @param options defines the options used to create the mesh
  58611. * @param scene defines the hosting scene
  58612. * @returns the decal mesh
  58613. * @see https://doc.babylonjs.com/how_to/decals
  58614. */
  58615. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58616. position?: Vector3;
  58617. normal?: Vector3;
  58618. size?: Vector3;
  58619. angle?: number;
  58620. }): Mesh;
  58621. }
  58622. }
  58623. declare module BABYLON {
  58624. /**
  58625. * Class containing static functions to help procedurally build meshes
  58626. */
  58627. export class MeshBuilder {
  58628. /**
  58629. * Creates a box mesh
  58630. * * The parameter `size` sets the size (float) of each box side (default 1)
  58631. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58632. * * 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)
  58633. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58635. * * 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
  58636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58637. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58638. * @param name defines the name of the mesh
  58639. * @param options defines the options used to create the mesh
  58640. * @param scene defines the hosting scene
  58641. * @returns the box mesh
  58642. */
  58643. static CreateBox(name: string, options: {
  58644. size?: number;
  58645. width?: number;
  58646. height?: number;
  58647. depth?: number;
  58648. faceUV?: Vector4[];
  58649. faceColors?: Color4[];
  58650. sideOrientation?: number;
  58651. frontUVs?: Vector4;
  58652. backUVs?: Vector4;
  58653. updatable?: boolean;
  58654. }, scene?: Nullable<Scene>): Mesh;
  58655. /**
  58656. * Creates a tiled box mesh
  58657. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58659. * @param name defines the name of the mesh
  58660. * @param options defines the options used to create the mesh
  58661. * @param scene defines the hosting scene
  58662. * @returns the tiled box mesh
  58663. */
  58664. static CreateTiledBox(name: string, options: {
  58665. pattern?: number;
  58666. size?: number;
  58667. width?: number;
  58668. height?: number;
  58669. depth: number;
  58670. tileSize?: number;
  58671. tileWidth?: number;
  58672. tileHeight?: number;
  58673. faceUV?: Vector4[];
  58674. faceColors?: Color4[];
  58675. alignHorizontal?: number;
  58676. alignVertical?: number;
  58677. sideOrientation?: number;
  58678. updatable?: boolean;
  58679. }, scene?: Nullable<Scene>): Mesh;
  58680. /**
  58681. * Creates a sphere mesh
  58682. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58683. * * 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`)
  58684. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58685. * * 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
  58686. * * 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)
  58687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58688. * * 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
  58689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58690. * @param name defines the name of the mesh
  58691. * @param options defines the options used to create the mesh
  58692. * @param scene defines the hosting scene
  58693. * @returns the sphere mesh
  58694. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58695. */
  58696. static CreateSphere(name: string, options: {
  58697. segments?: number;
  58698. diameter?: number;
  58699. diameterX?: number;
  58700. diameterY?: number;
  58701. diameterZ?: number;
  58702. arc?: number;
  58703. slice?: number;
  58704. sideOrientation?: number;
  58705. frontUVs?: Vector4;
  58706. backUVs?: Vector4;
  58707. updatable?: boolean;
  58708. }, scene?: Nullable<Scene>): Mesh;
  58709. /**
  58710. * Creates a plane polygonal mesh. By default, this is a disc
  58711. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58712. * * 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
  58713. * * 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
  58714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58715. * * 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
  58716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58717. * @param name defines the name of the mesh
  58718. * @param options defines the options used to create the mesh
  58719. * @param scene defines the hosting scene
  58720. * @returns the plane polygonal mesh
  58721. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58722. */
  58723. static CreateDisc(name: string, options: {
  58724. radius?: number;
  58725. tessellation?: number;
  58726. arc?: number;
  58727. updatable?: boolean;
  58728. sideOrientation?: number;
  58729. frontUVs?: Vector4;
  58730. backUVs?: Vector4;
  58731. }, scene?: Nullable<Scene>): Mesh;
  58732. /**
  58733. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58734. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58735. * * 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`)
  58736. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58737. * * 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
  58738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58739. * * 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
  58740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58741. * @param name defines the name of the mesh
  58742. * @param options defines the options used to create the mesh
  58743. * @param scene defines the hosting scene
  58744. * @returns the icosahedron mesh
  58745. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58746. */
  58747. static CreateIcoSphere(name: string, options: {
  58748. radius?: number;
  58749. radiusX?: number;
  58750. radiusY?: number;
  58751. radiusZ?: number;
  58752. flat?: boolean;
  58753. subdivisions?: number;
  58754. sideOrientation?: number;
  58755. frontUVs?: Vector4;
  58756. backUVs?: Vector4;
  58757. updatable?: boolean;
  58758. }, scene?: Nullable<Scene>): Mesh;
  58759. /**
  58760. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58761. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58762. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58763. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58764. * * 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
  58765. * * 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
  58766. * * 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
  58767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58768. * * 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
  58769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58770. * * 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
  58771. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58772. * * 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
  58773. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58775. * @param name defines the name of the mesh
  58776. * @param options defines the options used to create the mesh
  58777. * @param scene defines the hosting scene
  58778. * @returns the ribbon mesh
  58779. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58780. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58781. */
  58782. static CreateRibbon(name: string, options: {
  58783. pathArray: Vector3[][];
  58784. closeArray?: boolean;
  58785. closePath?: boolean;
  58786. offset?: number;
  58787. updatable?: boolean;
  58788. sideOrientation?: number;
  58789. frontUVs?: Vector4;
  58790. backUVs?: Vector4;
  58791. instance?: Mesh;
  58792. invertUV?: boolean;
  58793. uvs?: Vector2[];
  58794. colors?: Color4[];
  58795. }, scene?: Nullable<Scene>): Mesh;
  58796. /**
  58797. * Creates a cylinder or a cone mesh
  58798. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58799. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58800. * * 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.
  58801. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58802. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58803. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58804. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58805. * * 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).
  58806. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58807. * * 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).
  58808. * * 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
  58809. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58810. * * 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
  58811. * * 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.
  58812. * * If `enclose` is false, a ring surface is one element.
  58813. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58814. * * 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
  58815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58816. * * 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
  58817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58818. * @param name defines the name of the mesh
  58819. * @param options defines the options used to create the mesh
  58820. * @param scene defines the hosting scene
  58821. * @returns the cylinder mesh
  58822. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58823. */
  58824. static CreateCylinder(name: string, options: {
  58825. height?: number;
  58826. diameterTop?: number;
  58827. diameterBottom?: number;
  58828. diameter?: number;
  58829. tessellation?: number;
  58830. subdivisions?: number;
  58831. arc?: number;
  58832. faceColors?: Color4[];
  58833. faceUV?: Vector4[];
  58834. updatable?: boolean;
  58835. hasRings?: boolean;
  58836. enclose?: boolean;
  58837. cap?: number;
  58838. sideOrientation?: number;
  58839. frontUVs?: Vector4;
  58840. backUVs?: Vector4;
  58841. }, scene?: Nullable<Scene>): Mesh;
  58842. /**
  58843. * Creates a torus mesh
  58844. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58845. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58846. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58848. * * 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
  58849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58850. * @param name defines the name of the mesh
  58851. * @param options defines the options used to create the mesh
  58852. * @param scene defines the hosting scene
  58853. * @returns the torus mesh
  58854. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58855. */
  58856. static CreateTorus(name: string, options: {
  58857. diameter?: number;
  58858. thickness?: number;
  58859. tessellation?: number;
  58860. updatable?: boolean;
  58861. sideOrientation?: number;
  58862. frontUVs?: Vector4;
  58863. backUVs?: Vector4;
  58864. }, scene?: Nullable<Scene>): Mesh;
  58865. /**
  58866. * Creates a torus knot mesh
  58867. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58868. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58869. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58870. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58872. * * 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
  58873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58874. * @param name defines the name of the mesh
  58875. * @param options defines the options used to create the mesh
  58876. * @param scene defines the hosting scene
  58877. * @returns the torus knot mesh
  58878. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58879. */
  58880. static CreateTorusKnot(name: string, options: {
  58881. radius?: number;
  58882. tube?: number;
  58883. radialSegments?: number;
  58884. tubularSegments?: number;
  58885. p?: number;
  58886. q?: number;
  58887. updatable?: boolean;
  58888. sideOrientation?: number;
  58889. frontUVs?: Vector4;
  58890. backUVs?: Vector4;
  58891. }, scene?: Nullable<Scene>): Mesh;
  58892. /**
  58893. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58894. * * 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
  58895. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58896. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58897. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58898. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58899. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58900. * * 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
  58901. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58904. * @param name defines the name of the new line system
  58905. * @param options defines the options used to create the line system
  58906. * @param scene defines the hosting scene
  58907. * @returns a new line system mesh
  58908. */
  58909. static CreateLineSystem(name: string, options: {
  58910. lines: Vector3[][];
  58911. updatable?: boolean;
  58912. instance?: Nullable<LinesMesh>;
  58913. colors?: Nullable<Color4[][]>;
  58914. useVertexAlpha?: boolean;
  58915. }, scene: Nullable<Scene>): LinesMesh;
  58916. /**
  58917. * Creates a line mesh
  58918. * 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
  58919. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58920. * * The parameter `points` is an array successive Vector3
  58921. * * 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
  58922. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58923. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58924. * * When updating an instance, remember that only point positions can change, not the number of points
  58925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58927. * @param name defines the name of the new line system
  58928. * @param options defines the options used to create the line system
  58929. * @param scene defines the hosting scene
  58930. * @returns a new line mesh
  58931. */
  58932. static CreateLines(name: string, options: {
  58933. points: Vector3[];
  58934. updatable?: boolean;
  58935. instance?: Nullable<LinesMesh>;
  58936. colors?: Color4[];
  58937. useVertexAlpha?: boolean;
  58938. }, scene?: Nullable<Scene>): LinesMesh;
  58939. /**
  58940. * Creates a dashed line mesh
  58941. * * 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
  58942. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58943. * * The parameter `points` is an array successive Vector3
  58944. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58945. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58946. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58947. * * 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
  58948. * * When updating an instance, remember that only point positions can change, not the number of points
  58949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58950. * @param name defines the name of the mesh
  58951. * @param options defines the options used to create the mesh
  58952. * @param scene defines the hosting scene
  58953. * @returns the dashed line mesh
  58954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58955. */
  58956. static CreateDashedLines(name: string, options: {
  58957. points: Vector3[];
  58958. dashSize?: number;
  58959. gapSize?: number;
  58960. dashNb?: number;
  58961. updatable?: boolean;
  58962. instance?: LinesMesh;
  58963. }, scene?: Nullable<Scene>): LinesMesh;
  58964. /**
  58965. * 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.
  58966. * * 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.
  58967. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58968. * * 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.
  58969. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58970. * * 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
  58971. * * 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
  58972. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58974. * * 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
  58975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58977. * @param name defines the name of the mesh
  58978. * @param options defines the options used to create the mesh
  58979. * @param scene defines the hosting scene
  58980. * @returns the extruded shape mesh
  58981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58983. */
  58984. static ExtrudeShape(name: string, options: {
  58985. shape: Vector3[];
  58986. path: Vector3[];
  58987. scale?: number;
  58988. rotation?: number;
  58989. cap?: number;
  58990. updatable?: boolean;
  58991. sideOrientation?: number;
  58992. frontUVs?: Vector4;
  58993. backUVs?: Vector4;
  58994. instance?: Mesh;
  58995. invertUV?: boolean;
  58996. }, scene?: Nullable<Scene>): Mesh;
  58997. /**
  58998. * Creates an custom extruded shape mesh.
  58999. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59000. * * 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.
  59001. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59002. * * 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
  59003. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59004. * * 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
  59005. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59006. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59007. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59008. * * 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
  59009. * * 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
  59010. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59012. * * 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
  59013. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59015. * @param name defines the name of the mesh
  59016. * @param options defines the options used to create the mesh
  59017. * @param scene defines the hosting scene
  59018. * @returns the custom extruded shape mesh
  59019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59020. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59022. */
  59023. static ExtrudeShapeCustom(name: string, options: {
  59024. shape: Vector3[];
  59025. path: Vector3[];
  59026. scaleFunction?: any;
  59027. rotationFunction?: any;
  59028. ribbonCloseArray?: boolean;
  59029. ribbonClosePath?: boolean;
  59030. cap?: number;
  59031. updatable?: boolean;
  59032. sideOrientation?: number;
  59033. frontUVs?: Vector4;
  59034. backUVs?: Vector4;
  59035. instance?: Mesh;
  59036. invertUV?: boolean;
  59037. }, scene?: Nullable<Scene>): Mesh;
  59038. /**
  59039. * Creates lathe mesh.
  59040. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59041. * * 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
  59042. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59043. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59044. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59045. * * 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
  59046. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59047. * * 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
  59048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59049. * * 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
  59050. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59052. * @param name defines the name of the mesh
  59053. * @param options defines the options used to create the mesh
  59054. * @param scene defines the hosting scene
  59055. * @returns the lathe mesh
  59056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59057. */
  59058. static CreateLathe(name: string, options: {
  59059. shape: Vector3[];
  59060. radius?: number;
  59061. tessellation?: number;
  59062. clip?: number;
  59063. arc?: number;
  59064. closed?: boolean;
  59065. updatable?: boolean;
  59066. sideOrientation?: number;
  59067. frontUVs?: Vector4;
  59068. backUVs?: Vector4;
  59069. cap?: number;
  59070. invertUV?: boolean;
  59071. }, scene?: Nullable<Scene>): Mesh;
  59072. /**
  59073. * Creates a tiled plane mesh
  59074. * * You can set a limited pattern arrangement with the tiles
  59075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59076. * * 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
  59077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59078. * @param name defines the name of the mesh
  59079. * @param options defines the options used to create the mesh
  59080. * @param scene defines the hosting scene
  59081. * @returns the plane mesh
  59082. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59083. */
  59084. static CreateTiledPlane(name: string, options: {
  59085. pattern?: number;
  59086. tileSize?: number;
  59087. tileWidth?: number;
  59088. tileHeight?: number;
  59089. size?: number;
  59090. width?: number;
  59091. height?: number;
  59092. alignHorizontal?: number;
  59093. alignVertical?: number;
  59094. sideOrientation?: number;
  59095. frontUVs?: Vector4;
  59096. backUVs?: Vector4;
  59097. updatable?: boolean;
  59098. }, scene?: Nullable<Scene>): Mesh;
  59099. /**
  59100. * Creates a plane mesh
  59101. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59102. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59103. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59105. * * 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
  59106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59107. * @param name defines the name of the mesh
  59108. * @param options defines the options used to create the mesh
  59109. * @param scene defines the hosting scene
  59110. * @returns the plane mesh
  59111. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59112. */
  59113. static CreatePlane(name: string, options: {
  59114. size?: number;
  59115. width?: number;
  59116. height?: number;
  59117. sideOrientation?: number;
  59118. frontUVs?: Vector4;
  59119. backUVs?: Vector4;
  59120. updatable?: boolean;
  59121. sourcePlane?: Plane;
  59122. }, scene?: Nullable<Scene>): Mesh;
  59123. /**
  59124. * Creates a ground mesh
  59125. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59126. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59128. * @param name defines the name of the mesh
  59129. * @param options defines the options used to create the mesh
  59130. * @param scene defines the hosting scene
  59131. * @returns the ground mesh
  59132. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59133. */
  59134. static CreateGround(name: string, options: {
  59135. width?: number;
  59136. height?: number;
  59137. subdivisions?: number;
  59138. subdivisionsX?: number;
  59139. subdivisionsY?: number;
  59140. updatable?: boolean;
  59141. }, scene?: Nullable<Scene>): Mesh;
  59142. /**
  59143. * Creates a tiled ground mesh
  59144. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59145. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59146. * * 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
  59147. * * 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
  59148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59149. * @param name defines the name of the mesh
  59150. * @param options defines the options used to create the mesh
  59151. * @param scene defines the hosting scene
  59152. * @returns the tiled ground mesh
  59153. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59154. */
  59155. static CreateTiledGround(name: string, options: {
  59156. xmin: number;
  59157. zmin: number;
  59158. xmax: number;
  59159. zmax: number;
  59160. subdivisions?: {
  59161. w: number;
  59162. h: number;
  59163. };
  59164. precision?: {
  59165. w: number;
  59166. h: number;
  59167. };
  59168. updatable?: boolean;
  59169. }, scene?: Nullable<Scene>): Mesh;
  59170. /**
  59171. * Creates a ground mesh from a height map
  59172. * * The parameter `url` sets the URL of the height map image resource.
  59173. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59174. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59175. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59176. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59177. * * 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.
  59178. * * 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).
  59179. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59181. * @param name defines the name of the mesh
  59182. * @param url defines the url to the height map
  59183. * @param options defines the options used to create the mesh
  59184. * @param scene defines the hosting scene
  59185. * @returns the ground mesh
  59186. * @see https://doc.babylonjs.com/babylon101/height_map
  59187. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59188. */
  59189. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59190. width?: number;
  59191. height?: number;
  59192. subdivisions?: number;
  59193. minHeight?: number;
  59194. maxHeight?: number;
  59195. colorFilter?: Color3;
  59196. alphaFilter?: number;
  59197. updatable?: boolean;
  59198. onReady?: (mesh: GroundMesh) => void;
  59199. }, scene?: Nullable<Scene>): GroundMesh;
  59200. /**
  59201. * Creates a polygon mesh
  59202. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59203. * * 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
  59204. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59206. * * 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)
  59207. * * Remember you can only change the shape positions, not their number when updating a polygon
  59208. * @param name defines the name of the mesh
  59209. * @param options defines the options used to create the mesh
  59210. * @param scene defines the hosting scene
  59211. * @param earcutInjection can be used to inject your own earcut reference
  59212. * @returns the polygon mesh
  59213. */
  59214. static CreatePolygon(name: string, options: {
  59215. shape: Vector3[];
  59216. holes?: Vector3[][];
  59217. depth?: number;
  59218. faceUV?: Vector4[];
  59219. faceColors?: Color4[];
  59220. updatable?: boolean;
  59221. sideOrientation?: number;
  59222. frontUVs?: Vector4;
  59223. backUVs?: Vector4;
  59224. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59225. /**
  59226. * Creates an extruded polygon mesh, with depth in the Y direction.
  59227. * * 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)
  59228. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59229. * @param name defines the name of the mesh
  59230. * @param options defines the options used to create the mesh
  59231. * @param scene defines the hosting scene
  59232. * @param earcutInjection can be used to inject your own earcut reference
  59233. * @returns the polygon mesh
  59234. */
  59235. static ExtrudePolygon(name: string, options: {
  59236. shape: Vector3[];
  59237. holes?: Vector3[][];
  59238. depth?: number;
  59239. faceUV?: Vector4[];
  59240. faceColors?: Color4[];
  59241. updatable?: boolean;
  59242. sideOrientation?: number;
  59243. frontUVs?: Vector4;
  59244. backUVs?: Vector4;
  59245. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59246. /**
  59247. * Creates a tube mesh.
  59248. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59249. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59250. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59251. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59252. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59253. * * 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)
  59254. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59255. * * 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
  59256. * * 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
  59257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59258. * * 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
  59259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59261. * @param name defines the name of the mesh
  59262. * @param options defines the options used to create the mesh
  59263. * @param scene defines the hosting scene
  59264. * @returns the tube mesh
  59265. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59266. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59267. */
  59268. static CreateTube(name: string, options: {
  59269. path: Vector3[];
  59270. radius?: number;
  59271. tessellation?: number;
  59272. radiusFunction?: {
  59273. (i: number, distance: number): number;
  59274. };
  59275. cap?: number;
  59276. arc?: number;
  59277. updatable?: boolean;
  59278. sideOrientation?: number;
  59279. frontUVs?: Vector4;
  59280. backUVs?: Vector4;
  59281. instance?: Mesh;
  59282. invertUV?: boolean;
  59283. }, scene?: Nullable<Scene>): Mesh;
  59284. /**
  59285. * Creates a polyhedron mesh
  59286. * * 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
  59287. * * The parameter `size` (positive float, default 1) sets the polygon size
  59288. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59289. * * 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`
  59290. * * 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
  59291. * * 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)`)
  59292. * * 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
  59293. * * 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
  59294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59295. * * 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
  59296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59297. * @param name defines the name of the mesh
  59298. * @param options defines the options used to create the mesh
  59299. * @param scene defines the hosting scene
  59300. * @returns the polyhedron mesh
  59301. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59302. */
  59303. static CreatePolyhedron(name: string, options: {
  59304. type?: number;
  59305. size?: number;
  59306. sizeX?: number;
  59307. sizeY?: number;
  59308. sizeZ?: number;
  59309. custom?: any;
  59310. faceUV?: Vector4[];
  59311. faceColors?: Color4[];
  59312. flat?: boolean;
  59313. updatable?: boolean;
  59314. sideOrientation?: number;
  59315. frontUVs?: Vector4;
  59316. backUVs?: Vector4;
  59317. }, scene?: Nullable<Scene>): Mesh;
  59318. /**
  59319. * Creates a decal mesh.
  59320. * 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
  59321. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59322. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59323. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59324. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59325. * @param name defines the name of the mesh
  59326. * @param sourceMesh defines the mesh where the decal must be applied
  59327. * @param options defines the options used to create the mesh
  59328. * @param scene defines the hosting scene
  59329. * @returns the decal mesh
  59330. * @see https://doc.babylonjs.com/how_to/decals
  59331. */
  59332. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59333. position?: Vector3;
  59334. normal?: Vector3;
  59335. size?: Vector3;
  59336. angle?: number;
  59337. }): Mesh;
  59338. }
  59339. }
  59340. declare module BABYLON {
  59341. /**
  59342. * A simplifier interface for future simplification implementations
  59343. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59344. */
  59345. export interface ISimplifier {
  59346. /**
  59347. * Simplification of a given mesh according to the given settings.
  59348. * Since this requires computation, it is assumed that the function runs async.
  59349. * @param settings The settings of the simplification, including quality and distance
  59350. * @param successCallback A callback that will be called after the mesh was simplified.
  59351. * @param errorCallback in case of an error, this callback will be called. optional.
  59352. */
  59353. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59354. }
  59355. /**
  59356. * Expected simplification settings.
  59357. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59358. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59359. */
  59360. export interface ISimplificationSettings {
  59361. /**
  59362. * Gets or sets the expected quality
  59363. */
  59364. quality: number;
  59365. /**
  59366. * Gets or sets the distance when this optimized version should be used
  59367. */
  59368. distance: number;
  59369. /**
  59370. * Gets an already optimized mesh
  59371. */
  59372. optimizeMesh?: boolean;
  59373. }
  59374. /**
  59375. * Class used to specify simplification options
  59376. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59377. */
  59378. export class SimplificationSettings implements ISimplificationSettings {
  59379. /** expected quality */
  59380. quality: number;
  59381. /** distance when this optimized version should be used */
  59382. distance: number;
  59383. /** already optimized mesh */
  59384. optimizeMesh?: boolean | undefined;
  59385. /**
  59386. * Creates a SimplificationSettings
  59387. * @param quality expected quality
  59388. * @param distance distance when this optimized version should be used
  59389. * @param optimizeMesh already optimized mesh
  59390. */
  59391. constructor(
  59392. /** expected quality */
  59393. quality: number,
  59394. /** distance when this optimized version should be used */
  59395. distance: number,
  59396. /** already optimized mesh */
  59397. optimizeMesh?: boolean | undefined);
  59398. }
  59399. /**
  59400. * Interface used to define a simplification task
  59401. */
  59402. export interface ISimplificationTask {
  59403. /**
  59404. * Array of settings
  59405. */
  59406. settings: Array<ISimplificationSettings>;
  59407. /**
  59408. * Simplification type
  59409. */
  59410. simplificationType: SimplificationType;
  59411. /**
  59412. * Mesh to simplify
  59413. */
  59414. mesh: Mesh;
  59415. /**
  59416. * Callback called on success
  59417. */
  59418. successCallback?: () => void;
  59419. /**
  59420. * Defines if parallel processing can be used
  59421. */
  59422. parallelProcessing: boolean;
  59423. }
  59424. /**
  59425. * Queue used to order the simplification tasks
  59426. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59427. */
  59428. export class SimplificationQueue {
  59429. private _simplificationArray;
  59430. /**
  59431. * Gets a boolean indicating that the process is still running
  59432. */
  59433. running: boolean;
  59434. /**
  59435. * Creates a new queue
  59436. */
  59437. constructor();
  59438. /**
  59439. * Adds a new simplification task
  59440. * @param task defines a task to add
  59441. */
  59442. addTask(task: ISimplificationTask): void;
  59443. /**
  59444. * Execute next task
  59445. */
  59446. executeNext(): void;
  59447. /**
  59448. * Execute a simplification task
  59449. * @param task defines the task to run
  59450. */
  59451. runSimplification(task: ISimplificationTask): void;
  59452. private getSimplifier;
  59453. }
  59454. /**
  59455. * The implemented types of simplification
  59456. * At the moment only Quadratic Error Decimation is implemented
  59457. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59458. */
  59459. export enum SimplificationType {
  59460. /** Quadratic error decimation */
  59461. QUADRATIC = 0
  59462. }
  59463. }
  59464. declare module BABYLON {
  59465. interface Scene {
  59466. /** @hidden (Backing field) */
  59467. _simplificationQueue: SimplificationQueue;
  59468. /**
  59469. * Gets or sets the simplification queue attached to the scene
  59470. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59471. */
  59472. simplificationQueue: SimplificationQueue;
  59473. }
  59474. interface Mesh {
  59475. /**
  59476. * Simplify the mesh according to the given array of settings.
  59477. * Function will return immediately and will simplify async
  59478. * @param settings a collection of simplification settings
  59479. * @param parallelProcessing should all levels calculate parallel or one after the other
  59480. * @param simplificationType the type of simplification to run
  59481. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59482. * @returns the current mesh
  59483. */
  59484. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59485. }
  59486. /**
  59487. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59488. * created in a scene
  59489. */
  59490. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59491. /**
  59492. * The component name helpfull to identify the component in the list of scene components.
  59493. */
  59494. readonly name: string;
  59495. /**
  59496. * The scene the component belongs to.
  59497. */
  59498. scene: Scene;
  59499. /**
  59500. * Creates a new instance of the component for the given scene
  59501. * @param scene Defines the scene to register the component in
  59502. */
  59503. constructor(scene: Scene);
  59504. /**
  59505. * Registers the component in a given scene
  59506. */
  59507. register(): void;
  59508. /**
  59509. * Rebuilds the elements related to this component in case of
  59510. * context lost for instance.
  59511. */
  59512. rebuild(): void;
  59513. /**
  59514. * Disposes the component and the associated ressources
  59515. */
  59516. dispose(): void;
  59517. private _beforeCameraUpdate;
  59518. }
  59519. }
  59520. declare module BABYLON {
  59521. /**
  59522. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59523. */
  59524. export interface INavigationEnginePlugin {
  59525. /**
  59526. * plugin name
  59527. */
  59528. name: string;
  59529. /**
  59530. * Creates a navigation mesh
  59531. * @param meshes array of all the geometry used to compute the navigatio mesh
  59532. * @param parameters bunch of parameters used to filter geometry
  59533. */
  59534. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59535. /**
  59536. * Create a navigation mesh debug mesh
  59537. * @param scene is where the mesh will be added
  59538. * @returns debug display mesh
  59539. */
  59540. createDebugNavMesh(scene: Scene): Mesh;
  59541. /**
  59542. * Get a navigation mesh constrained position, closest to the parameter position
  59543. * @param position world position
  59544. * @returns the closest point to position constrained by the navigation mesh
  59545. */
  59546. getClosestPoint(position: Vector3): Vector3;
  59547. /**
  59548. * Get a navigation mesh constrained position, within a particular radius
  59549. * @param position world position
  59550. * @param maxRadius the maximum distance to the constrained world position
  59551. * @returns the closest point to position constrained by the navigation mesh
  59552. */
  59553. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59554. /**
  59555. * Compute the final position from a segment made of destination-position
  59556. * @param position world position
  59557. * @param destination world position
  59558. * @returns the resulting point along the navmesh
  59559. */
  59560. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59561. /**
  59562. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59563. * @param start world position
  59564. * @param end world position
  59565. * @returns array containing world position composing the path
  59566. */
  59567. computePath(start: Vector3, end: Vector3): Vector3[];
  59568. /**
  59569. * If this plugin is supported
  59570. * @returns true if plugin is supported
  59571. */
  59572. isSupported(): boolean;
  59573. /**
  59574. * Create a new Crowd so you can add agents
  59575. * @param maxAgents the maximum agent count in the crowd
  59576. * @param maxAgentRadius the maximum radius an agent can have
  59577. * @param scene to attach the crowd to
  59578. * @returns the crowd you can add agents to
  59579. */
  59580. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59581. /**
  59582. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59583. * The queries will try to find a solution within those bounds
  59584. * default is (1,1,1)
  59585. * @param extent x,y,z value that define the extent around the queries point of reference
  59586. */
  59587. setDefaultQueryExtent(extent: Vector3): void;
  59588. /**
  59589. * Get the Bounding box extent specified by setDefaultQueryExtent
  59590. * @returns the box extent values
  59591. */
  59592. getDefaultQueryExtent(): Vector3;
  59593. /**
  59594. * Release all resources
  59595. */
  59596. dispose(): void;
  59597. }
  59598. /**
  59599. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59600. */
  59601. export interface ICrowd {
  59602. /**
  59603. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59604. * You can attach anything to that node. The node position is updated in the scene update tick.
  59605. * @param pos world position that will be constrained by the navigation mesh
  59606. * @param parameters agent parameters
  59607. * @param transform hooked to the agent that will be update by the scene
  59608. * @returns agent index
  59609. */
  59610. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59611. /**
  59612. * Returns the agent position in world space
  59613. * @param index agent index returned by addAgent
  59614. * @returns world space position
  59615. */
  59616. getAgentPosition(index: number): Vector3;
  59617. /**
  59618. * Gets the agent velocity in world space
  59619. * @param index agent index returned by addAgent
  59620. * @returns world space velocity
  59621. */
  59622. getAgentVelocity(index: number): Vector3;
  59623. /**
  59624. * remove a particular agent previously created
  59625. * @param index agent index returned by addAgent
  59626. */
  59627. removeAgent(index: number): void;
  59628. /**
  59629. * get the list of all agents attached to this crowd
  59630. * @returns list of agent indices
  59631. */
  59632. getAgents(): number[];
  59633. /**
  59634. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59635. * @param deltaTime in seconds
  59636. */
  59637. update(deltaTime: number): void;
  59638. /**
  59639. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59640. * @param index agent index returned by addAgent
  59641. * @param destination targeted world position
  59642. */
  59643. agentGoto(index: number, destination: Vector3): void;
  59644. /**
  59645. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59646. * The queries will try to find a solution within those bounds
  59647. * default is (1,1,1)
  59648. * @param extent x,y,z value that define the extent around the queries point of reference
  59649. */
  59650. setDefaultQueryExtent(extent: Vector3): void;
  59651. /**
  59652. * Get the Bounding box extent specified by setDefaultQueryExtent
  59653. * @returns the box extent values
  59654. */
  59655. getDefaultQueryExtent(): Vector3;
  59656. /**
  59657. * Release all resources
  59658. */
  59659. dispose(): void;
  59660. }
  59661. /**
  59662. * Configures an agent
  59663. */
  59664. export interface IAgentParameters {
  59665. /**
  59666. * Agent radius. [Limit: >= 0]
  59667. */
  59668. radius: number;
  59669. /**
  59670. * Agent height. [Limit: > 0]
  59671. */
  59672. height: number;
  59673. /**
  59674. * Maximum allowed acceleration. [Limit: >= 0]
  59675. */
  59676. maxAcceleration: number;
  59677. /**
  59678. * Maximum allowed speed. [Limit: >= 0]
  59679. */
  59680. maxSpeed: number;
  59681. /**
  59682. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59683. */
  59684. collisionQueryRange: number;
  59685. /**
  59686. * The path visibility optimization range. [Limit: > 0]
  59687. */
  59688. pathOptimizationRange: number;
  59689. /**
  59690. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59691. */
  59692. separationWeight: number;
  59693. }
  59694. /**
  59695. * Configures the navigation mesh creation
  59696. */
  59697. export interface INavMeshParameters {
  59698. /**
  59699. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59700. */
  59701. cs: number;
  59702. /**
  59703. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59704. */
  59705. ch: number;
  59706. /**
  59707. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59708. */
  59709. walkableSlopeAngle: number;
  59710. /**
  59711. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59712. * be considered walkable. [Limit: >= 3] [Units: vx]
  59713. */
  59714. walkableHeight: number;
  59715. /**
  59716. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59717. */
  59718. walkableClimb: number;
  59719. /**
  59720. * The distance to erode/shrink the walkable area of the heightfield away from
  59721. * obstructions. [Limit: >=0] [Units: vx]
  59722. */
  59723. walkableRadius: number;
  59724. /**
  59725. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59726. */
  59727. maxEdgeLen: number;
  59728. /**
  59729. * The maximum distance a simplfied contour's border edges should deviate
  59730. * the original raw contour. [Limit: >=0] [Units: vx]
  59731. */
  59732. maxSimplificationError: number;
  59733. /**
  59734. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59735. */
  59736. minRegionArea: number;
  59737. /**
  59738. * Any regions with a span count smaller than this value will, if possible,
  59739. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59740. */
  59741. mergeRegionArea: number;
  59742. /**
  59743. * The maximum number of vertices allowed for polygons generated during the
  59744. * contour to polygon conversion process. [Limit: >= 3]
  59745. */
  59746. maxVertsPerPoly: number;
  59747. /**
  59748. * Sets the sampling distance to use when generating the detail mesh.
  59749. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59750. */
  59751. detailSampleDist: number;
  59752. /**
  59753. * The maximum distance the detail mesh surface should deviate from heightfield
  59754. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59755. */
  59756. detailSampleMaxError: number;
  59757. }
  59758. }
  59759. declare module BABYLON {
  59760. /**
  59761. * RecastJS navigation plugin
  59762. */
  59763. export class RecastJSPlugin implements INavigationEnginePlugin {
  59764. /**
  59765. * Reference to the Recast library
  59766. */
  59767. bjsRECAST: any;
  59768. /**
  59769. * plugin name
  59770. */
  59771. name: string;
  59772. /**
  59773. * the first navmesh created. We might extend this to support multiple navmeshes
  59774. */
  59775. navMesh: any;
  59776. /**
  59777. * Initializes the recastJS plugin
  59778. * @param recastInjection can be used to inject your own recast reference
  59779. */
  59780. constructor(recastInjection?: any);
  59781. /**
  59782. * Creates a navigation mesh
  59783. * @param meshes array of all the geometry used to compute the navigatio mesh
  59784. * @param parameters bunch of parameters used to filter geometry
  59785. */
  59786. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59787. /**
  59788. * Create a navigation mesh debug mesh
  59789. * @param scene is where the mesh will be added
  59790. * @returns debug display mesh
  59791. */
  59792. createDebugNavMesh(scene: Scene): Mesh;
  59793. /**
  59794. * Get a navigation mesh constrained position, closest to the parameter position
  59795. * @param position world position
  59796. * @returns the closest point to position constrained by the navigation mesh
  59797. */
  59798. getClosestPoint(position: Vector3): Vector3;
  59799. /**
  59800. * Get a navigation mesh constrained position, within a particular radius
  59801. * @param position world position
  59802. * @param maxRadius the maximum distance to the constrained world position
  59803. * @returns the closest point to position constrained by the navigation mesh
  59804. */
  59805. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59806. /**
  59807. * Compute the final position from a segment made of destination-position
  59808. * @param position world position
  59809. * @param destination world position
  59810. * @returns the resulting point along the navmesh
  59811. */
  59812. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59813. /**
  59814. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59815. * @param start world position
  59816. * @param end world position
  59817. * @returns array containing world position composing the path
  59818. */
  59819. computePath(start: Vector3, end: Vector3): Vector3[];
  59820. /**
  59821. * Create a new Crowd so you can add agents
  59822. * @param maxAgents the maximum agent count in the crowd
  59823. * @param maxAgentRadius the maximum radius an agent can have
  59824. * @param scene to attach the crowd to
  59825. * @returns the crowd you can add agents to
  59826. */
  59827. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59828. /**
  59829. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59830. * The queries will try to find a solution within those bounds
  59831. * default is (1,1,1)
  59832. * @param extent x,y,z value that define the extent around the queries point of reference
  59833. */
  59834. setDefaultQueryExtent(extent: Vector3): void;
  59835. /**
  59836. * Get the Bounding box extent specified by setDefaultQueryExtent
  59837. * @returns the box extent values
  59838. */
  59839. getDefaultQueryExtent(): Vector3;
  59840. /**
  59841. * Disposes
  59842. */
  59843. dispose(): void;
  59844. /**
  59845. * If this plugin is supported
  59846. * @returns true if plugin is supported
  59847. */
  59848. isSupported(): boolean;
  59849. }
  59850. /**
  59851. * Recast detour crowd implementation
  59852. */
  59853. export class RecastJSCrowd implements ICrowd {
  59854. /**
  59855. * Recast/detour plugin
  59856. */
  59857. bjsRECASTPlugin: RecastJSPlugin;
  59858. /**
  59859. * Link to the detour crowd
  59860. */
  59861. recastCrowd: any;
  59862. /**
  59863. * One transform per agent
  59864. */
  59865. transforms: TransformNode[];
  59866. /**
  59867. * All agents created
  59868. */
  59869. agents: number[];
  59870. /**
  59871. * Link to the scene is kept to unregister the crowd from the scene
  59872. */
  59873. private _scene;
  59874. /**
  59875. * Observer for crowd updates
  59876. */
  59877. private _onBeforeAnimationsObserver;
  59878. /**
  59879. * Constructor
  59880. * @param plugin recastJS plugin
  59881. * @param maxAgents the maximum agent count in the crowd
  59882. * @param maxAgentRadius the maximum radius an agent can have
  59883. * @param scene to attach the crowd to
  59884. * @returns the crowd you can add agents to
  59885. */
  59886. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59887. /**
  59888. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59889. * You can attach anything to that node. The node position is updated in the scene update tick.
  59890. * @param pos world position that will be constrained by the navigation mesh
  59891. * @param parameters agent parameters
  59892. * @param transform hooked to the agent that will be update by the scene
  59893. * @returns agent index
  59894. */
  59895. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59896. /**
  59897. * Returns the agent position in world space
  59898. * @param index agent index returned by addAgent
  59899. * @returns world space position
  59900. */
  59901. getAgentPosition(index: number): Vector3;
  59902. /**
  59903. * Returns the agent velocity in world space
  59904. * @param index agent index returned by addAgent
  59905. * @returns world space velocity
  59906. */
  59907. getAgentVelocity(index: number): Vector3;
  59908. /**
  59909. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59910. * @param index agent index returned by addAgent
  59911. * @param destination targeted world position
  59912. */
  59913. agentGoto(index: number, destination: Vector3): void;
  59914. /**
  59915. * remove a particular agent previously created
  59916. * @param index agent index returned by addAgent
  59917. */
  59918. removeAgent(index: number): void;
  59919. /**
  59920. * get the list of all agents attached to this crowd
  59921. * @returns list of agent indices
  59922. */
  59923. getAgents(): number[];
  59924. /**
  59925. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59926. * @param deltaTime in seconds
  59927. */
  59928. update(deltaTime: number): void;
  59929. /**
  59930. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59931. * The queries will try to find a solution within those bounds
  59932. * default is (1,1,1)
  59933. * @param extent x,y,z value that define the extent around the queries point of reference
  59934. */
  59935. setDefaultQueryExtent(extent: Vector3): void;
  59936. /**
  59937. * Get the Bounding box extent specified by setDefaultQueryExtent
  59938. * @returns the box extent values
  59939. */
  59940. getDefaultQueryExtent(): Vector3;
  59941. /**
  59942. * Release all resources
  59943. */
  59944. dispose(): void;
  59945. }
  59946. }
  59947. declare module BABYLON {
  59948. /**
  59949. * Class used to enable access to IndexedDB
  59950. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59951. */
  59952. export class Database implements IOfflineProvider {
  59953. private _callbackManifestChecked;
  59954. private _currentSceneUrl;
  59955. private _db;
  59956. private _enableSceneOffline;
  59957. private _enableTexturesOffline;
  59958. private _manifestVersionFound;
  59959. private _mustUpdateRessources;
  59960. private _hasReachedQuota;
  59961. private _isSupported;
  59962. private _idbFactory;
  59963. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59964. private static IsUASupportingBlobStorage;
  59965. /**
  59966. * Gets a boolean indicating if Database storate is enabled (off by default)
  59967. */
  59968. static IDBStorageEnabled: boolean;
  59969. /**
  59970. * Gets a boolean indicating if scene must be saved in the database
  59971. */
  59972. readonly enableSceneOffline: boolean;
  59973. /**
  59974. * Gets a boolean indicating if textures must be saved in the database
  59975. */
  59976. readonly enableTexturesOffline: boolean;
  59977. /**
  59978. * Creates a new Database
  59979. * @param urlToScene defines the url to load the scene
  59980. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59981. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59982. */
  59983. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59984. private static _ParseURL;
  59985. private static _ReturnFullUrlLocation;
  59986. private _checkManifestFile;
  59987. /**
  59988. * Open the database and make it available
  59989. * @param successCallback defines the callback to call on success
  59990. * @param errorCallback defines the callback to call on error
  59991. */
  59992. open(successCallback: () => void, errorCallback: () => void): void;
  59993. /**
  59994. * Loads an image from the database
  59995. * @param url defines the url to load from
  59996. * @param image defines the target DOM image
  59997. */
  59998. loadImage(url: string, image: HTMLImageElement): void;
  59999. private _loadImageFromDBAsync;
  60000. private _saveImageIntoDBAsync;
  60001. private _checkVersionFromDB;
  60002. private _loadVersionFromDBAsync;
  60003. private _saveVersionIntoDBAsync;
  60004. /**
  60005. * Loads a file from database
  60006. * @param url defines the URL to load from
  60007. * @param sceneLoaded defines a callback to call on success
  60008. * @param progressCallBack defines a callback to call when progress changed
  60009. * @param errorCallback defines a callback to call on error
  60010. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60011. */
  60012. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60013. private _loadFileAsync;
  60014. private _saveFileAsync;
  60015. /**
  60016. * Validates if xhr data is correct
  60017. * @param xhr defines the request to validate
  60018. * @param dataType defines the expected data type
  60019. * @returns true if data is correct
  60020. */
  60021. private static _ValidateXHRData;
  60022. }
  60023. }
  60024. declare module BABYLON {
  60025. /** @hidden */
  60026. export var gpuUpdateParticlesPixelShader: {
  60027. name: string;
  60028. shader: string;
  60029. };
  60030. }
  60031. declare module BABYLON {
  60032. /** @hidden */
  60033. export var gpuUpdateParticlesVertexShader: {
  60034. name: string;
  60035. shader: string;
  60036. };
  60037. }
  60038. declare module BABYLON {
  60039. /** @hidden */
  60040. export var clipPlaneFragmentDeclaration2: {
  60041. name: string;
  60042. shader: string;
  60043. };
  60044. }
  60045. declare module BABYLON {
  60046. /** @hidden */
  60047. export var gpuRenderParticlesPixelShader: {
  60048. name: string;
  60049. shader: string;
  60050. };
  60051. }
  60052. declare module BABYLON {
  60053. /** @hidden */
  60054. export var clipPlaneVertexDeclaration2: {
  60055. name: string;
  60056. shader: string;
  60057. };
  60058. }
  60059. declare module BABYLON {
  60060. /** @hidden */
  60061. export var gpuRenderParticlesVertexShader: {
  60062. name: string;
  60063. shader: string;
  60064. };
  60065. }
  60066. declare module BABYLON {
  60067. /**
  60068. * This represents a GPU particle system in Babylon
  60069. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60070. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60071. */
  60072. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60073. /**
  60074. * The layer mask we are rendering the particles through.
  60075. */
  60076. layerMask: number;
  60077. private _capacity;
  60078. private _activeCount;
  60079. private _currentActiveCount;
  60080. private _accumulatedCount;
  60081. private _renderEffect;
  60082. private _updateEffect;
  60083. private _buffer0;
  60084. private _buffer1;
  60085. private _spriteBuffer;
  60086. private _updateVAO;
  60087. private _renderVAO;
  60088. private _targetIndex;
  60089. private _sourceBuffer;
  60090. private _targetBuffer;
  60091. private _engine;
  60092. private _currentRenderId;
  60093. private _started;
  60094. private _stopped;
  60095. private _timeDelta;
  60096. private _randomTexture;
  60097. private _randomTexture2;
  60098. private _attributesStrideSize;
  60099. private _updateEffectOptions;
  60100. private _randomTextureSize;
  60101. private _actualFrame;
  60102. private readonly _rawTextureWidth;
  60103. /**
  60104. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60105. */
  60106. static readonly IsSupported: boolean;
  60107. /**
  60108. * An event triggered when the system is disposed.
  60109. */
  60110. onDisposeObservable: Observable<GPUParticleSystem>;
  60111. /**
  60112. * Gets the maximum number of particles active at the same time.
  60113. * @returns The max number of active particles.
  60114. */
  60115. getCapacity(): number;
  60116. /**
  60117. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60118. * to override the particles.
  60119. */
  60120. forceDepthWrite: boolean;
  60121. /**
  60122. * Gets or set the number of active particles
  60123. */
  60124. activeParticleCount: number;
  60125. private _preWarmDone;
  60126. /**
  60127. * Is this system ready to be used/rendered
  60128. * @return true if the system is ready
  60129. */
  60130. isReady(): boolean;
  60131. /**
  60132. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60133. * @returns True if it has been started, otherwise false.
  60134. */
  60135. isStarted(): boolean;
  60136. /**
  60137. * Starts the particle system and begins to emit
  60138. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60139. */
  60140. start(delay?: number): void;
  60141. /**
  60142. * Stops the particle system.
  60143. */
  60144. stop(): void;
  60145. /**
  60146. * Remove all active particles
  60147. */
  60148. reset(): void;
  60149. /**
  60150. * Returns the string "GPUParticleSystem"
  60151. * @returns a string containing the class name
  60152. */
  60153. getClassName(): string;
  60154. private _colorGradientsTexture;
  60155. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60156. /**
  60157. * Adds a new color gradient
  60158. * @param gradient defines the gradient to use (between 0 and 1)
  60159. * @param color1 defines the color to affect to the specified gradient
  60160. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60161. * @returns the current particle system
  60162. */
  60163. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60164. /**
  60165. * Remove a specific color gradient
  60166. * @param gradient defines the gradient to remove
  60167. * @returns the current particle system
  60168. */
  60169. removeColorGradient(gradient: number): GPUParticleSystem;
  60170. private _angularSpeedGradientsTexture;
  60171. private _sizeGradientsTexture;
  60172. private _velocityGradientsTexture;
  60173. private _limitVelocityGradientsTexture;
  60174. private _dragGradientsTexture;
  60175. private _addFactorGradient;
  60176. /**
  60177. * Adds a new size gradient
  60178. * @param gradient defines the gradient to use (between 0 and 1)
  60179. * @param factor defines the size factor to affect to the specified gradient
  60180. * @returns the current particle system
  60181. */
  60182. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60183. /**
  60184. * Remove a specific size gradient
  60185. * @param gradient defines the gradient to remove
  60186. * @returns the current particle system
  60187. */
  60188. removeSizeGradient(gradient: number): GPUParticleSystem;
  60189. /**
  60190. * Adds a new angular speed gradient
  60191. * @param gradient defines the gradient to use (between 0 and 1)
  60192. * @param factor defines the angular speed to affect to the specified gradient
  60193. * @returns the current particle system
  60194. */
  60195. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60196. /**
  60197. * Remove a specific angular speed gradient
  60198. * @param gradient defines the gradient to remove
  60199. * @returns the current particle system
  60200. */
  60201. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60202. /**
  60203. * Adds a new velocity gradient
  60204. * @param gradient defines the gradient to use (between 0 and 1)
  60205. * @param factor defines the velocity to affect to the specified gradient
  60206. * @returns the current particle system
  60207. */
  60208. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60209. /**
  60210. * Remove a specific velocity gradient
  60211. * @param gradient defines the gradient to remove
  60212. * @returns the current particle system
  60213. */
  60214. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60215. /**
  60216. * Adds a new limit velocity gradient
  60217. * @param gradient defines the gradient to use (between 0 and 1)
  60218. * @param factor defines the limit velocity value to affect to the specified gradient
  60219. * @returns the current particle system
  60220. */
  60221. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60222. /**
  60223. * Remove a specific limit velocity gradient
  60224. * @param gradient defines the gradient to remove
  60225. * @returns the current particle system
  60226. */
  60227. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60228. /**
  60229. * Adds a new drag gradient
  60230. * @param gradient defines the gradient to use (between 0 and 1)
  60231. * @param factor defines the drag value to affect to the specified gradient
  60232. * @returns the current particle system
  60233. */
  60234. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60235. /**
  60236. * Remove a specific drag gradient
  60237. * @param gradient defines the gradient to remove
  60238. * @returns the current particle system
  60239. */
  60240. removeDragGradient(gradient: number): GPUParticleSystem;
  60241. /**
  60242. * Not supported by GPUParticleSystem
  60243. * @param gradient defines the gradient to use (between 0 and 1)
  60244. * @param factor defines the emit rate value to affect to the specified gradient
  60245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60246. * @returns the current particle system
  60247. */
  60248. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60249. /**
  60250. * Not supported by GPUParticleSystem
  60251. * @param gradient defines the gradient to remove
  60252. * @returns the current particle system
  60253. */
  60254. removeEmitRateGradient(gradient: number): IParticleSystem;
  60255. /**
  60256. * Not supported by GPUParticleSystem
  60257. * @param gradient defines the gradient to use (between 0 and 1)
  60258. * @param factor defines the start size value to affect to the specified gradient
  60259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60260. * @returns the current particle system
  60261. */
  60262. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60263. /**
  60264. * Not supported by GPUParticleSystem
  60265. * @param gradient defines the gradient to remove
  60266. * @returns the current particle system
  60267. */
  60268. removeStartSizeGradient(gradient: number): IParticleSystem;
  60269. /**
  60270. * Not supported by GPUParticleSystem
  60271. * @param gradient defines the gradient to use (between 0 and 1)
  60272. * @param min defines the color remap minimal range
  60273. * @param max defines the color remap maximal range
  60274. * @returns the current particle system
  60275. */
  60276. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60277. /**
  60278. * Not supported by GPUParticleSystem
  60279. * @param gradient defines the gradient to remove
  60280. * @returns the current particle system
  60281. */
  60282. removeColorRemapGradient(): IParticleSystem;
  60283. /**
  60284. * Not supported by GPUParticleSystem
  60285. * @param gradient defines the gradient to use (between 0 and 1)
  60286. * @param min defines the alpha remap minimal range
  60287. * @param max defines the alpha remap maximal range
  60288. * @returns the current particle system
  60289. */
  60290. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60291. /**
  60292. * Not supported by GPUParticleSystem
  60293. * @param gradient defines the gradient to remove
  60294. * @returns the current particle system
  60295. */
  60296. removeAlphaRemapGradient(): IParticleSystem;
  60297. /**
  60298. * Not supported by GPUParticleSystem
  60299. * @param gradient defines the gradient to use (between 0 and 1)
  60300. * @param color defines the color to affect to the specified gradient
  60301. * @returns the current particle system
  60302. */
  60303. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60304. /**
  60305. * Not supported by GPUParticleSystem
  60306. * @param gradient defines the gradient to remove
  60307. * @returns the current particle system
  60308. */
  60309. removeRampGradient(): IParticleSystem;
  60310. /**
  60311. * Not supported by GPUParticleSystem
  60312. * @returns the list of ramp gradients
  60313. */
  60314. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60315. /**
  60316. * Not supported by GPUParticleSystem
  60317. * Gets or sets a boolean indicating that ramp gradients must be used
  60318. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60319. */
  60320. useRampGradients: boolean;
  60321. /**
  60322. * Not supported by GPUParticleSystem
  60323. * @param gradient defines the gradient to use (between 0 and 1)
  60324. * @param factor defines the life time factor to affect to the specified gradient
  60325. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60326. * @returns the current particle system
  60327. */
  60328. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60329. /**
  60330. * Not supported by GPUParticleSystem
  60331. * @param gradient defines the gradient to remove
  60332. * @returns the current particle system
  60333. */
  60334. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60335. /**
  60336. * Instantiates a GPU particle system.
  60337. * 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.
  60338. * @param name The name of the particle system
  60339. * @param options The options used to create the system
  60340. * @param scene The scene the particle system belongs to
  60341. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60342. */
  60343. constructor(name: string, options: Partial<{
  60344. capacity: number;
  60345. randomTextureSize: number;
  60346. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60347. protected _reset(): void;
  60348. private _createUpdateVAO;
  60349. private _createRenderVAO;
  60350. private _initialize;
  60351. /** @hidden */
  60352. _recreateUpdateEffect(): void;
  60353. /** @hidden */
  60354. _recreateRenderEffect(): void;
  60355. /**
  60356. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60357. * @param preWarm defines if we are in the pre-warmimg phase
  60358. */
  60359. animate(preWarm?: boolean): void;
  60360. private _createFactorGradientTexture;
  60361. private _createSizeGradientTexture;
  60362. private _createAngularSpeedGradientTexture;
  60363. private _createVelocityGradientTexture;
  60364. private _createLimitVelocityGradientTexture;
  60365. private _createDragGradientTexture;
  60366. private _createColorGradientTexture;
  60367. /**
  60368. * Renders the particle system in its current state
  60369. * @param preWarm defines if the system should only update the particles but not render them
  60370. * @returns the current number of particles
  60371. */
  60372. render(preWarm?: boolean): number;
  60373. /**
  60374. * Rebuilds the particle system
  60375. */
  60376. rebuild(): void;
  60377. private _releaseBuffers;
  60378. private _releaseVAOs;
  60379. /**
  60380. * Disposes the particle system and free the associated resources
  60381. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60382. */
  60383. dispose(disposeTexture?: boolean): void;
  60384. /**
  60385. * Clones the particle system.
  60386. * @param name The name of the cloned object
  60387. * @param newEmitter The new emitter to use
  60388. * @returns the cloned particle system
  60389. */
  60390. clone(name: string, newEmitter: any): GPUParticleSystem;
  60391. /**
  60392. * Serializes the particle system to a JSON object.
  60393. * @returns the JSON object
  60394. */
  60395. serialize(): any;
  60396. /**
  60397. * Parses a JSON object to create a GPU particle system.
  60398. * @param parsedParticleSystem The JSON object to parse
  60399. * @param scene The scene to create the particle system in
  60400. * @param rootUrl The root url to use to load external dependencies like texture
  60401. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60402. * @returns the parsed GPU particle system
  60403. */
  60404. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60405. }
  60406. }
  60407. declare module BABYLON {
  60408. /**
  60409. * Represents a set of particle systems working together to create a specific effect
  60410. */
  60411. export class ParticleSystemSet implements IDisposable {
  60412. /**
  60413. * Gets or sets base Assets URL
  60414. */
  60415. static BaseAssetsUrl: string;
  60416. private _emitterCreationOptions;
  60417. private _emitterNode;
  60418. /**
  60419. * Gets the particle system list
  60420. */
  60421. systems: IParticleSystem[];
  60422. /**
  60423. * Gets the emitter node used with this set
  60424. */
  60425. readonly emitterNode: Nullable<TransformNode>;
  60426. /**
  60427. * Creates a new emitter mesh as a sphere
  60428. * @param options defines the options used to create the sphere
  60429. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60430. * @param scene defines the hosting scene
  60431. */
  60432. setEmitterAsSphere(options: {
  60433. diameter: number;
  60434. segments: number;
  60435. color: Color3;
  60436. }, renderingGroupId: number, scene: Scene): void;
  60437. /**
  60438. * Starts all particle systems of the set
  60439. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60440. */
  60441. start(emitter?: AbstractMesh): void;
  60442. /**
  60443. * Release all associated resources
  60444. */
  60445. dispose(): void;
  60446. /**
  60447. * Serialize the set into a JSON compatible object
  60448. * @returns a JSON compatible representation of the set
  60449. */
  60450. serialize(): any;
  60451. /**
  60452. * Parse a new ParticleSystemSet from a serialized source
  60453. * @param data defines a JSON compatible representation of the set
  60454. * @param scene defines the hosting scene
  60455. * @param gpu defines if we want GPU particles or CPU particles
  60456. * @returns a new ParticleSystemSet
  60457. */
  60458. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60459. }
  60460. }
  60461. declare module BABYLON {
  60462. /**
  60463. * This class is made for on one-liner static method to help creating particle system set.
  60464. */
  60465. export class ParticleHelper {
  60466. /**
  60467. * Gets or sets base Assets URL
  60468. */
  60469. static BaseAssetsUrl: string;
  60470. /**
  60471. * Create a default particle system that you can tweak
  60472. * @param emitter defines the emitter to use
  60473. * @param capacity defines the system capacity (default is 500 particles)
  60474. * @param scene defines the hosting scene
  60475. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60476. * @returns the new Particle system
  60477. */
  60478. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60479. /**
  60480. * This is the main static method (one-liner) of this helper to create different particle systems
  60481. * @param type This string represents the type to the particle system to create
  60482. * @param scene The scene where the particle system should live
  60483. * @param gpu If the system will use gpu
  60484. * @returns the ParticleSystemSet created
  60485. */
  60486. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60487. /**
  60488. * Static function used to export a particle system to a ParticleSystemSet variable.
  60489. * Please note that the emitter shape is not exported
  60490. * @param systems defines the particle systems to export
  60491. * @returns the created particle system set
  60492. */
  60493. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60494. }
  60495. }
  60496. declare module BABYLON {
  60497. interface Engine {
  60498. /**
  60499. * Create an effect to use with particle systems.
  60500. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60501. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60502. * @param uniformsNames defines a list of attribute names
  60503. * @param samplers defines an array of string used to represent textures
  60504. * @param defines defines the string containing the defines to use to compile the shaders
  60505. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60506. * @param onCompiled defines a function to call when the effect creation is successful
  60507. * @param onError defines a function to call when the effect creation has failed
  60508. * @returns the new Effect
  60509. */
  60510. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60511. }
  60512. interface Mesh {
  60513. /**
  60514. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60515. * @returns an array of IParticleSystem
  60516. */
  60517. getEmittedParticleSystems(): IParticleSystem[];
  60518. /**
  60519. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60520. * @returns an array of IParticleSystem
  60521. */
  60522. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60523. }
  60524. /**
  60525. * @hidden
  60526. */
  60527. export var _IDoNeedToBeInTheBuild: number;
  60528. }
  60529. declare module BABYLON {
  60530. /** Defines the 4 color options */
  60531. export enum PointColor {
  60532. /** color value */
  60533. Color = 2,
  60534. /** uv value */
  60535. UV = 1,
  60536. /** random value */
  60537. Random = 0,
  60538. /** stated value */
  60539. Stated = 3
  60540. }
  60541. /**
  60542. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  60543. * 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.
  60544. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  60545. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  60546. *
  60547. * Full documentation here : TO BE ENTERED
  60548. */
  60549. export class PointsCloudSystem implements IDisposable {
  60550. /**
  60551. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  60552. * Example : var p = SPS.particles[i];
  60553. */
  60554. particles: CloudPoint[];
  60555. /**
  60556. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  60557. */
  60558. nbParticles: number;
  60559. /**
  60560. * This a counter for your own usage. It's not set by any SPS functions.
  60561. */
  60562. counter: number;
  60563. /**
  60564. * The PCS name. This name is also given to the underlying mesh.
  60565. */
  60566. name: string;
  60567. /**
  60568. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  60569. */
  60570. mesh: Mesh;
  60571. /**
  60572. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  60573. * Please read :
  60574. */
  60575. vars: any;
  60576. /**
  60577. * @hidden
  60578. */
  60579. _size: number;
  60580. private _scene;
  60581. private _promises;
  60582. private _positions;
  60583. private _indices;
  60584. private _normals;
  60585. private _colors;
  60586. private _uvs;
  60587. private _indices32;
  60588. private _positions32;
  60589. private _colors32;
  60590. private _uvs32;
  60591. private _updatable;
  60592. private _isVisibilityBoxLocked;
  60593. private _alwaysVisible;
  60594. private _groups;
  60595. private _groupCounter;
  60596. private _computeParticleColor;
  60597. private _computeParticleTexture;
  60598. private _computeParticleRotation;
  60599. private _computeBoundingBox;
  60600. private _isReady;
  60601. /**
  60602. * Creates a PCS (Points Cloud System) object
  60603. * @param name (String) is the PCS name, this will be the underlying mesh name
  60604. * @param pointSize (number) is the size for each point
  60605. * @param scene (Scene) is the scene in which the PCS is added
  60606. * @param options defines the options of the PCS e.g.
  60607. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  60608. */
  60609. constructor(name: string, pointSize: number, scene: Scene, options?: {
  60610. updatable?: boolean;
  60611. });
  60612. /**
  60613. * Builds the PCS underlying mesh. Returns a standard Mesh.
  60614. * If no points were added to the PCS, the returned mesh is just a single point.
  60615. * @returns a promise for the created mesh
  60616. */
  60617. buildMeshAsync(): Promise<Mesh>;
  60618. /**
  60619. * @hidden
  60620. */
  60621. private _buildMesh;
  60622. private _addParticle;
  60623. private _randomUnitVector;
  60624. private _getColorIndicesForCoord;
  60625. private _setPointsColorOrUV;
  60626. private _colorFromTexture;
  60627. private _calculateDensity;
  60628. /**
  60629. * Adds points to the PCS in random positions within a unit sphere
  60630. * @param nb (positive integer) the number of particles to be created from this model
  60631. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  60632. * @returns the number of groups in the system
  60633. */
  60634. addPoints(nb: number, pointFunction?: any): number;
  60635. /**
  60636. * Adds points to the PCS from the surface of the model shape
  60637. * @param mesh is any Mesh object that will be used as a surface model for the points
  60638. * @param nb (positive integer) the number of particles to be created from this model
  60639. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  60640. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  60641. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  60642. * @returns the number of groups in the system
  60643. */
  60644. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  60645. /**
  60646. * Adds points to the PCS inside the model shape
  60647. * @param mesh is any Mesh object that will be used as a surface model for the points
  60648. * @param nb (positive integer) the number of particles to be created from this model
  60649. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  60650. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  60651. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  60652. * @returns the number of groups in the system
  60653. */
  60654. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  60655. /**
  60656. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  60657. * This method calls `updateParticle()` for each particle of the SPS.
  60658. * For an animated SPS, it is usually called within the render loop.
  60659. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  60660. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  60661. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  60662. * @returns the PCS.
  60663. */
  60664. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  60665. /**
  60666. * Disposes the PCS.
  60667. */
  60668. dispose(): void;
  60669. /**
  60670. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  60671. * doc :
  60672. * @returns the PCS.
  60673. */
  60674. refreshVisibleSize(): PointsCloudSystem;
  60675. /**
  60676. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  60677. * @param size the size (float) of the visibility box
  60678. * note : this doesn't lock the PCS mesh bounding box.
  60679. * doc :
  60680. */
  60681. setVisibilityBox(size: number): void;
  60682. /**
  60683. * Gets whether the PCS is always visible or not
  60684. * doc :
  60685. */
  60686. /**
  60687. * Sets the PCS as always visible or not
  60688. * doc :
  60689. */
  60690. isAlwaysVisible: boolean;
  60691. /**
  60692. * Tells to `setParticles()` to compute the particle rotations or not
  60693. * Default value : false. The PCS is faster when it's set to false
  60694. * Note : particle rotations are only applied to parent particles
  60695. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  60696. */
  60697. computeParticleRotation: boolean;
  60698. /**
  60699. * Tells to `setParticles()` to compute the particle colors or not.
  60700. * Default value : true. The PCS is faster when it's set to false.
  60701. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  60702. */
  60703. /**
  60704. * Gets if `setParticles()` computes the particle colors or not.
  60705. * Default value : false. The PCS is faster when it's set to false.
  60706. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  60707. */
  60708. computeParticleColor: boolean;
  60709. /**
  60710. * Gets if `setParticles()` computes the particle textures or not.
  60711. * Default value : false. The PCS is faster when it's set to false.
  60712. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  60713. */
  60714. computeParticleTexture: boolean;
  60715. /**
  60716. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  60717. */
  60718. /**
  60719. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  60720. */
  60721. computeBoundingBox: boolean;
  60722. /**
  60723. * This function does nothing. It may be overwritten to set all the particle first values.
  60724. * The PCS doesn't call this function, you may have to call it by your own.
  60725. * doc :
  60726. */
  60727. initParticles(): void;
  60728. /**
  60729. * This function does nothing. It may be overwritten to recycle a particle
  60730. * The PCS doesn't call this function, you can to call it
  60731. * doc :
  60732. * @param particle The particle to recycle
  60733. * @returns the recycled particle
  60734. */
  60735. recycleParticle(particle: CloudPoint): CloudPoint;
  60736. /**
  60737. * Updates a particle : this function should be overwritten by the user.
  60738. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  60739. * doc :
  60740. * @example : just set a particle position or velocity and recycle conditions
  60741. * @param particle The particle to update
  60742. * @returns the updated particle
  60743. */
  60744. updateParticle(particle: CloudPoint): CloudPoint;
  60745. /**
  60746. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  60747. * This does nothing and may be overwritten by the user.
  60748. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60749. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60750. * @param update the boolean update value actually passed to setParticles()
  60751. */
  60752. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60753. /**
  60754. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  60755. * This will be passed three parameters.
  60756. * This does nothing and may be overwritten by the user.
  60757. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60758. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60759. * @param update the boolean update value actually passed to setParticles()
  60760. */
  60761. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60762. }
  60763. }
  60764. declare module BABYLON {
  60765. /**
  60766. * Represents one particle of a points cloud system.
  60767. */
  60768. export class CloudPoint {
  60769. /**
  60770. * particle global index
  60771. */
  60772. idx: number;
  60773. /**
  60774. * The color of the particle
  60775. */
  60776. color: Nullable<Color4>;
  60777. /**
  60778. * The world space position of the particle.
  60779. */
  60780. position: Vector3;
  60781. /**
  60782. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  60783. */
  60784. rotation: Vector3;
  60785. /**
  60786. * The world space rotation quaternion of the particle.
  60787. */
  60788. rotationQuaternion: Nullable<Quaternion>;
  60789. /**
  60790. * The uv of the particle.
  60791. */
  60792. uv: Nullable<Vector2>;
  60793. /**
  60794. * The current speed of the particle.
  60795. */
  60796. velocity: Vector3;
  60797. /**
  60798. * The pivot point in the particle local space.
  60799. */
  60800. pivot: Vector3;
  60801. /**
  60802. * Must the particle be translated from its pivot point in its local space ?
  60803. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  60804. * Default : false
  60805. */
  60806. translateFromPivot: boolean;
  60807. /**
  60808. * Index of this particle in the global "positions" array (Internal use)
  60809. * @hidden
  60810. */
  60811. _pos: number;
  60812. /**
  60813. * @hidden Index of this particle in the global "indices" array (Internal use)
  60814. */
  60815. _ind: number;
  60816. /**
  60817. * Group this particle belongs to
  60818. */
  60819. _group: PointsGroup;
  60820. /**
  60821. * Group id of this particle
  60822. */
  60823. groupId: number;
  60824. /**
  60825. * Index of the particle in its group id (Internal use)
  60826. */
  60827. idxInGroup: number;
  60828. /**
  60829. * @hidden Particle BoundingInfo object (Internal use)
  60830. */
  60831. _boundingInfo: BoundingInfo;
  60832. /**
  60833. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  60834. */
  60835. _pcs: PointsCloudSystem;
  60836. /**
  60837. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  60838. */
  60839. _stillInvisible: boolean;
  60840. /**
  60841. * @hidden Last computed particle rotation matrix
  60842. */
  60843. _rotationMatrix: number[];
  60844. /**
  60845. * Parent particle Id, if any.
  60846. * Default null.
  60847. */
  60848. parentId: Nullable<number>;
  60849. /**
  60850. * @hidden Internal global position in the PCS.
  60851. */
  60852. _globalPosition: Vector3;
  60853. /**
  60854. * Creates a Point Cloud object.
  60855. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  60856. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  60857. * @param group (PointsGroup) is the group the particle belongs to
  60858. * @param groupId (integer) is the group identifier in the PCS.
  60859. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  60860. * @param pcs defines the PCS it is associated to
  60861. */
  60862. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  60863. /**
  60864. * get point size
  60865. */
  60866. /**
  60867. * Set point size
  60868. */
  60869. size: Vector3;
  60870. /**
  60871. * Legacy support, changed quaternion to rotationQuaternion
  60872. */
  60873. /**
  60874. * Legacy support, changed quaternion to rotationQuaternion
  60875. */
  60876. quaternion: Nullable<Quaternion>;
  60877. /**
  60878. * Returns a boolean. True if the particle intersects a mesh, else false
  60879. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  60880. * @param target is the object (point or mesh) what the intersection is computed against
  60881. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  60882. * @returns true if it intersects
  60883. */
  60884. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  60885. /**
  60886. * get the rotation matrix of the particle
  60887. * @hidden
  60888. */
  60889. getRotationMatrix(m: Matrix): void;
  60890. }
  60891. /**
  60892. * Represents a group of points in a points cloud system
  60893. * * PCS internal tool, don't use it manually.
  60894. */
  60895. export class PointsGroup {
  60896. /**
  60897. * The group id
  60898. * @hidden
  60899. */
  60900. groupID: number;
  60901. /**
  60902. * image data for group (internal use)
  60903. * @hidden
  60904. */
  60905. _groupImageData: Nullable<ArrayBufferView>;
  60906. /**
  60907. * Image Width (internal use)
  60908. * @hidden
  60909. */
  60910. _groupImgWidth: number;
  60911. /**
  60912. * Image Height (internal use)
  60913. * @hidden
  60914. */
  60915. _groupImgHeight: number;
  60916. /**
  60917. * Custom position function (internal use)
  60918. * @hidden
  60919. */
  60920. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  60921. /**
  60922. * density per facet for surface points
  60923. * @hidden
  60924. */
  60925. _groupDensity: number[];
  60926. /**
  60927. * Only when points are colored by texture carries pointer to texture list array
  60928. * @hidden
  60929. */
  60930. _textureNb: number;
  60931. /**
  60932. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  60933. * PCS internal tool, don't use it manually.
  60934. * @hidden
  60935. */
  60936. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  60937. }
  60938. }
  60939. declare module BABYLON {
  60940. interface Scene {
  60941. /** @hidden (Backing field) */
  60942. _physicsEngine: Nullable<IPhysicsEngine>;
  60943. /** @hidden */
  60944. _physicsTimeAccumulator: number;
  60945. /**
  60946. * Gets the current physics engine
  60947. * @returns a IPhysicsEngine or null if none attached
  60948. */
  60949. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60950. /**
  60951. * Enables physics to the current scene
  60952. * @param gravity defines the scene's gravity for the physics engine
  60953. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60954. * @return a boolean indicating if the physics engine was initialized
  60955. */
  60956. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60957. /**
  60958. * Disables and disposes the physics engine associated with the scene
  60959. */
  60960. disablePhysicsEngine(): void;
  60961. /**
  60962. * Gets a boolean indicating if there is an active physics engine
  60963. * @returns a boolean indicating if there is an active physics engine
  60964. */
  60965. isPhysicsEnabled(): boolean;
  60966. /**
  60967. * Deletes a physics compound impostor
  60968. * @param compound defines the compound to delete
  60969. */
  60970. deleteCompoundImpostor(compound: any): void;
  60971. /**
  60972. * An event triggered when physic simulation is about to be run
  60973. */
  60974. onBeforePhysicsObservable: Observable<Scene>;
  60975. /**
  60976. * An event triggered when physic simulation has been done
  60977. */
  60978. onAfterPhysicsObservable: Observable<Scene>;
  60979. }
  60980. interface AbstractMesh {
  60981. /** @hidden */
  60982. _physicsImpostor: Nullable<PhysicsImpostor>;
  60983. /**
  60984. * Gets or sets impostor used for physic simulation
  60985. * @see http://doc.babylonjs.com/features/physics_engine
  60986. */
  60987. physicsImpostor: Nullable<PhysicsImpostor>;
  60988. /**
  60989. * Gets the current physics impostor
  60990. * @see http://doc.babylonjs.com/features/physics_engine
  60991. * @returns a physics impostor or null
  60992. */
  60993. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60994. /** Apply a physic impulse to the mesh
  60995. * @param force defines the force to apply
  60996. * @param contactPoint defines where to apply the force
  60997. * @returns the current mesh
  60998. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60999. */
  61000. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61001. /**
  61002. * Creates a physic joint between two meshes
  61003. * @param otherMesh defines the other mesh to use
  61004. * @param pivot1 defines the pivot to use on this mesh
  61005. * @param pivot2 defines the pivot to use on the other mesh
  61006. * @param options defines additional options (can be plugin dependent)
  61007. * @returns the current mesh
  61008. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61009. */
  61010. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61011. /** @hidden */
  61012. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61013. }
  61014. /**
  61015. * Defines the physics engine scene component responsible to manage a physics engine
  61016. */
  61017. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61018. /**
  61019. * The component name helpful to identify the component in the list of scene components.
  61020. */
  61021. readonly name: string;
  61022. /**
  61023. * The scene the component belongs to.
  61024. */
  61025. scene: Scene;
  61026. /**
  61027. * Creates a new instance of the component for the given scene
  61028. * @param scene Defines the scene to register the component in
  61029. */
  61030. constructor(scene: Scene);
  61031. /**
  61032. * Registers the component in a given scene
  61033. */
  61034. register(): void;
  61035. /**
  61036. * Rebuilds the elements related to this component in case of
  61037. * context lost for instance.
  61038. */
  61039. rebuild(): void;
  61040. /**
  61041. * Disposes the component and the associated ressources
  61042. */
  61043. dispose(): void;
  61044. }
  61045. }
  61046. declare module BABYLON {
  61047. /**
  61048. * A helper for physics simulations
  61049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61050. */
  61051. export class PhysicsHelper {
  61052. private _scene;
  61053. private _physicsEngine;
  61054. /**
  61055. * Initializes the Physics helper
  61056. * @param scene Babylon.js scene
  61057. */
  61058. constructor(scene: Scene);
  61059. /**
  61060. * Applies a radial explosion impulse
  61061. * @param origin the origin of the explosion
  61062. * @param radiusOrEventOptions the radius or the options of radial explosion
  61063. * @param strength the explosion strength
  61064. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61065. * @returns A physics radial explosion event, or null
  61066. */
  61067. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61068. /**
  61069. * Applies a radial explosion force
  61070. * @param origin the origin of the explosion
  61071. * @param radiusOrEventOptions the radius or the options of radial explosion
  61072. * @param strength the explosion strength
  61073. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61074. * @returns A physics radial explosion event, or null
  61075. */
  61076. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61077. /**
  61078. * Creates a gravitational field
  61079. * @param origin the origin of the explosion
  61080. * @param radiusOrEventOptions the radius or the options of radial explosion
  61081. * @param strength the explosion strength
  61082. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61083. * @returns A physics gravitational field event, or null
  61084. */
  61085. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61086. /**
  61087. * Creates a physics updraft event
  61088. * @param origin the origin of the updraft
  61089. * @param radiusOrEventOptions the radius or the options of the updraft
  61090. * @param strength the strength of the updraft
  61091. * @param height the height of the updraft
  61092. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61093. * @returns A physics updraft event, or null
  61094. */
  61095. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61096. /**
  61097. * Creates a physics vortex event
  61098. * @param origin the of the vortex
  61099. * @param radiusOrEventOptions the radius or the options of the vortex
  61100. * @param strength the strength of the vortex
  61101. * @param height the height of the vortex
  61102. * @returns a Physics vortex event, or null
  61103. * A physics vortex event or null
  61104. */
  61105. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61106. }
  61107. /**
  61108. * Represents a physics radial explosion event
  61109. */
  61110. class PhysicsRadialExplosionEvent {
  61111. private _scene;
  61112. private _options;
  61113. private _sphere;
  61114. private _dataFetched;
  61115. /**
  61116. * Initializes a radial explosioin event
  61117. * @param _scene BabylonJS scene
  61118. * @param _options The options for the vortex event
  61119. */
  61120. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61121. /**
  61122. * Returns the data related to the radial explosion event (sphere).
  61123. * @returns The radial explosion event data
  61124. */
  61125. getData(): PhysicsRadialExplosionEventData;
  61126. /**
  61127. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61128. * @param impostor A physics imposter
  61129. * @param origin the origin of the explosion
  61130. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61131. */
  61132. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61133. /**
  61134. * Triggers affecterd impostors callbacks
  61135. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61136. */
  61137. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61138. /**
  61139. * Disposes the sphere.
  61140. * @param force Specifies if the sphere should be disposed by force
  61141. */
  61142. dispose(force?: boolean): void;
  61143. /*** Helpers ***/
  61144. private _prepareSphere;
  61145. private _intersectsWithSphere;
  61146. }
  61147. /**
  61148. * Represents a gravitational field event
  61149. */
  61150. class PhysicsGravitationalFieldEvent {
  61151. private _physicsHelper;
  61152. private _scene;
  61153. private _origin;
  61154. private _options;
  61155. private _tickCallback;
  61156. private _sphere;
  61157. private _dataFetched;
  61158. /**
  61159. * Initializes the physics gravitational field event
  61160. * @param _physicsHelper A physics helper
  61161. * @param _scene BabylonJS scene
  61162. * @param _origin The origin position of the gravitational field event
  61163. * @param _options The options for the vortex event
  61164. */
  61165. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61166. /**
  61167. * Returns the data related to the gravitational field event (sphere).
  61168. * @returns A gravitational field event
  61169. */
  61170. getData(): PhysicsGravitationalFieldEventData;
  61171. /**
  61172. * Enables the gravitational field.
  61173. */
  61174. enable(): void;
  61175. /**
  61176. * Disables the gravitational field.
  61177. */
  61178. disable(): void;
  61179. /**
  61180. * Disposes the sphere.
  61181. * @param force The force to dispose from the gravitational field event
  61182. */
  61183. dispose(force?: boolean): void;
  61184. private _tick;
  61185. }
  61186. /**
  61187. * Represents a physics updraft event
  61188. */
  61189. class PhysicsUpdraftEvent {
  61190. private _scene;
  61191. private _origin;
  61192. private _options;
  61193. private _physicsEngine;
  61194. private _originTop;
  61195. private _originDirection;
  61196. private _tickCallback;
  61197. private _cylinder;
  61198. private _cylinderPosition;
  61199. private _dataFetched;
  61200. /**
  61201. * Initializes the physics updraft event
  61202. * @param _scene BabylonJS scene
  61203. * @param _origin The origin position of the updraft
  61204. * @param _options The options for the updraft event
  61205. */
  61206. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61207. /**
  61208. * Returns the data related to the updraft event (cylinder).
  61209. * @returns A physics updraft event
  61210. */
  61211. getData(): PhysicsUpdraftEventData;
  61212. /**
  61213. * Enables the updraft.
  61214. */
  61215. enable(): void;
  61216. /**
  61217. * Disables the updraft.
  61218. */
  61219. disable(): void;
  61220. /**
  61221. * Disposes the cylinder.
  61222. * @param force Specifies if the updraft should be disposed by force
  61223. */
  61224. dispose(force?: boolean): void;
  61225. private getImpostorHitData;
  61226. private _tick;
  61227. /*** Helpers ***/
  61228. private _prepareCylinder;
  61229. private _intersectsWithCylinder;
  61230. }
  61231. /**
  61232. * Represents a physics vortex event
  61233. */
  61234. class PhysicsVortexEvent {
  61235. private _scene;
  61236. private _origin;
  61237. private _options;
  61238. private _physicsEngine;
  61239. private _originTop;
  61240. private _tickCallback;
  61241. private _cylinder;
  61242. private _cylinderPosition;
  61243. private _dataFetched;
  61244. /**
  61245. * Initializes the physics vortex event
  61246. * @param _scene The BabylonJS scene
  61247. * @param _origin The origin position of the vortex
  61248. * @param _options The options for the vortex event
  61249. */
  61250. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61251. /**
  61252. * Returns the data related to the vortex event (cylinder).
  61253. * @returns The physics vortex event data
  61254. */
  61255. getData(): PhysicsVortexEventData;
  61256. /**
  61257. * Enables the vortex.
  61258. */
  61259. enable(): void;
  61260. /**
  61261. * Disables the cortex.
  61262. */
  61263. disable(): void;
  61264. /**
  61265. * Disposes the sphere.
  61266. * @param force
  61267. */
  61268. dispose(force?: boolean): void;
  61269. private getImpostorHitData;
  61270. private _tick;
  61271. /*** Helpers ***/
  61272. private _prepareCylinder;
  61273. private _intersectsWithCylinder;
  61274. }
  61275. /**
  61276. * Options fot the radial explosion event
  61277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61278. */
  61279. export class PhysicsRadialExplosionEventOptions {
  61280. /**
  61281. * The radius of the sphere for the radial explosion.
  61282. */
  61283. radius: number;
  61284. /**
  61285. * The strenth of the explosion.
  61286. */
  61287. strength: number;
  61288. /**
  61289. * The strenght of the force in correspondence to the distance of the affected object
  61290. */
  61291. falloff: PhysicsRadialImpulseFalloff;
  61292. /**
  61293. * Sphere options for the radial explosion.
  61294. */
  61295. sphere: {
  61296. segments: number;
  61297. diameter: number;
  61298. };
  61299. /**
  61300. * Sphere options for the radial explosion.
  61301. */
  61302. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61303. }
  61304. /**
  61305. * Options fot the updraft event
  61306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61307. */
  61308. export class PhysicsUpdraftEventOptions {
  61309. /**
  61310. * The radius of the cylinder for the vortex
  61311. */
  61312. radius: number;
  61313. /**
  61314. * The strenth of the updraft.
  61315. */
  61316. strength: number;
  61317. /**
  61318. * The height of the cylinder for the updraft.
  61319. */
  61320. height: number;
  61321. /**
  61322. * The mode for the the updraft.
  61323. */
  61324. updraftMode: PhysicsUpdraftMode;
  61325. }
  61326. /**
  61327. * Options fot the vortex event
  61328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61329. */
  61330. export class PhysicsVortexEventOptions {
  61331. /**
  61332. * The radius of the cylinder for the vortex
  61333. */
  61334. radius: number;
  61335. /**
  61336. * The strenth of the vortex.
  61337. */
  61338. strength: number;
  61339. /**
  61340. * The height of the cylinder for the vortex.
  61341. */
  61342. height: number;
  61343. /**
  61344. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61345. */
  61346. centripetalForceThreshold: number;
  61347. /**
  61348. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61349. */
  61350. centripetalForceMultiplier: number;
  61351. /**
  61352. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61353. */
  61354. centrifugalForceMultiplier: number;
  61355. /**
  61356. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61357. */
  61358. updraftForceMultiplier: number;
  61359. }
  61360. /**
  61361. * The strenght of the force in correspondence to the distance of the affected object
  61362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61363. */
  61364. export enum PhysicsRadialImpulseFalloff {
  61365. /** Defines that impulse is constant in strength across it's whole radius */
  61366. Constant = 0,
  61367. /** Defines that impulse gets weaker if it's further from the origin */
  61368. Linear = 1
  61369. }
  61370. /**
  61371. * The strength of the force in correspondence to the distance of the affected object
  61372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61373. */
  61374. export enum PhysicsUpdraftMode {
  61375. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61376. Center = 0,
  61377. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61378. Perpendicular = 1
  61379. }
  61380. /**
  61381. * Interface for a physics hit data
  61382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61383. */
  61384. export interface PhysicsHitData {
  61385. /**
  61386. * The force applied at the contact point
  61387. */
  61388. force: Vector3;
  61389. /**
  61390. * The contact point
  61391. */
  61392. contactPoint: Vector3;
  61393. /**
  61394. * The distance from the origin to the contact point
  61395. */
  61396. distanceFromOrigin: number;
  61397. }
  61398. /**
  61399. * Interface for radial explosion event data
  61400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61401. */
  61402. export interface PhysicsRadialExplosionEventData {
  61403. /**
  61404. * A sphere used for the radial explosion event
  61405. */
  61406. sphere: Mesh;
  61407. }
  61408. /**
  61409. * Interface for gravitational field event data
  61410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61411. */
  61412. export interface PhysicsGravitationalFieldEventData {
  61413. /**
  61414. * A sphere mesh used for the gravitational field event
  61415. */
  61416. sphere: Mesh;
  61417. }
  61418. /**
  61419. * Interface for updraft event data
  61420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61421. */
  61422. export interface PhysicsUpdraftEventData {
  61423. /**
  61424. * A cylinder used for the updraft event
  61425. */
  61426. cylinder: Mesh;
  61427. }
  61428. /**
  61429. * Interface for vortex event data
  61430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61431. */
  61432. export interface PhysicsVortexEventData {
  61433. /**
  61434. * A cylinder used for the vortex event
  61435. */
  61436. cylinder: Mesh;
  61437. }
  61438. /**
  61439. * Interface for an affected physics impostor
  61440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61441. */
  61442. export interface PhysicsAffectedImpostorWithData {
  61443. /**
  61444. * The impostor affected by the effect
  61445. */
  61446. impostor: PhysicsImpostor;
  61447. /**
  61448. * The data about the hit/horce from the explosion
  61449. */
  61450. hitData: PhysicsHitData;
  61451. }
  61452. }
  61453. declare module BABYLON {
  61454. /** @hidden */
  61455. export var blackAndWhitePixelShader: {
  61456. name: string;
  61457. shader: string;
  61458. };
  61459. }
  61460. declare module BABYLON {
  61461. /**
  61462. * Post process used to render in black and white
  61463. */
  61464. export class BlackAndWhitePostProcess extends PostProcess {
  61465. /**
  61466. * Linear about to convert he result to black and white (default: 1)
  61467. */
  61468. degree: number;
  61469. /**
  61470. * Creates a black and white post process
  61471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61472. * @param name The name of the effect.
  61473. * @param options The required width/height ratio to downsize to before computing the render pass.
  61474. * @param camera The camera to apply the render pass to.
  61475. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61476. * @param engine The engine which the post process will be applied. (default: current engine)
  61477. * @param reusable If the post process can be reused on the same frame. (default: false)
  61478. */
  61479. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61480. }
  61481. }
  61482. declare module BABYLON {
  61483. /**
  61484. * This represents a set of one or more post processes in Babylon.
  61485. * A post process can be used to apply a shader to a texture after it is rendered.
  61486. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61487. */
  61488. export class PostProcessRenderEffect {
  61489. private _postProcesses;
  61490. private _getPostProcesses;
  61491. private _singleInstance;
  61492. private _cameras;
  61493. private _indicesForCamera;
  61494. /**
  61495. * Name of the effect
  61496. * @hidden
  61497. */
  61498. _name: string;
  61499. /**
  61500. * Instantiates a post process render effect.
  61501. * A post process can be used to apply a shader to a texture after it is rendered.
  61502. * @param engine The engine the effect is tied to
  61503. * @param name The name of the effect
  61504. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61505. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61506. */
  61507. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61508. /**
  61509. * Checks if all the post processes in the effect are supported.
  61510. */
  61511. readonly isSupported: boolean;
  61512. /**
  61513. * Updates the current state of the effect
  61514. * @hidden
  61515. */
  61516. _update(): void;
  61517. /**
  61518. * Attaches the effect on cameras
  61519. * @param cameras The camera to attach to.
  61520. * @hidden
  61521. */
  61522. _attachCameras(cameras: Camera): void;
  61523. /**
  61524. * Attaches the effect on cameras
  61525. * @param cameras The camera to attach to.
  61526. * @hidden
  61527. */
  61528. _attachCameras(cameras: Camera[]): void;
  61529. /**
  61530. * Detaches the effect on cameras
  61531. * @param cameras The camera to detatch from.
  61532. * @hidden
  61533. */
  61534. _detachCameras(cameras: Camera): void;
  61535. /**
  61536. * Detatches the effect on cameras
  61537. * @param cameras The camera to detatch from.
  61538. * @hidden
  61539. */
  61540. _detachCameras(cameras: Camera[]): void;
  61541. /**
  61542. * Enables the effect on given cameras
  61543. * @param cameras The camera to enable.
  61544. * @hidden
  61545. */
  61546. _enable(cameras: Camera): void;
  61547. /**
  61548. * Enables the effect on given cameras
  61549. * @param cameras The camera to enable.
  61550. * @hidden
  61551. */
  61552. _enable(cameras: Nullable<Camera[]>): void;
  61553. /**
  61554. * Disables the effect on the given cameras
  61555. * @param cameras The camera to disable.
  61556. * @hidden
  61557. */
  61558. _disable(cameras: Camera): void;
  61559. /**
  61560. * Disables the effect on the given cameras
  61561. * @param cameras The camera to disable.
  61562. * @hidden
  61563. */
  61564. _disable(cameras: Nullable<Camera[]>): void;
  61565. /**
  61566. * Gets a list of the post processes contained in the effect.
  61567. * @param camera The camera to get the post processes on.
  61568. * @returns The list of the post processes in the effect.
  61569. */
  61570. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61571. }
  61572. }
  61573. declare module BABYLON {
  61574. /** @hidden */
  61575. export var extractHighlightsPixelShader: {
  61576. name: string;
  61577. shader: string;
  61578. };
  61579. }
  61580. declare module BABYLON {
  61581. /**
  61582. * 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.
  61583. */
  61584. export class ExtractHighlightsPostProcess extends PostProcess {
  61585. /**
  61586. * The luminance threshold, pixels below this value will be set to black.
  61587. */
  61588. threshold: number;
  61589. /** @hidden */
  61590. _exposure: number;
  61591. /**
  61592. * Post process which has the input texture to be used when performing highlight extraction
  61593. * @hidden
  61594. */
  61595. _inputPostProcess: Nullable<PostProcess>;
  61596. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61597. }
  61598. }
  61599. declare module BABYLON {
  61600. /** @hidden */
  61601. export var bloomMergePixelShader: {
  61602. name: string;
  61603. shader: string;
  61604. };
  61605. }
  61606. declare module BABYLON {
  61607. /**
  61608. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61609. */
  61610. export class BloomMergePostProcess extends PostProcess {
  61611. /** Weight of the bloom to be added to the original input. */
  61612. weight: number;
  61613. /**
  61614. * Creates a new instance of @see BloomMergePostProcess
  61615. * @param name The name of the effect.
  61616. * @param originalFromInput Post process which's input will be used for the merge.
  61617. * @param blurred Blurred highlights post process which's output will be used.
  61618. * @param weight Weight of the bloom to be added to the original input.
  61619. * @param options The required width/height ratio to downsize to before computing the render pass.
  61620. * @param camera The camera to apply the render pass to.
  61621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61622. * @param engine The engine which the post process will be applied. (default: current engine)
  61623. * @param reusable If the post process can be reused on the same frame. (default: false)
  61624. * @param textureType Type of textures used when performing the post process. (default: 0)
  61625. * @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)
  61626. */
  61627. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61628. /** Weight of the bloom to be added to the original input. */
  61629. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61630. }
  61631. }
  61632. declare module BABYLON {
  61633. /**
  61634. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61635. */
  61636. export class BloomEffect extends PostProcessRenderEffect {
  61637. private bloomScale;
  61638. /**
  61639. * @hidden Internal
  61640. */
  61641. _effects: Array<PostProcess>;
  61642. /**
  61643. * @hidden Internal
  61644. */
  61645. _downscale: ExtractHighlightsPostProcess;
  61646. private _blurX;
  61647. private _blurY;
  61648. private _merge;
  61649. /**
  61650. * The luminance threshold to find bright areas of the image to bloom.
  61651. */
  61652. threshold: number;
  61653. /**
  61654. * The strength of the bloom.
  61655. */
  61656. weight: number;
  61657. /**
  61658. * Specifies the size of the bloom blur kernel, relative to the final output size
  61659. */
  61660. kernel: number;
  61661. /**
  61662. * Creates a new instance of @see BloomEffect
  61663. * @param scene The scene the effect belongs to.
  61664. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61665. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61666. * @param bloomWeight The the strength of bloom.
  61667. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61668. * @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)
  61669. */
  61670. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61671. /**
  61672. * Disposes each of the internal effects for a given camera.
  61673. * @param camera The camera to dispose the effect on.
  61674. */
  61675. disposeEffects(camera: Camera): void;
  61676. /**
  61677. * @hidden Internal
  61678. */
  61679. _updateEffects(): void;
  61680. /**
  61681. * Internal
  61682. * @returns if all the contained post processes are ready.
  61683. * @hidden
  61684. */
  61685. _isReady(): boolean;
  61686. }
  61687. }
  61688. declare module BABYLON {
  61689. /** @hidden */
  61690. export var chromaticAberrationPixelShader: {
  61691. name: string;
  61692. shader: string;
  61693. };
  61694. }
  61695. declare module BABYLON {
  61696. /**
  61697. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61698. */
  61699. export class ChromaticAberrationPostProcess extends PostProcess {
  61700. /**
  61701. * The amount of seperation of rgb channels (default: 30)
  61702. */
  61703. aberrationAmount: number;
  61704. /**
  61705. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61706. */
  61707. radialIntensity: number;
  61708. /**
  61709. * 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))
  61710. */
  61711. direction: Vector2;
  61712. /**
  61713. * 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))
  61714. */
  61715. centerPosition: Vector2;
  61716. /**
  61717. * Creates a new instance ChromaticAberrationPostProcess
  61718. * @param name The name of the effect.
  61719. * @param screenWidth The width of the screen to apply the effect on.
  61720. * @param screenHeight The height of the screen to apply the effect on.
  61721. * @param options The required width/height ratio to downsize to before computing the render pass.
  61722. * @param camera The camera to apply the render pass to.
  61723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61724. * @param engine The engine which the post process will be applied. (default: current engine)
  61725. * @param reusable If the post process can be reused on the same frame. (default: false)
  61726. * @param textureType Type of textures used when performing the post process. (default: 0)
  61727. * @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)
  61728. */
  61729. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61730. }
  61731. }
  61732. declare module BABYLON {
  61733. /** @hidden */
  61734. export var circleOfConfusionPixelShader: {
  61735. name: string;
  61736. shader: string;
  61737. };
  61738. }
  61739. declare module BABYLON {
  61740. /**
  61741. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61742. */
  61743. export class CircleOfConfusionPostProcess extends PostProcess {
  61744. /**
  61745. * 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.
  61746. */
  61747. lensSize: number;
  61748. /**
  61749. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61750. */
  61751. fStop: number;
  61752. /**
  61753. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61754. */
  61755. focusDistance: number;
  61756. /**
  61757. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61758. */
  61759. focalLength: number;
  61760. private _depthTexture;
  61761. /**
  61762. * Creates a new instance CircleOfConfusionPostProcess
  61763. * @param name The name of the effect.
  61764. * @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.
  61765. * @param options The required width/height ratio to downsize to before computing the render pass.
  61766. * @param camera The camera to apply the render pass to.
  61767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61768. * @param engine The engine which the post process will be applied. (default: current engine)
  61769. * @param reusable If the post process can be reused on the same frame. (default: false)
  61770. * @param textureType Type of textures used when performing the post process. (default: 0)
  61771. * @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)
  61772. */
  61773. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61774. /**
  61775. * 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.
  61776. */
  61777. depthTexture: RenderTargetTexture;
  61778. }
  61779. }
  61780. declare module BABYLON {
  61781. /** @hidden */
  61782. export var colorCorrectionPixelShader: {
  61783. name: string;
  61784. shader: string;
  61785. };
  61786. }
  61787. declare module BABYLON {
  61788. /**
  61789. *
  61790. * This post-process allows the modification of rendered colors by using
  61791. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61792. *
  61793. * The object needs to be provided an url to a texture containing the color
  61794. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61795. * Use an image editing software to tweak the LUT to match your needs.
  61796. *
  61797. * For an example of a color LUT, see here:
  61798. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61799. * For explanations on color grading, see here:
  61800. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61801. *
  61802. */
  61803. export class ColorCorrectionPostProcess extends PostProcess {
  61804. private _colorTableTexture;
  61805. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61806. }
  61807. }
  61808. declare module BABYLON {
  61809. /** @hidden */
  61810. export var convolutionPixelShader: {
  61811. name: string;
  61812. shader: string;
  61813. };
  61814. }
  61815. declare module BABYLON {
  61816. /**
  61817. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61818. * input texture to perform effects such as edge detection or sharpening
  61819. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61820. */
  61821. export class ConvolutionPostProcess extends PostProcess {
  61822. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61823. kernel: number[];
  61824. /**
  61825. * Creates a new instance ConvolutionPostProcess
  61826. * @param name The name of the effect.
  61827. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61828. * @param options The required width/height ratio to downsize to before computing the render pass.
  61829. * @param camera The camera to apply the render pass to.
  61830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61831. * @param engine The engine which the post process will be applied. (default: current engine)
  61832. * @param reusable If the post process can be reused on the same frame. (default: false)
  61833. * @param textureType Type of textures used when performing the post process. (default: 0)
  61834. */
  61835. constructor(name: string,
  61836. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61837. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61838. /**
  61839. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61840. */
  61841. static EdgeDetect0Kernel: number[];
  61842. /**
  61843. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61844. */
  61845. static EdgeDetect1Kernel: number[];
  61846. /**
  61847. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61848. */
  61849. static EdgeDetect2Kernel: number[];
  61850. /**
  61851. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61852. */
  61853. static SharpenKernel: number[];
  61854. /**
  61855. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61856. */
  61857. static EmbossKernel: number[];
  61858. /**
  61859. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61860. */
  61861. static GaussianKernel: number[];
  61862. }
  61863. }
  61864. declare module BABYLON {
  61865. /**
  61866. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61867. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61868. * based on samples that have a large difference in distance than the center pixel.
  61869. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61870. */
  61871. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61872. direction: Vector2;
  61873. /**
  61874. * Creates a new instance CircleOfConfusionPostProcess
  61875. * @param name The name of the effect.
  61876. * @param scene The scene the effect belongs to.
  61877. * @param direction The direction the blur should be applied.
  61878. * @param kernel The size of the kernel used to blur.
  61879. * @param options The required width/height ratio to downsize to before computing the render pass.
  61880. * @param camera The camera to apply the render pass to.
  61881. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61882. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61884. * @param engine The engine which the post process will be applied. (default: current engine)
  61885. * @param reusable If the post process can be reused on the same frame. (default: false)
  61886. * @param textureType Type of textures used when performing the post process. (default: 0)
  61887. * @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)
  61888. */
  61889. 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);
  61890. }
  61891. }
  61892. declare module BABYLON {
  61893. /** @hidden */
  61894. export var depthOfFieldMergePixelShader: {
  61895. name: string;
  61896. shader: string;
  61897. };
  61898. }
  61899. declare module BABYLON {
  61900. /**
  61901. * Options to be set when merging outputs from the default pipeline.
  61902. */
  61903. export class DepthOfFieldMergePostProcessOptions {
  61904. /**
  61905. * The original image to merge on top of
  61906. */
  61907. originalFromInput: PostProcess;
  61908. /**
  61909. * Parameters to perform the merge of the depth of field effect
  61910. */
  61911. depthOfField?: {
  61912. circleOfConfusion: PostProcess;
  61913. blurSteps: Array<PostProcess>;
  61914. };
  61915. /**
  61916. * Parameters to perform the merge of bloom effect
  61917. */
  61918. bloom?: {
  61919. blurred: PostProcess;
  61920. weight: number;
  61921. };
  61922. }
  61923. /**
  61924. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61925. */
  61926. export class DepthOfFieldMergePostProcess extends PostProcess {
  61927. private blurSteps;
  61928. /**
  61929. * Creates a new instance of DepthOfFieldMergePostProcess
  61930. * @param name The name of the effect.
  61931. * @param originalFromInput Post process which's input will be used for the merge.
  61932. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61933. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61934. * @param options The required width/height ratio to downsize to before computing the render pass.
  61935. * @param camera The camera to apply the render pass to.
  61936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61937. * @param engine The engine which the post process will be applied. (default: current engine)
  61938. * @param reusable If the post process can be reused on the same frame. (default: false)
  61939. * @param textureType Type of textures used when performing the post process. (default: 0)
  61940. * @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)
  61941. */
  61942. 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);
  61943. /**
  61944. * Updates the effect with the current post process compile time values and recompiles the shader.
  61945. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61946. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61947. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61948. * @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
  61949. * @param onCompiled Called when the shader has been compiled.
  61950. * @param onError Called if there is an error when compiling a shader.
  61951. */
  61952. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61953. }
  61954. }
  61955. declare module BABYLON {
  61956. /**
  61957. * Specifies the level of max blur that should be applied when using the depth of field effect
  61958. */
  61959. export enum DepthOfFieldEffectBlurLevel {
  61960. /**
  61961. * Subtle blur
  61962. */
  61963. Low = 0,
  61964. /**
  61965. * Medium blur
  61966. */
  61967. Medium = 1,
  61968. /**
  61969. * Large blur
  61970. */
  61971. High = 2
  61972. }
  61973. /**
  61974. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61975. */
  61976. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61977. private _circleOfConfusion;
  61978. /**
  61979. * @hidden Internal, blurs from high to low
  61980. */
  61981. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61982. private _depthOfFieldBlurY;
  61983. private _dofMerge;
  61984. /**
  61985. * @hidden Internal post processes in depth of field effect
  61986. */
  61987. _effects: Array<PostProcess>;
  61988. /**
  61989. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61990. */
  61991. focalLength: number;
  61992. /**
  61993. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61994. */
  61995. fStop: number;
  61996. /**
  61997. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61998. */
  61999. focusDistance: number;
  62000. /**
  62001. * 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.
  62002. */
  62003. lensSize: number;
  62004. /**
  62005. * Creates a new instance DepthOfFieldEffect
  62006. * @param scene The scene the effect belongs to.
  62007. * @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.
  62008. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62009. * @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)
  62010. */
  62011. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62012. /**
  62013. * Get the current class name of the current effet
  62014. * @returns "DepthOfFieldEffect"
  62015. */
  62016. getClassName(): string;
  62017. /**
  62018. * 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.
  62019. */
  62020. depthTexture: RenderTargetTexture;
  62021. /**
  62022. * Disposes each of the internal effects for a given camera.
  62023. * @param camera The camera to dispose the effect on.
  62024. */
  62025. disposeEffects(camera: Camera): void;
  62026. /**
  62027. * @hidden Internal
  62028. */
  62029. _updateEffects(): void;
  62030. /**
  62031. * Internal
  62032. * @returns if all the contained post processes are ready.
  62033. * @hidden
  62034. */
  62035. _isReady(): boolean;
  62036. }
  62037. }
  62038. declare module BABYLON {
  62039. /** @hidden */
  62040. export var displayPassPixelShader: {
  62041. name: string;
  62042. shader: string;
  62043. };
  62044. }
  62045. declare module BABYLON {
  62046. /**
  62047. * DisplayPassPostProcess which produces an output the same as it's input
  62048. */
  62049. export class DisplayPassPostProcess extends PostProcess {
  62050. /**
  62051. * Creates the DisplayPassPostProcess
  62052. * @param name The name of the effect.
  62053. * @param options The required width/height ratio to downsize to before computing the render pass.
  62054. * @param camera The camera to apply the render pass to.
  62055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62056. * @param engine The engine which the post process will be applied. (default: current engine)
  62057. * @param reusable If the post process can be reused on the same frame. (default: false)
  62058. */
  62059. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62060. }
  62061. }
  62062. declare module BABYLON {
  62063. /** @hidden */
  62064. export var filterPixelShader: {
  62065. name: string;
  62066. shader: string;
  62067. };
  62068. }
  62069. declare module BABYLON {
  62070. /**
  62071. * Applies a kernel filter to the image
  62072. */
  62073. export class FilterPostProcess extends PostProcess {
  62074. /** The matrix to be applied to the image */
  62075. kernelMatrix: Matrix;
  62076. /**
  62077. *
  62078. * @param name The name of the effect.
  62079. * @param kernelMatrix The matrix to be applied to the image
  62080. * @param options The required width/height ratio to downsize to before computing the render pass.
  62081. * @param camera The camera to apply the render pass to.
  62082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62083. * @param engine The engine which the post process will be applied. (default: current engine)
  62084. * @param reusable If the post process can be reused on the same frame. (default: false)
  62085. */
  62086. constructor(name: string,
  62087. /** The matrix to be applied to the image */
  62088. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62089. }
  62090. }
  62091. declare module BABYLON {
  62092. /** @hidden */
  62093. export var fxaaPixelShader: {
  62094. name: string;
  62095. shader: string;
  62096. };
  62097. }
  62098. declare module BABYLON {
  62099. /** @hidden */
  62100. export var fxaaVertexShader: {
  62101. name: string;
  62102. shader: string;
  62103. };
  62104. }
  62105. declare module BABYLON {
  62106. /**
  62107. * Fxaa post process
  62108. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62109. */
  62110. export class FxaaPostProcess extends PostProcess {
  62111. /** @hidden */
  62112. texelWidth: number;
  62113. /** @hidden */
  62114. texelHeight: number;
  62115. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62116. private _getDefines;
  62117. }
  62118. }
  62119. declare module BABYLON {
  62120. /** @hidden */
  62121. export var grainPixelShader: {
  62122. name: string;
  62123. shader: string;
  62124. };
  62125. }
  62126. declare module BABYLON {
  62127. /**
  62128. * The GrainPostProcess adds noise to the image at mid luminance levels
  62129. */
  62130. export class GrainPostProcess extends PostProcess {
  62131. /**
  62132. * The intensity of the grain added (default: 30)
  62133. */
  62134. intensity: number;
  62135. /**
  62136. * If the grain should be randomized on every frame
  62137. */
  62138. animated: boolean;
  62139. /**
  62140. * Creates a new instance of @see GrainPostProcess
  62141. * @param name The name of the effect.
  62142. * @param options The required width/height ratio to downsize to before computing the render pass.
  62143. * @param camera The camera to apply the render pass to.
  62144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62145. * @param engine The engine which the post process will be applied. (default: current engine)
  62146. * @param reusable If the post process can be reused on the same frame. (default: false)
  62147. * @param textureType Type of textures used when performing the post process. (default: 0)
  62148. * @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)
  62149. */
  62150. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62151. }
  62152. }
  62153. declare module BABYLON {
  62154. /** @hidden */
  62155. export var highlightsPixelShader: {
  62156. name: string;
  62157. shader: string;
  62158. };
  62159. }
  62160. declare module BABYLON {
  62161. /**
  62162. * Extracts highlights from the image
  62163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62164. */
  62165. export class HighlightsPostProcess extends PostProcess {
  62166. /**
  62167. * Extracts highlights from the image
  62168. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62169. * @param name The name of the effect.
  62170. * @param options The required width/height ratio to downsize to before computing the render pass.
  62171. * @param camera The camera to apply the render pass to.
  62172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62173. * @param engine The engine which the post process will be applied. (default: current engine)
  62174. * @param reusable If the post process can be reused on the same frame. (default: false)
  62175. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62176. */
  62177. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62178. }
  62179. }
  62180. declare module BABYLON {
  62181. /** @hidden */
  62182. export var mrtFragmentDeclaration: {
  62183. name: string;
  62184. shader: string;
  62185. };
  62186. }
  62187. declare module BABYLON {
  62188. /** @hidden */
  62189. export var geometryPixelShader: {
  62190. name: string;
  62191. shader: string;
  62192. };
  62193. }
  62194. declare module BABYLON {
  62195. /** @hidden */
  62196. export var geometryVertexShader: {
  62197. name: string;
  62198. shader: string;
  62199. };
  62200. }
  62201. declare module BABYLON {
  62202. /** @hidden */
  62203. interface ISavedTransformationMatrix {
  62204. world: Matrix;
  62205. viewProjection: Matrix;
  62206. }
  62207. /**
  62208. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62209. */
  62210. export class GeometryBufferRenderer {
  62211. /**
  62212. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62213. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62214. */
  62215. static readonly POSITION_TEXTURE_TYPE: number;
  62216. /**
  62217. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62218. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62219. */
  62220. static readonly VELOCITY_TEXTURE_TYPE: number;
  62221. /**
  62222. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62223. * in order to compute objects velocities when enableVelocity is set to "true"
  62224. * @hidden
  62225. */
  62226. _previousTransformationMatrices: {
  62227. [index: number]: ISavedTransformationMatrix;
  62228. };
  62229. /**
  62230. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62231. * in order to compute objects velocities when enableVelocity is set to "true"
  62232. * @hidden
  62233. */
  62234. _previousBonesTransformationMatrices: {
  62235. [index: number]: Float32Array;
  62236. };
  62237. /**
  62238. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62239. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62240. */
  62241. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62242. private _scene;
  62243. private _multiRenderTarget;
  62244. private _ratio;
  62245. private _enablePosition;
  62246. private _enableVelocity;
  62247. private _positionIndex;
  62248. private _velocityIndex;
  62249. protected _effect: Effect;
  62250. protected _cachedDefines: string;
  62251. /**
  62252. * Set the render list (meshes to be rendered) used in the G buffer.
  62253. */
  62254. renderList: Mesh[];
  62255. /**
  62256. * Gets wether or not G buffer are supported by the running hardware.
  62257. * This requires draw buffer supports
  62258. */
  62259. readonly isSupported: boolean;
  62260. /**
  62261. * Returns the index of the given texture type in the G-Buffer textures array
  62262. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62263. * @returns the index of the given texture type in the G-Buffer textures array
  62264. */
  62265. getTextureIndex(textureType: number): number;
  62266. /**
  62267. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62268. */
  62269. /**
  62270. * Sets whether or not objects positions are enabled for the G buffer.
  62271. */
  62272. enablePosition: boolean;
  62273. /**
  62274. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62275. */
  62276. /**
  62277. * Sets wether or not objects velocities are enabled for the G buffer.
  62278. */
  62279. enableVelocity: boolean;
  62280. /**
  62281. * Gets the scene associated with the buffer.
  62282. */
  62283. readonly scene: Scene;
  62284. /**
  62285. * Gets the ratio used by the buffer during its creation.
  62286. * How big is the buffer related to the main canvas.
  62287. */
  62288. readonly ratio: number;
  62289. /** @hidden */
  62290. static _SceneComponentInitialization: (scene: Scene) => void;
  62291. /**
  62292. * Creates a new G Buffer for the scene
  62293. * @param scene The scene the buffer belongs to
  62294. * @param ratio How big is the buffer related to the main canvas.
  62295. */
  62296. constructor(scene: Scene, ratio?: number);
  62297. /**
  62298. * Checks wether everything is ready to render a submesh to the G buffer.
  62299. * @param subMesh the submesh to check readiness for
  62300. * @param useInstances is the mesh drawn using instance or not
  62301. * @returns true if ready otherwise false
  62302. */
  62303. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62304. /**
  62305. * Gets the current underlying G Buffer.
  62306. * @returns the buffer
  62307. */
  62308. getGBuffer(): MultiRenderTarget;
  62309. /**
  62310. * Gets the number of samples used to render the buffer (anti aliasing).
  62311. */
  62312. /**
  62313. * Sets the number of samples used to render the buffer (anti aliasing).
  62314. */
  62315. samples: number;
  62316. /**
  62317. * Disposes the renderer and frees up associated resources.
  62318. */
  62319. dispose(): void;
  62320. protected _createRenderTargets(): void;
  62321. private _copyBonesTransformationMatrices;
  62322. }
  62323. }
  62324. declare module BABYLON {
  62325. interface Scene {
  62326. /** @hidden (Backing field) */
  62327. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62328. /**
  62329. * Gets or Sets the current geometry buffer associated to the scene.
  62330. */
  62331. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62332. /**
  62333. * Enables a GeometryBufferRender and associates it with the scene
  62334. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62335. * @returns the GeometryBufferRenderer
  62336. */
  62337. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62338. /**
  62339. * Disables the GeometryBufferRender associated with the scene
  62340. */
  62341. disableGeometryBufferRenderer(): void;
  62342. }
  62343. /**
  62344. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62345. * in several rendering techniques.
  62346. */
  62347. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62348. /**
  62349. * The component name helpful to identify the component in the list of scene components.
  62350. */
  62351. readonly name: string;
  62352. /**
  62353. * The scene the component belongs to.
  62354. */
  62355. scene: Scene;
  62356. /**
  62357. * Creates a new instance of the component for the given scene
  62358. * @param scene Defines the scene to register the component in
  62359. */
  62360. constructor(scene: Scene);
  62361. /**
  62362. * Registers the component in a given scene
  62363. */
  62364. register(): void;
  62365. /**
  62366. * Rebuilds the elements related to this component in case of
  62367. * context lost for instance.
  62368. */
  62369. rebuild(): void;
  62370. /**
  62371. * Disposes the component and the associated ressources
  62372. */
  62373. dispose(): void;
  62374. private _gatherRenderTargets;
  62375. }
  62376. }
  62377. declare module BABYLON {
  62378. /** @hidden */
  62379. export var motionBlurPixelShader: {
  62380. name: string;
  62381. shader: string;
  62382. };
  62383. }
  62384. declare module BABYLON {
  62385. /**
  62386. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62387. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62388. * As an example, all you have to do is to create the post-process:
  62389. * var mb = new BABYLON.MotionBlurPostProcess(
  62390. * 'mb', // The name of the effect.
  62391. * scene, // The scene containing the objects to blur according to their velocity.
  62392. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62393. * camera // The camera to apply the render pass to.
  62394. * );
  62395. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62396. */
  62397. export class MotionBlurPostProcess extends PostProcess {
  62398. /**
  62399. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62400. */
  62401. motionStrength: number;
  62402. /**
  62403. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62404. */
  62405. /**
  62406. * Sets the number of iterations to be used for motion blur quality
  62407. */
  62408. motionBlurSamples: number;
  62409. private _motionBlurSamples;
  62410. private _geometryBufferRenderer;
  62411. /**
  62412. * Creates a new instance MotionBlurPostProcess
  62413. * @param name The name of the effect.
  62414. * @param scene The scene containing the objects to blur according to their velocity.
  62415. * @param options The required width/height ratio to downsize to before computing the render pass.
  62416. * @param camera The camera to apply the render pass to.
  62417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62418. * @param engine The engine which the post process will be applied. (default: current engine)
  62419. * @param reusable If the post process can be reused on the same frame. (default: false)
  62420. * @param textureType Type of textures used when performing the post process. (default: 0)
  62421. * @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)
  62422. */
  62423. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62424. /**
  62425. * Excludes the given skinned mesh from computing bones velocities.
  62426. * 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.
  62427. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62428. */
  62429. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62430. /**
  62431. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62432. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62433. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62434. */
  62435. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62436. /**
  62437. * Disposes the post process.
  62438. * @param camera The camera to dispose the post process on.
  62439. */
  62440. dispose(camera?: Camera): void;
  62441. }
  62442. }
  62443. declare module BABYLON {
  62444. /** @hidden */
  62445. export var refractionPixelShader: {
  62446. name: string;
  62447. shader: string;
  62448. };
  62449. }
  62450. declare module BABYLON {
  62451. /**
  62452. * Post process which applies a refractin texture
  62453. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62454. */
  62455. export class RefractionPostProcess extends PostProcess {
  62456. /** the base color of the refraction (used to taint the rendering) */
  62457. color: Color3;
  62458. /** simulated refraction depth */
  62459. depth: number;
  62460. /** the coefficient of the base color (0 to remove base color tainting) */
  62461. colorLevel: number;
  62462. private _refTexture;
  62463. private _ownRefractionTexture;
  62464. /**
  62465. * Gets or sets the refraction texture
  62466. * Please note that you are responsible for disposing the texture if you set it manually
  62467. */
  62468. refractionTexture: Texture;
  62469. /**
  62470. * Initializes the RefractionPostProcess
  62471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62472. * @param name The name of the effect.
  62473. * @param refractionTextureUrl Url of the refraction texture to use
  62474. * @param color the base color of the refraction (used to taint the rendering)
  62475. * @param depth simulated refraction depth
  62476. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62477. * @param camera The camera to apply the render pass to.
  62478. * @param options The required width/height ratio to downsize to before computing the render pass.
  62479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62480. * @param engine The engine which the post process will be applied. (default: current engine)
  62481. * @param reusable If the post process can be reused on the same frame. (default: false)
  62482. */
  62483. constructor(name: string, refractionTextureUrl: string,
  62484. /** the base color of the refraction (used to taint the rendering) */
  62485. color: Color3,
  62486. /** simulated refraction depth */
  62487. depth: number,
  62488. /** the coefficient of the base color (0 to remove base color tainting) */
  62489. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62490. /**
  62491. * Disposes of the post process
  62492. * @param camera Camera to dispose post process on
  62493. */
  62494. dispose(camera: Camera): void;
  62495. }
  62496. }
  62497. declare module BABYLON {
  62498. /** @hidden */
  62499. export var sharpenPixelShader: {
  62500. name: string;
  62501. shader: string;
  62502. };
  62503. }
  62504. declare module BABYLON {
  62505. /**
  62506. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62507. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62508. */
  62509. export class SharpenPostProcess extends PostProcess {
  62510. /**
  62511. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62512. */
  62513. colorAmount: number;
  62514. /**
  62515. * How much sharpness should be applied (default: 0.3)
  62516. */
  62517. edgeAmount: number;
  62518. /**
  62519. * Creates a new instance ConvolutionPostProcess
  62520. * @param name The name of the effect.
  62521. * @param options The required width/height ratio to downsize to before computing the render pass.
  62522. * @param camera The camera to apply the render pass to.
  62523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62524. * @param engine The engine which the post process will be applied. (default: current engine)
  62525. * @param reusable If the post process can be reused on the same frame. (default: false)
  62526. * @param textureType Type of textures used when performing the post process. (default: 0)
  62527. * @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)
  62528. */
  62529. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62530. }
  62531. }
  62532. declare module BABYLON {
  62533. /**
  62534. * PostProcessRenderPipeline
  62535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62536. */
  62537. export class PostProcessRenderPipeline {
  62538. private engine;
  62539. private _renderEffects;
  62540. private _renderEffectsForIsolatedPass;
  62541. /**
  62542. * List of inspectable custom properties (used by the Inspector)
  62543. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62544. */
  62545. inspectableCustomProperties: IInspectable[];
  62546. /**
  62547. * @hidden
  62548. */
  62549. protected _cameras: Camera[];
  62550. /** @hidden */
  62551. _name: string;
  62552. /**
  62553. * Gets pipeline name
  62554. */
  62555. readonly name: string;
  62556. /** Gets the list of attached cameras */
  62557. readonly cameras: Camera[];
  62558. /**
  62559. * Initializes a PostProcessRenderPipeline
  62560. * @param engine engine to add the pipeline to
  62561. * @param name name of the pipeline
  62562. */
  62563. constructor(engine: Engine, name: string);
  62564. /**
  62565. * Gets the class name
  62566. * @returns "PostProcessRenderPipeline"
  62567. */
  62568. getClassName(): string;
  62569. /**
  62570. * If all the render effects in the pipeline are supported
  62571. */
  62572. readonly isSupported: boolean;
  62573. /**
  62574. * Adds an effect to the pipeline
  62575. * @param renderEffect the effect to add
  62576. */
  62577. addEffect(renderEffect: PostProcessRenderEffect): void;
  62578. /** @hidden */
  62579. _rebuild(): void;
  62580. /** @hidden */
  62581. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62582. /** @hidden */
  62583. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62584. /** @hidden */
  62585. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62586. /** @hidden */
  62587. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62588. /** @hidden */
  62589. _attachCameras(cameras: Camera, unique: boolean): void;
  62590. /** @hidden */
  62591. _attachCameras(cameras: Camera[], unique: boolean): void;
  62592. /** @hidden */
  62593. _detachCameras(cameras: Camera): void;
  62594. /** @hidden */
  62595. _detachCameras(cameras: Nullable<Camera[]>): void;
  62596. /** @hidden */
  62597. _update(): void;
  62598. /** @hidden */
  62599. _reset(): void;
  62600. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62601. /**
  62602. * Disposes of the pipeline
  62603. */
  62604. dispose(): void;
  62605. }
  62606. }
  62607. declare module BABYLON {
  62608. /**
  62609. * PostProcessRenderPipelineManager class
  62610. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62611. */
  62612. export class PostProcessRenderPipelineManager {
  62613. private _renderPipelines;
  62614. /**
  62615. * Initializes a PostProcessRenderPipelineManager
  62616. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62617. */
  62618. constructor();
  62619. /**
  62620. * Gets the list of supported render pipelines
  62621. */
  62622. readonly supportedPipelines: PostProcessRenderPipeline[];
  62623. /**
  62624. * Adds a pipeline to the manager
  62625. * @param renderPipeline The pipeline to add
  62626. */
  62627. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62628. /**
  62629. * Attaches a camera to the pipeline
  62630. * @param renderPipelineName The name of the pipeline to attach to
  62631. * @param cameras the camera to attach
  62632. * @param unique if the camera can be attached multiple times to the pipeline
  62633. */
  62634. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62635. /**
  62636. * Detaches a camera from the pipeline
  62637. * @param renderPipelineName The name of the pipeline to detach from
  62638. * @param cameras the camera to detach
  62639. */
  62640. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62641. /**
  62642. * Enables an effect by name on a pipeline
  62643. * @param renderPipelineName the name of the pipeline to enable the effect in
  62644. * @param renderEffectName the name of the effect to enable
  62645. * @param cameras the cameras that the effect should be enabled on
  62646. */
  62647. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62648. /**
  62649. * Disables an effect by name on a pipeline
  62650. * @param renderPipelineName the name of the pipeline to disable the effect in
  62651. * @param renderEffectName the name of the effect to disable
  62652. * @param cameras the cameras that the effect should be disabled on
  62653. */
  62654. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62655. /**
  62656. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62657. */
  62658. update(): void;
  62659. /** @hidden */
  62660. _rebuild(): void;
  62661. /**
  62662. * Disposes of the manager and pipelines
  62663. */
  62664. dispose(): void;
  62665. }
  62666. }
  62667. declare module BABYLON {
  62668. interface Scene {
  62669. /** @hidden (Backing field) */
  62670. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62671. /**
  62672. * Gets the postprocess render pipeline manager
  62673. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62674. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62675. */
  62676. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62677. }
  62678. /**
  62679. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62680. */
  62681. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62682. /**
  62683. * The component name helpfull to identify the component in the list of scene components.
  62684. */
  62685. readonly name: string;
  62686. /**
  62687. * The scene the component belongs to.
  62688. */
  62689. scene: Scene;
  62690. /**
  62691. * Creates a new instance of the component for the given scene
  62692. * @param scene Defines the scene to register the component in
  62693. */
  62694. constructor(scene: Scene);
  62695. /**
  62696. * Registers the component in a given scene
  62697. */
  62698. register(): void;
  62699. /**
  62700. * Rebuilds the elements related to this component in case of
  62701. * context lost for instance.
  62702. */
  62703. rebuild(): void;
  62704. /**
  62705. * Disposes the component and the associated ressources
  62706. */
  62707. dispose(): void;
  62708. private _gatherRenderTargets;
  62709. }
  62710. }
  62711. declare module BABYLON {
  62712. /**
  62713. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62714. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62715. */
  62716. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62717. private _scene;
  62718. private _camerasToBeAttached;
  62719. /**
  62720. * ID of the sharpen post process,
  62721. */
  62722. private readonly SharpenPostProcessId;
  62723. /**
  62724. * @ignore
  62725. * ID of the image processing post process;
  62726. */
  62727. readonly ImageProcessingPostProcessId: string;
  62728. /**
  62729. * @ignore
  62730. * ID of the Fast Approximate Anti-Aliasing post process;
  62731. */
  62732. readonly FxaaPostProcessId: string;
  62733. /**
  62734. * ID of the chromatic aberration post process,
  62735. */
  62736. private readonly ChromaticAberrationPostProcessId;
  62737. /**
  62738. * ID of the grain post process
  62739. */
  62740. private readonly GrainPostProcessId;
  62741. /**
  62742. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62743. */
  62744. sharpen: SharpenPostProcess;
  62745. private _sharpenEffect;
  62746. private bloom;
  62747. /**
  62748. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62749. */
  62750. depthOfField: DepthOfFieldEffect;
  62751. /**
  62752. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62753. */
  62754. fxaa: FxaaPostProcess;
  62755. /**
  62756. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62757. */
  62758. imageProcessing: ImageProcessingPostProcess;
  62759. /**
  62760. * Chromatic aberration post process which will shift rgb colors in the image
  62761. */
  62762. chromaticAberration: ChromaticAberrationPostProcess;
  62763. private _chromaticAberrationEffect;
  62764. /**
  62765. * Grain post process which add noise to the image
  62766. */
  62767. grain: GrainPostProcess;
  62768. private _grainEffect;
  62769. /**
  62770. * Glow post process which adds a glow to emissive areas of the image
  62771. */
  62772. private _glowLayer;
  62773. /**
  62774. * Animations which can be used to tweak settings over a period of time
  62775. */
  62776. animations: Animation[];
  62777. private _imageProcessingConfigurationObserver;
  62778. private _sharpenEnabled;
  62779. private _bloomEnabled;
  62780. private _depthOfFieldEnabled;
  62781. private _depthOfFieldBlurLevel;
  62782. private _fxaaEnabled;
  62783. private _imageProcessingEnabled;
  62784. private _defaultPipelineTextureType;
  62785. private _bloomScale;
  62786. private _chromaticAberrationEnabled;
  62787. private _grainEnabled;
  62788. private _buildAllowed;
  62789. /**
  62790. * Gets active scene
  62791. */
  62792. readonly scene: Scene;
  62793. /**
  62794. * Enable or disable the sharpen process from the pipeline
  62795. */
  62796. sharpenEnabled: boolean;
  62797. private _resizeObserver;
  62798. private _hardwareScaleLevel;
  62799. private _bloomKernel;
  62800. /**
  62801. * Specifies the size of the bloom blur kernel, relative to the final output size
  62802. */
  62803. bloomKernel: number;
  62804. /**
  62805. * Specifies the weight of the bloom in the final rendering
  62806. */
  62807. private _bloomWeight;
  62808. /**
  62809. * Specifies the luma threshold for the area that will be blurred by the bloom
  62810. */
  62811. private _bloomThreshold;
  62812. private _hdr;
  62813. /**
  62814. * The strength of the bloom.
  62815. */
  62816. bloomWeight: number;
  62817. /**
  62818. * The strength of the bloom.
  62819. */
  62820. bloomThreshold: number;
  62821. /**
  62822. * The scale of the bloom, lower value will provide better performance.
  62823. */
  62824. bloomScale: number;
  62825. /**
  62826. * Enable or disable the bloom from the pipeline
  62827. */
  62828. bloomEnabled: boolean;
  62829. private _rebuildBloom;
  62830. /**
  62831. * If the depth of field is enabled.
  62832. */
  62833. depthOfFieldEnabled: boolean;
  62834. /**
  62835. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62836. */
  62837. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62838. /**
  62839. * If the anti aliasing is enabled.
  62840. */
  62841. fxaaEnabled: boolean;
  62842. private _samples;
  62843. /**
  62844. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62845. */
  62846. samples: number;
  62847. /**
  62848. * If image processing is enabled.
  62849. */
  62850. imageProcessingEnabled: boolean;
  62851. /**
  62852. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62853. */
  62854. glowLayerEnabled: boolean;
  62855. /**
  62856. * Gets the glow layer (or null if not defined)
  62857. */
  62858. readonly glowLayer: Nullable<GlowLayer>;
  62859. /**
  62860. * Enable or disable the chromaticAberration process from the pipeline
  62861. */
  62862. chromaticAberrationEnabled: boolean;
  62863. /**
  62864. * Enable or disable the grain process from the pipeline
  62865. */
  62866. grainEnabled: boolean;
  62867. /**
  62868. * @constructor
  62869. * @param name - The rendering pipeline name (default: "")
  62870. * @param hdr - If high dynamic range textures should be used (default: true)
  62871. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62872. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62873. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62874. */
  62875. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62876. /**
  62877. * Get the class name
  62878. * @returns "DefaultRenderingPipeline"
  62879. */
  62880. getClassName(): string;
  62881. /**
  62882. * Force the compilation of the entire pipeline.
  62883. */
  62884. prepare(): void;
  62885. private _hasCleared;
  62886. private _prevPostProcess;
  62887. private _prevPrevPostProcess;
  62888. private _setAutoClearAndTextureSharing;
  62889. private _depthOfFieldSceneObserver;
  62890. private _buildPipeline;
  62891. private _disposePostProcesses;
  62892. /**
  62893. * Adds a camera to the pipeline
  62894. * @param camera the camera to be added
  62895. */
  62896. addCamera(camera: Camera): void;
  62897. /**
  62898. * Removes a camera from the pipeline
  62899. * @param camera the camera to remove
  62900. */
  62901. removeCamera(camera: Camera): void;
  62902. /**
  62903. * Dispose of the pipeline and stop all post processes
  62904. */
  62905. dispose(): void;
  62906. /**
  62907. * Serialize the rendering pipeline (Used when exporting)
  62908. * @returns the serialized object
  62909. */
  62910. serialize(): any;
  62911. /**
  62912. * Parse the serialized pipeline
  62913. * @param source Source pipeline.
  62914. * @param scene The scene to load the pipeline to.
  62915. * @param rootUrl The URL of the serialized pipeline.
  62916. * @returns An instantiated pipeline from the serialized object.
  62917. */
  62918. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62919. }
  62920. }
  62921. declare module BABYLON {
  62922. /** @hidden */
  62923. export var lensHighlightsPixelShader: {
  62924. name: string;
  62925. shader: string;
  62926. };
  62927. }
  62928. declare module BABYLON {
  62929. /** @hidden */
  62930. export var depthOfFieldPixelShader: {
  62931. name: string;
  62932. shader: string;
  62933. };
  62934. }
  62935. declare module BABYLON {
  62936. /**
  62937. * BABYLON.JS Chromatic Aberration GLSL Shader
  62938. * Author: Olivier Guyot
  62939. * Separates very slightly R, G and B colors on the edges of the screen
  62940. * Inspired by Francois Tarlier & Martins Upitis
  62941. */
  62942. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62943. /**
  62944. * @ignore
  62945. * The chromatic aberration PostProcess id in the pipeline
  62946. */
  62947. LensChromaticAberrationEffect: string;
  62948. /**
  62949. * @ignore
  62950. * The highlights enhancing PostProcess id in the pipeline
  62951. */
  62952. HighlightsEnhancingEffect: string;
  62953. /**
  62954. * @ignore
  62955. * The depth-of-field PostProcess id in the pipeline
  62956. */
  62957. LensDepthOfFieldEffect: string;
  62958. private _scene;
  62959. private _depthTexture;
  62960. private _grainTexture;
  62961. private _chromaticAberrationPostProcess;
  62962. private _highlightsPostProcess;
  62963. private _depthOfFieldPostProcess;
  62964. private _edgeBlur;
  62965. private _grainAmount;
  62966. private _chromaticAberration;
  62967. private _distortion;
  62968. private _highlightsGain;
  62969. private _highlightsThreshold;
  62970. private _dofDistance;
  62971. private _dofAperture;
  62972. private _dofDarken;
  62973. private _dofPentagon;
  62974. private _blurNoise;
  62975. /**
  62976. * @constructor
  62977. *
  62978. * Effect parameters are as follow:
  62979. * {
  62980. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62981. * edge_blur: number; // from 0 to x (1 for realism)
  62982. * distortion: number; // from 0 to x (1 for realism)
  62983. * grain_amount: number; // from 0 to 1
  62984. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62985. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62986. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62987. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62988. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62989. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62990. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62991. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62992. * }
  62993. * Note: if an effect parameter is unset, effect is disabled
  62994. *
  62995. * @param name The rendering pipeline name
  62996. * @param parameters - An object containing all parameters (see above)
  62997. * @param scene The scene linked to this pipeline
  62998. * @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)
  62999. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63000. */
  63001. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63002. /**
  63003. * Get the class name
  63004. * @returns "LensRenderingPipeline"
  63005. */
  63006. getClassName(): string;
  63007. /**
  63008. * Gets associated scene
  63009. */
  63010. readonly scene: Scene;
  63011. /**
  63012. * Gets or sets the edge blur
  63013. */
  63014. edgeBlur: number;
  63015. /**
  63016. * Gets or sets the grain amount
  63017. */
  63018. grainAmount: number;
  63019. /**
  63020. * Gets or sets the chromatic aberration amount
  63021. */
  63022. chromaticAberration: number;
  63023. /**
  63024. * Gets or sets the depth of field aperture
  63025. */
  63026. dofAperture: number;
  63027. /**
  63028. * Gets or sets the edge distortion
  63029. */
  63030. edgeDistortion: number;
  63031. /**
  63032. * Gets or sets the depth of field distortion
  63033. */
  63034. dofDistortion: number;
  63035. /**
  63036. * Gets or sets the darken out of focus amount
  63037. */
  63038. darkenOutOfFocus: number;
  63039. /**
  63040. * Gets or sets a boolean indicating if blur noise is enabled
  63041. */
  63042. blurNoise: boolean;
  63043. /**
  63044. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63045. */
  63046. pentagonBokeh: boolean;
  63047. /**
  63048. * Gets or sets the highlight grain amount
  63049. */
  63050. highlightsGain: number;
  63051. /**
  63052. * Gets or sets the highlight threshold
  63053. */
  63054. highlightsThreshold: number;
  63055. /**
  63056. * Sets the amount of blur at the edges
  63057. * @param amount blur amount
  63058. */
  63059. setEdgeBlur(amount: number): void;
  63060. /**
  63061. * Sets edge blur to 0
  63062. */
  63063. disableEdgeBlur(): void;
  63064. /**
  63065. * Sets the amout of grain
  63066. * @param amount Amount of grain
  63067. */
  63068. setGrainAmount(amount: number): void;
  63069. /**
  63070. * Set grain amount to 0
  63071. */
  63072. disableGrain(): void;
  63073. /**
  63074. * Sets the chromatic aberration amount
  63075. * @param amount amount of chromatic aberration
  63076. */
  63077. setChromaticAberration(amount: number): void;
  63078. /**
  63079. * Sets chromatic aberration amount to 0
  63080. */
  63081. disableChromaticAberration(): void;
  63082. /**
  63083. * Sets the EdgeDistortion amount
  63084. * @param amount amount of EdgeDistortion
  63085. */
  63086. setEdgeDistortion(amount: number): void;
  63087. /**
  63088. * Sets edge distortion to 0
  63089. */
  63090. disableEdgeDistortion(): void;
  63091. /**
  63092. * Sets the FocusDistance amount
  63093. * @param amount amount of FocusDistance
  63094. */
  63095. setFocusDistance(amount: number): void;
  63096. /**
  63097. * Disables depth of field
  63098. */
  63099. disableDepthOfField(): void;
  63100. /**
  63101. * Sets the Aperture amount
  63102. * @param amount amount of Aperture
  63103. */
  63104. setAperture(amount: number): void;
  63105. /**
  63106. * Sets the DarkenOutOfFocus amount
  63107. * @param amount amount of DarkenOutOfFocus
  63108. */
  63109. setDarkenOutOfFocus(amount: number): void;
  63110. private _pentagonBokehIsEnabled;
  63111. /**
  63112. * Creates a pentagon bokeh effect
  63113. */
  63114. enablePentagonBokeh(): void;
  63115. /**
  63116. * Disables the pentagon bokeh effect
  63117. */
  63118. disablePentagonBokeh(): void;
  63119. /**
  63120. * Enables noise blur
  63121. */
  63122. enableNoiseBlur(): void;
  63123. /**
  63124. * Disables noise blur
  63125. */
  63126. disableNoiseBlur(): void;
  63127. /**
  63128. * Sets the HighlightsGain amount
  63129. * @param amount amount of HighlightsGain
  63130. */
  63131. setHighlightsGain(amount: number): void;
  63132. /**
  63133. * Sets the HighlightsThreshold amount
  63134. * @param amount amount of HighlightsThreshold
  63135. */
  63136. setHighlightsThreshold(amount: number): void;
  63137. /**
  63138. * Disables highlights
  63139. */
  63140. disableHighlights(): void;
  63141. /**
  63142. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63143. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63144. */
  63145. dispose(disableDepthRender?: boolean): void;
  63146. private _createChromaticAberrationPostProcess;
  63147. private _createHighlightsPostProcess;
  63148. private _createDepthOfFieldPostProcess;
  63149. private _createGrainTexture;
  63150. }
  63151. }
  63152. declare module BABYLON {
  63153. /** @hidden */
  63154. export var ssao2PixelShader: {
  63155. name: string;
  63156. shader: string;
  63157. };
  63158. }
  63159. declare module BABYLON {
  63160. /** @hidden */
  63161. export var ssaoCombinePixelShader: {
  63162. name: string;
  63163. shader: string;
  63164. };
  63165. }
  63166. declare module BABYLON {
  63167. /**
  63168. * Render pipeline to produce ssao effect
  63169. */
  63170. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63171. /**
  63172. * @ignore
  63173. * The PassPostProcess id in the pipeline that contains the original scene color
  63174. */
  63175. SSAOOriginalSceneColorEffect: string;
  63176. /**
  63177. * @ignore
  63178. * The SSAO PostProcess id in the pipeline
  63179. */
  63180. SSAORenderEffect: string;
  63181. /**
  63182. * @ignore
  63183. * The horizontal blur PostProcess id in the pipeline
  63184. */
  63185. SSAOBlurHRenderEffect: string;
  63186. /**
  63187. * @ignore
  63188. * The vertical blur PostProcess id in the pipeline
  63189. */
  63190. SSAOBlurVRenderEffect: string;
  63191. /**
  63192. * @ignore
  63193. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63194. */
  63195. SSAOCombineRenderEffect: string;
  63196. /**
  63197. * The output strength of the SSAO post-process. Default value is 1.0.
  63198. */
  63199. totalStrength: number;
  63200. /**
  63201. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63202. */
  63203. maxZ: number;
  63204. /**
  63205. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63206. */
  63207. minZAspect: number;
  63208. private _samples;
  63209. /**
  63210. * Number of samples used for the SSAO calculations. Default value is 8
  63211. */
  63212. samples: number;
  63213. private _textureSamples;
  63214. /**
  63215. * Number of samples to use for antialiasing
  63216. */
  63217. textureSamples: number;
  63218. /**
  63219. * Ratio object used for SSAO ratio and blur ratio
  63220. */
  63221. private _ratio;
  63222. /**
  63223. * Dynamically generated sphere sampler.
  63224. */
  63225. private _sampleSphere;
  63226. /**
  63227. * Blur filter offsets
  63228. */
  63229. private _samplerOffsets;
  63230. private _expensiveBlur;
  63231. /**
  63232. * If bilateral blur should be used
  63233. */
  63234. expensiveBlur: boolean;
  63235. /**
  63236. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63237. */
  63238. radius: number;
  63239. /**
  63240. * The base color of the SSAO post-process
  63241. * The final result is "base + ssao" between [0, 1]
  63242. */
  63243. base: number;
  63244. /**
  63245. * Support test.
  63246. */
  63247. static readonly IsSupported: boolean;
  63248. private _scene;
  63249. private _depthTexture;
  63250. private _normalTexture;
  63251. private _randomTexture;
  63252. private _originalColorPostProcess;
  63253. private _ssaoPostProcess;
  63254. private _blurHPostProcess;
  63255. private _blurVPostProcess;
  63256. private _ssaoCombinePostProcess;
  63257. /**
  63258. * Gets active scene
  63259. */
  63260. readonly scene: Scene;
  63261. /**
  63262. * @constructor
  63263. * @param name The rendering pipeline name
  63264. * @param scene The scene linked to this pipeline
  63265. * @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 }
  63266. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63267. */
  63268. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63269. /**
  63270. * Get the class name
  63271. * @returns "SSAO2RenderingPipeline"
  63272. */
  63273. getClassName(): string;
  63274. /**
  63275. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63276. */
  63277. dispose(disableGeometryBufferRenderer?: boolean): void;
  63278. private _createBlurPostProcess;
  63279. /** @hidden */
  63280. _rebuild(): void;
  63281. private _bits;
  63282. private _radicalInverse_VdC;
  63283. private _hammersley;
  63284. private _hemisphereSample_uniform;
  63285. private _generateHemisphere;
  63286. private _createSSAOPostProcess;
  63287. private _createSSAOCombinePostProcess;
  63288. private _createRandomTexture;
  63289. /**
  63290. * Serialize the rendering pipeline (Used when exporting)
  63291. * @returns the serialized object
  63292. */
  63293. serialize(): any;
  63294. /**
  63295. * Parse the serialized pipeline
  63296. * @param source Source pipeline.
  63297. * @param scene The scene to load the pipeline to.
  63298. * @param rootUrl The URL of the serialized pipeline.
  63299. * @returns An instantiated pipeline from the serialized object.
  63300. */
  63301. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63302. }
  63303. }
  63304. declare module BABYLON {
  63305. /** @hidden */
  63306. export var ssaoPixelShader: {
  63307. name: string;
  63308. shader: string;
  63309. };
  63310. }
  63311. declare module BABYLON {
  63312. /**
  63313. * Render pipeline to produce ssao effect
  63314. */
  63315. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63316. /**
  63317. * @ignore
  63318. * The PassPostProcess id in the pipeline that contains the original scene color
  63319. */
  63320. SSAOOriginalSceneColorEffect: string;
  63321. /**
  63322. * @ignore
  63323. * The SSAO PostProcess id in the pipeline
  63324. */
  63325. SSAORenderEffect: string;
  63326. /**
  63327. * @ignore
  63328. * The horizontal blur PostProcess id in the pipeline
  63329. */
  63330. SSAOBlurHRenderEffect: string;
  63331. /**
  63332. * @ignore
  63333. * The vertical blur PostProcess id in the pipeline
  63334. */
  63335. SSAOBlurVRenderEffect: string;
  63336. /**
  63337. * @ignore
  63338. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63339. */
  63340. SSAOCombineRenderEffect: string;
  63341. /**
  63342. * The output strength of the SSAO post-process. Default value is 1.0.
  63343. */
  63344. totalStrength: number;
  63345. /**
  63346. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63347. */
  63348. radius: number;
  63349. /**
  63350. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63351. * Must not be equal to fallOff and superior to fallOff.
  63352. * Default value is 0.0075
  63353. */
  63354. area: number;
  63355. /**
  63356. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63357. * Must not be equal to area and inferior to area.
  63358. * Default value is 0.000001
  63359. */
  63360. fallOff: number;
  63361. /**
  63362. * The base color of the SSAO post-process
  63363. * The final result is "base + ssao" between [0, 1]
  63364. */
  63365. base: number;
  63366. private _scene;
  63367. private _depthTexture;
  63368. private _randomTexture;
  63369. private _originalColorPostProcess;
  63370. private _ssaoPostProcess;
  63371. private _blurHPostProcess;
  63372. private _blurVPostProcess;
  63373. private _ssaoCombinePostProcess;
  63374. private _firstUpdate;
  63375. /**
  63376. * Gets active scene
  63377. */
  63378. readonly scene: Scene;
  63379. /**
  63380. * @constructor
  63381. * @param name - The rendering pipeline name
  63382. * @param scene - The scene linked to this pipeline
  63383. * @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 }
  63384. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63385. */
  63386. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63387. /**
  63388. * Get the class name
  63389. * @returns "SSAORenderingPipeline"
  63390. */
  63391. getClassName(): string;
  63392. /**
  63393. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63394. */
  63395. dispose(disableDepthRender?: boolean): void;
  63396. private _createBlurPostProcess;
  63397. /** @hidden */
  63398. _rebuild(): void;
  63399. private _createSSAOPostProcess;
  63400. private _createSSAOCombinePostProcess;
  63401. private _createRandomTexture;
  63402. }
  63403. }
  63404. declare module BABYLON {
  63405. /** @hidden */
  63406. export var standardPixelShader: {
  63407. name: string;
  63408. shader: string;
  63409. };
  63410. }
  63411. declare module BABYLON {
  63412. /**
  63413. * Standard rendering pipeline
  63414. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63415. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63416. */
  63417. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63418. /**
  63419. * Public members
  63420. */
  63421. /**
  63422. * Post-process which contains the original scene color before the pipeline applies all the effects
  63423. */
  63424. originalPostProcess: Nullable<PostProcess>;
  63425. /**
  63426. * Post-process used to down scale an image x4
  63427. */
  63428. downSampleX4PostProcess: Nullable<PostProcess>;
  63429. /**
  63430. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63431. */
  63432. brightPassPostProcess: Nullable<PostProcess>;
  63433. /**
  63434. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63435. */
  63436. blurHPostProcesses: PostProcess[];
  63437. /**
  63438. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63439. */
  63440. blurVPostProcesses: PostProcess[];
  63441. /**
  63442. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63443. */
  63444. textureAdderPostProcess: Nullable<PostProcess>;
  63445. /**
  63446. * Post-process used to create volumetric lighting effect
  63447. */
  63448. volumetricLightPostProcess: Nullable<PostProcess>;
  63449. /**
  63450. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63451. */
  63452. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63453. /**
  63454. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63455. */
  63456. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63457. /**
  63458. * Post-process used to merge the volumetric light effect and the real scene color
  63459. */
  63460. volumetricLightMergePostProces: Nullable<PostProcess>;
  63461. /**
  63462. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63463. */
  63464. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63465. /**
  63466. * Base post-process used to calculate the average luminance of the final image for HDR
  63467. */
  63468. luminancePostProcess: Nullable<PostProcess>;
  63469. /**
  63470. * Post-processes used to create down sample post-processes in order to get
  63471. * the average luminance of the final image for HDR
  63472. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63473. */
  63474. luminanceDownSamplePostProcesses: PostProcess[];
  63475. /**
  63476. * Post-process used to create a HDR effect (light adaptation)
  63477. */
  63478. hdrPostProcess: Nullable<PostProcess>;
  63479. /**
  63480. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63481. */
  63482. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63483. /**
  63484. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63485. */
  63486. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63487. /**
  63488. * Post-process used to merge the final HDR post-process and the real scene color
  63489. */
  63490. hdrFinalPostProcess: Nullable<PostProcess>;
  63491. /**
  63492. * Post-process used to create a lens flare effect
  63493. */
  63494. lensFlarePostProcess: Nullable<PostProcess>;
  63495. /**
  63496. * Post-process that merges the result of the lens flare post-process and the real scene color
  63497. */
  63498. lensFlareComposePostProcess: Nullable<PostProcess>;
  63499. /**
  63500. * Post-process used to create a motion blur effect
  63501. */
  63502. motionBlurPostProcess: Nullable<PostProcess>;
  63503. /**
  63504. * Post-process used to create a depth of field effect
  63505. */
  63506. depthOfFieldPostProcess: Nullable<PostProcess>;
  63507. /**
  63508. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63509. */
  63510. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63511. /**
  63512. * Represents the brightness threshold in order to configure the illuminated surfaces
  63513. */
  63514. brightThreshold: number;
  63515. /**
  63516. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63517. */
  63518. blurWidth: number;
  63519. /**
  63520. * Sets if the blur for highlighted surfaces must be only horizontal
  63521. */
  63522. horizontalBlur: boolean;
  63523. /**
  63524. * Gets the overall exposure used by the pipeline
  63525. */
  63526. /**
  63527. * Sets the overall exposure used by the pipeline
  63528. */
  63529. exposure: number;
  63530. /**
  63531. * Texture used typically to simulate "dirty" on camera lens
  63532. */
  63533. lensTexture: Nullable<Texture>;
  63534. /**
  63535. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63536. */
  63537. volumetricLightCoefficient: number;
  63538. /**
  63539. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63540. */
  63541. volumetricLightPower: number;
  63542. /**
  63543. * Used the set the blur intensity to smooth the volumetric lights
  63544. */
  63545. volumetricLightBlurScale: number;
  63546. /**
  63547. * Light (spot or directional) used to generate the volumetric lights rays
  63548. * The source light must have a shadow generate so the pipeline can get its
  63549. * depth map
  63550. */
  63551. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63552. /**
  63553. * For eye adaptation, represents the minimum luminance the eye can see
  63554. */
  63555. hdrMinimumLuminance: number;
  63556. /**
  63557. * For eye adaptation, represents the decrease luminance speed
  63558. */
  63559. hdrDecreaseRate: number;
  63560. /**
  63561. * For eye adaptation, represents the increase luminance speed
  63562. */
  63563. hdrIncreaseRate: number;
  63564. /**
  63565. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63566. */
  63567. /**
  63568. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63569. */
  63570. hdrAutoExposure: boolean;
  63571. /**
  63572. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63573. */
  63574. lensColorTexture: Nullable<Texture>;
  63575. /**
  63576. * The overall strengh for the lens flare effect
  63577. */
  63578. lensFlareStrength: number;
  63579. /**
  63580. * Dispersion coefficient for lens flare ghosts
  63581. */
  63582. lensFlareGhostDispersal: number;
  63583. /**
  63584. * Main lens flare halo width
  63585. */
  63586. lensFlareHaloWidth: number;
  63587. /**
  63588. * Based on the lens distortion effect, defines how much the lens flare result
  63589. * is distorted
  63590. */
  63591. lensFlareDistortionStrength: number;
  63592. /**
  63593. * Configures the blur intensity used for for lens flare (halo)
  63594. */
  63595. lensFlareBlurWidth: number;
  63596. /**
  63597. * Lens star texture must be used to simulate rays on the flares and is available
  63598. * in the documentation
  63599. */
  63600. lensStarTexture: Nullable<Texture>;
  63601. /**
  63602. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63603. * flare effect by taking account of the dirt texture
  63604. */
  63605. lensFlareDirtTexture: Nullable<Texture>;
  63606. /**
  63607. * Represents the focal length for the depth of field effect
  63608. */
  63609. depthOfFieldDistance: number;
  63610. /**
  63611. * Represents the blur intensity for the blurred part of the depth of field effect
  63612. */
  63613. depthOfFieldBlurWidth: number;
  63614. /**
  63615. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63616. */
  63617. /**
  63618. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63619. */
  63620. motionStrength: number;
  63621. /**
  63622. * Gets wether or not the motion blur post-process is object based or screen based.
  63623. */
  63624. /**
  63625. * Sets wether or not the motion blur post-process should be object based or screen based
  63626. */
  63627. objectBasedMotionBlur: boolean;
  63628. /**
  63629. * List of animations for the pipeline (IAnimatable implementation)
  63630. */
  63631. animations: Animation[];
  63632. /**
  63633. * Private members
  63634. */
  63635. private _scene;
  63636. private _currentDepthOfFieldSource;
  63637. private _basePostProcess;
  63638. private _fixedExposure;
  63639. private _currentExposure;
  63640. private _hdrAutoExposure;
  63641. private _hdrCurrentLuminance;
  63642. private _motionStrength;
  63643. private _isObjectBasedMotionBlur;
  63644. private _floatTextureType;
  63645. private _camerasToBeAttached;
  63646. private _ratio;
  63647. private _bloomEnabled;
  63648. private _depthOfFieldEnabled;
  63649. private _vlsEnabled;
  63650. private _lensFlareEnabled;
  63651. private _hdrEnabled;
  63652. private _motionBlurEnabled;
  63653. private _fxaaEnabled;
  63654. private _motionBlurSamples;
  63655. private _volumetricLightStepsCount;
  63656. private _samples;
  63657. /**
  63658. * @ignore
  63659. * Specifies if the bloom pipeline is enabled
  63660. */
  63661. BloomEnabled: boolean;
  63662. /**
  63663. * @ignore
  63664. * Specifies if the depth of field pipeline is enabed
  63665. */
  63666. DepthOfFieldEnabled: boolean;
  63667. /**
  63668. * @ignore
  63669. * Specifies if the lens flare pipeline is enabed
  63670. */
  63671. LensFlareEnabled: boolean;
  63672. /**
  63673. * @ignore
  63674. * Specifies if the HDR pipeline is enabled
  63675. */
  63676. HDREnabled: boolean;
  63677. /**
  63678. * @ignore
  63679. * Specifies if the volumetric lights scattering effect is enabled
  63680. */
  63681. VLSEnabled: boolean;
  63682. /**
  63683. * @ignore
  63684. * Specifies if the motion blur effect is enabled
  63685. */
  63686. MotionBlurEnabled: boolean;
  63687. /**
  63688. * Specifies if anti-aliasing is enabled
  63689. */
  63690. fxaaEnabled: boolean;
  63691. /**
  63692. * Specifies the number of steps used to calculate the volumetric lights
  63693. * Typically in interval [50, 200]
  63694. */
  63695. volumetricLightStepsCount: number;
  63696. /**
  63697. * Specifies the number of samples used for the motion blur effect
  63698. * Typically in interval [16, 64]
  63699. */
  63700. motionBlurSamples: number;
  63701. /**
  63702. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63703. */
  63704. samples: number;
  63705. /**
  63706. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63707. * @constructor
  63708. * @param name The rendering pipeline name
  63709. * @param scene The scene linked to this pipeline
  63710. * @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)
  63711. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63712. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63713. */
  63714. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63715. private _buildPipeline;
  63716. private _createDownSampleX4PostProcess;
  63717. private _createBrightPassPostProcess;
  63718. private _createBlurPostProcesses;
  63719. private _createTextureAdderPostProcess;
  63720. private _createVolumetricLightPostProcess;
  63721. private _createLuminancePostProcesses;
  63722. private _createHdrPostProcess;
  63723. private _createLensFlarePostProcess;
  63724. private _createDepthOfFieldPostProcess;
  63725. private _createMotionBlurPostProcess;
  63726. private _getDepthTexture;
  63727. private _disposePostProcesses;
  63728. /**
  63729. * Dispose of the pipeline and stop all post processes
  63730. */
  63731. dispose(): void;
  63732. /**
  63733. * Serialize the rendering pipeline (Used when exporting)
  63734. * @returns the serialized object
  63735. */
  63736. serialize(): any;
  63737. /**
  63738. * Parse the serialized pipeline
  63739. * @param source Source pipeline.
  63740. * @param scene The scene to load the pipeline to.
  63741. * @param rootUrl The URL of the serialized pipeline.
  63742. * @returns An instantiated pipeline from the serialized object.
  63743. */
  63744. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63745. /**
  63746. * Luminance steps
  63747. */
  63748. static LuminanceSteps: number;
  63749. }
  63750. }
  63751. declare module BABYLON {
  63752. /** @hidden */
  63753. export var tonemapPixelShader: {
  63754. name: string;
  63755. shader: string;
  63756. };
  63757. }
  63758. declare module BABYLON {
  63759. /** Defines operator used for tonemapping */
  63760. export enum TonemappingOperator {
  63761. /** Hable */
  63762. Hable = 0,
  63763. /** Reinhard */
  63764. Reinhard = 1,
  63765. /** HejiDawson */
  63766. HejiDawson = 2,
  63767. /** Photographic */
  63768. Photographic = 3
  63769. }
  63770. /**
  63771. * Defines a post process to apply tone mapping
  63772. */
  63773. export class TonemapPostProcess extends PostProcess {
  63774. private _operator;
  63775. /** Defines the required exposure adjustement */
  63776. exposureAdjustment: number;
  63777. /**
  63778. * Creates a new TonemapPostProcess
  63779. * @param name defines the name of the postprocess
  63780. * @param _operator defines the operator to use
  63781. * @param exposureAdjustment defines the required exposure adjustement
  63782. * @param camera defines the camera to use (can be null)
  63783. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63784. * @param engine defines the hosting engine (can be ignore if camera is set)
  63785. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63786. */
  63787. constructor(name: string, _operator: TonemappingOperator,
  63788. /** Defines the required exposure adjustement */
  63789. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63790. }
  63791. }
  63792. declare module BABYLON {
  63793. /** @hidden */
  63794. export var depthVertexShader: {
  63795. name: string;
  63796. shader: string;
  63797. };
  63798. }
  63799. declare module BABYLON {
  63800. /** @hidden */
  63801. export var volumetricLightScatteringPixelShader: {
  63802. name: string;
  63803. shader: string;
  63804. };
  63805. }
  63806. declare module BABYLON {
  63807. /** @hidden */
  63808. export var volumetricLightScatteringPassVertexShader: {
  63809. name: string;
  63810. shader: string;
  63811. };
  63812. }
  63813. declare module BABYLON {
  63814. /** @hidden */
  63815. export var volumetricLightScatteringPassPixelShader: {
  63816. name: string;
  63817. shader: string;
  63818. };
  63819. }
  63820. declare module BABYLON {
  63821. /**
  63822. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63823. */
  63824. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63825. private _volumetricLightScatteringPass;
  63826. private _volumetricLightScatteringRTT;
  63827. private _viewPort;
  63828. private _screenCoordinates;
  63829. private _cachedDefines;
  63830. /**
  63831. * If not undefined, the mesh position is computed from the attached node position
  63832. */
  63833. attachedNode: {
  63834. position: Vector3;
  63835. };
  63836. /**
  63837. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63838. */
  63839. customMeshPosition: Vector3;
  63840. /**
  63841. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63842. */
  63843. useCustomMeshPosition: boolean;
  63844. /**
  63845. * If the post-process should inverse the light scattering direction
  63846. */
  63847. invert: boolean;
  63848. /**
  63849. * The internal mesh used by the post-process
  63850. */
  63851. mesh: Mesh;
  63852. /**
  63853. * @hidden
  63854. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63855. */
  63856. useDiffuseColor: boolean;
  63857. /**
  63858. * Array containing the excluded meshes not rendered in the internal pass
  63859. */
  63860. excludedMeshes: AbstractMesh[];
  63861. /**
  63862. * Controls the overall intensity of the post-process
  63863. */
  63864. exposure: number;
  63865. /**
  63866. * Dissipates each sample's contribution in range [0, 1]
  63867. */
  63868. decay: number;
  63869. /**
  63870. * Controls the overall intensity of each sample
  63871. */
  63872. weight: number;
  63873. /**
  63874. * Controls the density of each sample
  63875. */
  63876. density: number;
  63877. /**
  63878. * @constructor
  63879. * @param name The post-process name
  63880. * @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)
  63881. * @param camera The camera that the post-process will be attached to
  63882. * @param mesh The mesh used to create the light scattering
  63883. * @param samples The post-process quality, default 100
  63884. * @param samplingModeThe post-process filtering mode
  63885. * @param engine The babylon engine
  63886. * @param reusable If the post-process is reusable
  63887. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63888. */
  63889. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63890. /**
  63891. * Returns the string "VolumetricLightScatteringPostProcess"
  63892. * @returns "VolumetricLightScatteringPostProcess"
  63893. */
  63894. getClassName(): string;
  63895. private _isReady;
  63896. /**
  63897. * Sets the new light position for light scattering effect
  63898. * @param position The new custom light position
  63899. */
  63900. setCustomMeshPosition(position: Vector3): void;
  63901. /**
  63902. * Returns the light position for light scattering effect
  63903. * @return Vector3 The custom light position
  63904. */
  63905. getCustomMeshPosition(): Vector3;
  63906. /**
  63907. * Disposes the internal assets and detaches the post-process from the camera
  63908. */
  63909. dispose(camera: Camera): void;
  63910. /**
  63911. * Returns the render target texture used by the post-process
  63912. * @return the render target texture used by the post-process
  63913. */
  63914. getPass(): RenderTargetTexture;
  63915. private _meshExcluded;
  63916. private _createPass;
  63917. private _updateMeshScreenCoordinates;
  63918. /**
  63919. * Creates a default mesh for the Volumeric Light Scattering post-process
  63920. * @param name The mesh name
  63921. * @param scene The scene where to create the mesh
  63922. * @return the default mesh
  63923. */
  63924. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63925. }
  63926. }
  63927. declare module BABYLON {
  63928. interface Scene {
  63929. /** @hidden (Backing field) */
  63930. _boundingBoxRenderer: BoundingBoxRenderer;
  63931. /** @hidden (Backing field) */
  63932. _forceShowBoundingBoxes: boolean;
  63933. /**
  63934. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63935. */
  63936. forceShowBoundingBoxes: boolean;
  63937. /**
  63938. * Gets the bounding box renderer associated with the scene
  63939. * @returns a BoundingBoxRenderer
  63940. */
  63941. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63942. }
  63943. interface AbstractMesh {
  63944. /** @hidden (Backing field) */
  63945. _showBoundingBox: boolean;
  63946. /**
  63947. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63948. */
  63949. showBoundingBox: boolean;
  63950. }
  63951. /**
  63952. * Component responsible of rendering the bounding box of the meshes in a scene.
  63953. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63954. */
  63955. export class BoundingBoxRenderer implements ISceneComponent {
  63956. /**
  63957. * The component name helpfull to identify the component in the list of scene components.
  63958. */
  63959. readonly name: string;
  63960. /**
  63961. * The scene the component belongs to.
  63962. */
  63963. scene: Scene;
  63964. /**
  63965. * Color of the bounding box lines placed in front of an object
  63966. */
  63967. frontColor: Color3;
  63968. /**
  63969. * Color of the bounding box lines placed behind an object
  63970. */
  63971. backColor: Color3;
  63972. /**
  63973. * Defines if the renderer should show the back lines or not
  63974. */
  63975. showBackLines: boolean;
  63976. /**
  63977. * @hidden
  63978. */
  63979. renderList: SmartArray<BoundingBox>;
  63980. private _colorShader;
  63981. private _vertexBuffers;
  63982. private _indexBuffer;
  63983. private _fillIndexBuffer;
  63984. private _fillIndexData;
  63985. /**
  63986. * Instantiates a new bounding box renderer in a scene.
  63987. * @param scene the scene the renderer renders in
  63988. */
  63989. constructor(scene: Scene);
  63990. /**
  63991. * Registers the component in a given scene
  63992. */
  63993. register(): void;
  63994. private _evaluateSubMesh;
  63995. private _activeMesh;
  63996. private _prepareRessources;
  63997. private _createIndexBuffer;
  63998. /**
  63999. * Rebuilds the elements related to this component in case of
  64000. * context lost for instance.
  64001. */
  64002. rebuild(): void;
  64003. /**
  64004. * @hidden
  64005. */
  64006. reset(): void;
  64007. /**
  64008. * Render the bounding boxes of a specific rendering group
  64009. * @param renderingGroupId defines the rendering group to render
  64010. */
  64011. render(renderingGroupId: number): void;
  64012. /**
  64013. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64014. * @param mesh Define the mesh to render the occlusion bounding box for
  64015. */
  64016. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64017. /**
  64018. * Dispose and release the resources attached to this renderer.
  64019. */
  64020. dispose(): void;
  64021. }
  64022. }
  64023. declare module BABYLON {
  64024. /** @hidden */
  64025. export var depthPixelShader: {
  64026. name: string;
  64027. shader: string;
  64028. };
  64029. }
  64030. declare module BABYLON {
  64031. /**
  64032. * This represents a depth renderer in Babylon.
  64033. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64034. */
  64035. export class DepthRenderer {
  64036. private _scene;
  64037. private _depthMap;
  64038. private _effect;
  64039. private readonly _storeNonLinearDepth;
  64040. private readonly _clearColor;
  64041. /** Get if the depth renderer is using packed depth or not */
  64042. readonly isPacked: boolean;
  64043. private _cachedDefines;
  64044. private _camera;
  64045. /**
  64046. * Specifiess that the depth renderer will only be used within
  64047. * the camera it is created for.
  64048. * This can help forcing its rendering during the camera processing.
  64049. */
  64050. useOnlyInActiveCamera: boolean;
  64051. /** @hidden */
  64052. static _SceneComponentInitialization: (scene: Scene) => void;
  64053. /**
  64054. * Instantiates a depth renderer
  64055. * @param scene The scene the renderer belongs to
  64056. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64057. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64058. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64059. */
  64060. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64061. /**
  64062. * Creates the depth rendering effect and checks if the effect is ready.
  64063. * @param subMesh The submesh to be used to render the depth map of
  64064. * @param useInstances If multiple world instances should be used
  64065. * @returns if the depth renderer is ready to render the depth map
  64066. */
  64067. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64068. /**
  64069. * Gets the texture which the depth map will be written to.
  64070. * @returns The depth map texture
  64071. */
  64072. getDepthMap(): RenderTargetTexture;
  64073. /**
  64074. * Disposes of the depth renderer.
  64075. */
  64076. dispose(): void;
  64077. }
  64078. }
  64079. declare module BABYLON {
  64080. interface Scene {
  64081. /** @hidden (Backing field) */
  64082. _depthRenderer: {
  64083. [id: string]: DepthRenderer;
  64084. };
  64085. /**
  64086. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64087. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64088. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64089. * @returns the created depth renderer
  64090. */
  64091. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64092. /**
  64093. * Disables a depth renderer for a given camera
  64094. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64095. */
  64096. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64097. }
  64098. /**
  64099. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64100. * in several rendering techniques.
  64101. */
  64102. export class DepthRendererSceneComponent implements ISceneComponent {
  64103. /**
  64104. * The component name helpfull to identify the component in the list of scene components.
  64105. */
  64106. readonly name: string;
  64107. /**
  64108. * The scene the component belongs to.
  64109. */
  64110. scene: Scene;
  64111. /**
  64112. * Creates a new instance of the component for the given scene
  64113. * @param scene Defines the scene to register the component in
  64114. */
  64115. constructor(scene: Scene);
  64116. /**
  64117. * Registers the component in a given scene
  64118. */
  64119. register(): void;
  64120. /**
  64121. * Rebuilds the elements related to this component in case of
  64122. * context lost for instance.
  64123. */
  64124. rebuild(): void;
  64125. /**
  64126. * Disposes the component and the associated ressources
  64127. */
  64128. dispose(): void;
  64129. private _gatherRenderTargets;
  64130. private _gatherActiveCameraRenderTargets;
  64131. }
  64132. }
  64133. declare module BABYLON {
  64134. /** @hidden */
  64135. export var outlinePixelShader: {
  64136. name: string;
  64137. shader: string;
  64138. };
  64139. }
  64140. declare module BABYLON {
  64141. /** @hidden */
  64142. export var outlineVertexShader: {
  64143. name: string;
  64144. shader: string;
  64145. };
  64146. }
  64147. declare module BABYLON {
  64148. interface Scene {
  64149. /** @hidden */
  64150. _outlineRenderer: OutlineRenderer;
  64151. /**
  64152. * Gets the outline renderer associated with the scene
  64153. * @returns a OutlineRenderer
  64154. */
  64155. getOutlineRenderer(): OutlineRenderer;
  64156. }
  64157. interface AbstractMesh {
  64158. /** @hidden (Backing field) */
  64159. _renderOutline: boolean;
  64160. /**
  64161. * Gets or sets a boolean indicating if the outline must be rendered as well
  64162. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64163. */
  64164. renderOutline: boolean;
  64165. /** @hidden (Backing field) */
  64166. _renderOverlay: boolean;
  64167. /**
  64168. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64169. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64170. */
  64171. renderOverlay: boolean;
  64172. }
  64173. /**
  64174. * This class is responsible to draw bothe outline/overlay of meshes.
  64175. * It should not be used directly but through the available method on mesh.
  64176. */
  64177. export class OutlineRenderer implements ISceneComponent {
  64178. /**
  64179. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64180. */
  64181. private static _StencilReference;
  64182. /**
  64183. * The name of the component. Each component must have a unique name.
  64184. */
  64185. name: string;
  64186. /**
  64187. * The scene the component belongs to.
  64188. */
  64189. scene: Scene;
  64190. /**
  64191. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64192. */
  64193. zOffset: number;
  64194. private _engine;
  64195. private _effect;
  64196. private _cachedDefines;
  64197. private _savedDepthWrite;
  64198. /**
  64199. * Instantiates a new outline renderer. (There could be only one per scene).
  64200. * @param scene Defines the scene it belongs to
  64201. */
  64202. constructor(scene: Scene);
  64203. /**
  64204. * Register the component to one instance of a scene.
  64205. */
  64206. register(): void;
  64207. /**
  64208. * Rebuilds the elements related to this component in case of
  64209. * context lost for instance.
  64210. */
  64211. rebuild(): void;
  64212. /**
  64213. * Disposes the component and the associated ressources.
  64214. */
  64215. dispose(): void;
  64216. /**
  64217. * Renders the outline in the canvas.
  64218. * @param subMesh Defines the sumesh to render
  64219. * @param batch Defines the batch of meshes in case of instances
  64220. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64221. */
  64222. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64223. /**
  64224. * Returns whether or not the outline renderer is ready for a given submesh.
  64225. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64226. * @param subMesh Defines the submesh to check readyness for
  64227. * @param useInstances Defines wheter wee are trying to render instances or not
  64228. * @returns true if ready otherwise false
  64229. */
  64230. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64231. private _beforeRenderingMesh;
  64232. private _afterRenderingMesh;
  64233. }
  64234. }
  64235. declare module BABYLON {
  64236. /**
  64237. * Defines the basic options interface of a Sprite Frame Source Size.
  64238. */
  64239. export interface ISpriteJSONSpriteSourceSize {
  64240. /**
  64241. * number of the original width of the Frame
  64242. */
  64243. w: number;
  64244. /**
  64245. * number of the original height of the Frame
  64246. */
  64247. h: number;
  64248. }
  64249. /**
  64250. * Defines the basic options interface of a Sprite Frame Data.
  64251. */
  64252. export interface ISpriteJSONSpriteFrameData {
  64253. /**
  64254. * number of the x offset of the Frame
  64255. */
  64256. x: number;
  64257. /**
  64258. * number of the y offset of the Frame
  64259. */
  64260. y: number;
  64261. /**
  64262. * number of the width of the Frame
  64263. */
  64264. w: number;
  64265. /**
  64266. * number of the height of the Frame
  64267. */
  64268. h: number;
  64269. }
  64270. /**
  64271. * Defines the basic options interface of a JSON Sprite.
  64272. */
  64273. export interface ISpriteJSONSprite {
  64274. /**
  64275. * string name of the Frame
  64276. */
  64277. filename: string;
  64278. /**
  64279. * ISpriteJSONSpriteFrame basic object of the frame data
  64280. */
  64281. frame: ISpriteJSONSpriteFrameData;
  64282. /**
  64283. * boolean to flag is the frame was rotated.
  64284. */
  64285. rotated: boolean;
  64286. /**
  64287. * boolean to flag is the frame was trimmed.
  64288. */
  64289. trimmed: boolean;
  64290. /**
  64291. * ISpriteJSONSpriteFrame basic object of the source data
  64292. */
  64293. spriteSourceSize: ISpriteJSONSpriteFrameData;
  64294. /**
  64295. * ISpriteJSONSpriteFrame basic object of the source data
  64296. */
  64297. sourceSize: ISpriteJSONSpriteSourceSize;
  64298. }
  64299. /**
  64300. * Defines the basic options interface of a JSON atlas.
  64301. */
  64302. export interface ISpriteJSONAtlas {
  64303. /**
  64304. * Array of objects that contain the frame data.
  64305. */
  64306. frames: Array<ISpriteJSONSprite>;
  64307. /**
  64308. * object basic object containing the sprite meta data.
  64309. */
  64310. meta?: object;
  64311. }
  64312. }
  64313. declare module BABYLON {
  64314. /** @hidden */
  64315. export var spriteMapPixelShader: {
  64316. name: string;
  64317. shader: string;
  64318. };
  64319. }
  64320. declare module BABYLON {
  64321. /** @hidden */
  64322. export var spriteMapVertexShader: {
  64323. name: string;
  64324. shader: string;
  64325. };
  64326. }
  64327. declare module BABYLON {
  64328. /**
  64329. * Defines the basic options interface of a SpriteMap
  64330. */
  64331. export interface ISpriteMapOptions {
  64332. /**
  64333. * Vector2 of the number of cells in the grid.
  64334. */
  64335. stageSize?: Vector2;
  64336. /**
  64337. * Vector2 of the size of the output plane in World Units.
  64338. */
  64339. outputSize?: Vector2;
  64340. /**
  64341. * Vector3 of the position of the output plane in World Units.
  64342. */
  64343. outputPosition?: Vector3;
  64344. /**
  64345. * Vector3 of the rotation of the output plane.
  64346. */
  64347. outputRotation?: Vector3;
  64348. /**
  64349. * number of layers that the system will reserve in resources.
  64350. */
  64351. layerCount?: number;
  64352. /**
  64353. * number of max animation frames a single cell will reserve in resources.
  64354. */
  64355. maxAnimationFrames?: number;
  64356. /**
  64357. * number cell index of the base tile when the system compiles.
  64358. */
  64359. baseTile?: number;
  64360. /**
  64361. * boolean flip the sprite after its been repositioned by the framing data.
  64362. */
  64363. flipU?: boolean;
  64364. /**
  64365. * Vector3 scalar of the global RGB values of the SpriteMap.
  64366. */
  64367. colorMultiply?: Vector3;
  64368. }
  64369. /**
  64370. * Defines the IDisposable interface in order to be cleanable from resources.
  64371. */
  64372. export interface ISpriteMap extends IDisposable {
  64373. /**
  64374. * String name of the SpriteMap.
  64375. */
  64376. name: string;
  64377. /**
  64378. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  64379. */
  64380. atlasJSON: ISpriteJSONAtlas;
  64381. /**
  64382. * Texture of the SpriteMap.
  64383. */
  64384. spriteSheet: Texture;
  64385. /**
  64386. * The parameters to initialize the SpriteMap with.
  64387. */
  64388. options: ISpriteMapOptions;
  64389. }
  64390. /**
  64391. * Class used to manage a grid restricted sprite deployment on an Output plane.
  64392. */
  64393. export class SpriteMap implements ISpriteMap {
  64394. /** The Name of the spriteMap */
  64395. name: string;
  64396. /** The JSON file with the frame and meta data */
  64397. atlasJSON: ISpriteJSONAtlas;
  64398. /** The systems Sprite Sheet Texture */
  64399. spriteSheet: Texture;
  64400. /** Arguments passed with the Constructor */
  64401. options: ISpriteMapOptions;
  64402. /** Public Sprite Storage array, parsed from atlasJSON */
  64403. sprites: Array<ISpriteJSONSprite>;
  64404. /** Returns the Number of Sprites in the System */
  64405. readonly spriteCount: number;
  64406. /** Returns the Position of Output Plane*/
  64407. /** Returns the Position of Output Plane*/
  64408. position: Vector3;
  64409. /** Returns the Rotation of Output Plane*/
  64410. /** Returns the Rotation of Output Plane*/
  64411. rotation: Vector3;
  64412. /** Sets the AnimationMap*/
  64413. /** Sets the AnimationMap*/
  64414. animationMap: RawTexture;
  64415. /** Scene that the SpriteMap was created in */
  64416. private _scene;
  64417. /** Texture Buffer of Float32 that holds tile frame data*/
  64418. private _frameMap;
  64419. /** Texture Buffers of Float32 that holds tileMap data*/
  64420. private _tileMaps;
  64421. /** Texture Buffer of Float32 that holds Animation Data*/
  64422. private _animationMap;
  64423. /** Custom ShaderMaterial Central to the System*/
  64424. private _material;
  64425. /** Custom ShaderMaterial Central to the System*/
  64426. private _output;
  64427. /** Systems Time Ticker*/
  64428. private _time;
  64429. /**
  64430. * Creates a new SpriteMap
  64431. * @param name defines the SpriteMaps Name
  64432. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  64433. * @param spriteSheet is the Texture that the Sprites are on.
  64434. * @param options a basic deployment configuration
  64435. * @param scene The Scene that the map is deployed on
  64436. */
  64437. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  64438. /**
  64439. * Returns tileID location
  64440. * @returns Vector2 the cell position ID
  64441. */
  64442. getTileID(): Vector2;
  64443. /**
  64444. * Gets the UV location of the mouse over the SpriteMap.
  64445. * @returns Vector2 the UV position of the mouse interaction
  64446. */
  64447. getMousePosition(): Vector2;
  64448. /**
  64449. * Creates the "frame" texture Buffer
  64450. * -------------------------------------
  64451. * Structure of frames
  64452. * "filename": "Falling-Water-2.png",
  64453. * "frame": {"x":69,"y":103,"w":24,"h":32},
  64454. * "rotated": true,
  64455. * "trimmed": true,
  64456. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  64457. * "sourceSize": {"w":32,"h":32}
  64458. * @returns RawTexture of the frameMap
  64459. */
  64460. private _createFrameBuffer;
  64461. /**
  64462. * Creates the tileMap texture Buffer
  64463. * @param buffer normally and array of numbers, or a false to generate from scratch
  64464. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  64465. * @returns RawTexture of the tileMap
  64466. */
  64467. private _createTileBuffer;
  64468. /**
  64469. * Modifies the data of the tileMaps
  64470. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  64471. * @param pos is the iVector2 Coordinates of the Tile
  64472. * @param tile The SpriteIndex of the new Tile
  64473. */
  64474. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  64475. /**
  64476. * Creates the animationMap texture Buffer
  64477. * @param buffer normally and array of numbers, or a false to generate from scratch
  64478. * @returns RawTexture of the animationMap
  64479. */
  64480. private _createTileAnimationBuffer;
  64481. /**
  64482. * Modifies the data of the animationMap
  64483. * @param cellID is the Index of the Sprite
  64484. * @param _frame is the target Animation frame
  64485. * @param toCell is the Target Index of the next frame of the animation
  64486. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  64487. * @param speed is a global scalar of the time variable on the map.
  64488. */
  64489. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  64490. /**
  64491. * Exports the .tilemaps file
  64492. */
  64493. saveTileMaps(): void;
  64494. /**
  64495. * Imports the .tilemaps file
  64496. * @param url of the .tilemaps file
  64497. */
  64498. loadTileMaps(url: string): void;
  64499. /**
  64500. * Release associated resources
  64501. */
  64502. dispose(): void;
  64503. }
  64504. }
  64505. declare module BABYLON {
  64506. /**
  64507. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64508. * @see http://doc.babylonjs.com/babylon101/sprites
  64509. */
  64510. export class SpritePackedManager extends SpriteManager {
  64511. /** defines the packed manager's name */
  64512. name: string;
  64513. /**
  64514. * Creates a new sprite manager from a packed sprite sheet
  64515. * @param name defines the manager's name
  64516. * @param imgUrl defines the sprite sheet url
  64517. * @param capacity defines the maximum allowed number of sprites
  64518. * @param scene defines the hosting scene
  64519. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64520. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64521. * @param samplingMode defines the smapling mode to use with spritesheet
  64522. * @param fromPacked set to true; do not alter
  64523. */
  64524. constructor(
  64525. /** defines the packed manager's name */
  64526. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64527. }
  64528. }
  64529. declare module BABYLON {
  64530. /**
  64531. * Defines the list of states available for a task inside a AssetsManager
  64532. */
  64533. export enum AssetTaskState {
  64534. /**
  64535. * Initialization
  64536. */
  64537. INIT = 0,
  64538. /**
  64539. * Running
  64540. */
  64541. RUNNING = 1,
  64542. /**
  64543. * Done
  64544. */
  64545. DONE = 2,
  64546. /**
  64547. * Error
  64548. */
  64549. ERROR = 3
  64550. }
  64551. /**
  64552. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64553. */
  64554. export abstract class AbstractAssetTask {
  64555. /**
  64556. * Task name
  64557. */ name: string;
  64558. /**
  64559. * Callback called when the task is successful
  64560. */
  64561. onSuccess: (task: any) => void;
  64562. /**
  64563. * Callback called when the task is not successful
  64564. */
  64565. onError: (task: any, message?: string, exception?: any) => void;
  64566. /**
  64567. * Creates a new AssetsManager
  64568. * @param name defines the name of the task
  64569. */
  64570. constructor(
  64571. /**
  64572. * Task name
  64573. */ name: string);
  64574. private _isCompleted;
  64575. private _taskState;
  64576. private _errorObject;
  64577. /**
  64578. * Get if the task is completed
  64579. */
  64580. readonly isCompleted: boolean;
  64581. /**
  64582. * Gets the current state of the task
  64583. */
  64584. readonly taskState: AssetTaskState;
  64585. /**
  64586. * Gets the current error object (if task is in error)
  64587. */
  64588. readonly errorObject: {
  64589. message?: string;
  64590. exception?: any;
  64591. };
  64592. /**
  64593. * Internal only
  64594. * @hidden
  64595. */
  64596. _setErrorObject(message?: string, exception?: any): void;
  64597. /**
  64598. * Execute the current task
  64599. * @param scene defines the scene where you want your assets to be loaded
  64600. * @param onSuccess is a callback called when the task is successfully executed
  64601. * @param onError is a callback called if an error occurs
  64602. */
  64603. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64604. /**
  64605. * Execute the current task
  64606. * @param scene defines the scene where you want your assets to be loaded
  64607. * @param onSuccess is a callback called when the task is successfully executed
  64608. * @param onError is a callback called if an error occurs
  64609. */
  64610. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64611. /**
  64612. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64613. * This can be used with failed tasks that have the reason for failure fixed.
  64614. */
  64615. reset(): void;
  64616. private onErrorCallback;
  64617. private onDoneCallback;
  64618. }
  64619. /**
  64620. * Define the interface used by progress events raised during assets loading
  64621. */
  64622. export interface IAssetsProgressEvent {
  64623. /**
  64624. * Defines the number of remaining tasks to process
  64625. */
  64626. remainingCount: number;
  64627. /**
  64628. * Defines the total number of tasks
  64629. */
  64630. totalCount: number;
  64631. /**
  64632. * Defines the task that was just processed
  64633. */
  64634. task: AbstractAssetTask;
  64635. }
  64636. /**
  64637. * Class used to share progress information about assets loading
  64638. */
  64639. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64640. /**
  64641. * Defines the number of remaining tasks to process
  64642. */
  64643. remainingCount: number;
  64644. /**
  64645. * Defines the total number of tasks
  64646. */
  64647. totalCount: number;
  64648. /**
  64649. * Defines the task that was just processed
  64650. */
  64651. task: AbstractAssetTask;
  64652. /**
  64653. * Creates a AssetsProgressEvent
  64654. * @param remainingCount defines the number of remaining tasks to process
  64655. * @param totalCount defines the total number of tasks
  64656. * @param task defines the task that was just processed
  64657. */
  64658. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64659. }
  64660. /**
  64661. * Define a task used by AssetsManager to load meshes
  64662. */
  64663. export class MeshAssetTask extends AbstractAssetTask {
  64664. /**
  64665. * Defines the name of the task
  64666. */
  64667. name: string;
  64668. /**
  64669. * Defines the list of mesh's names you want to load
  64670. */
  64671. meshesNames: any;
  64672. /**
  64673. * Defines the root url to use as a base to load your meshes and associated resources
  64674. */
  64675. rootUrl: string;
  64676. /**
  64677. * Defines the filename of the scene to load from
  64678. */
  64679. sceneFilename: string;
  64680. /**
  64681. * Gets the list of loaded meshes
  64682. */
  64683. loadedMeshes: Array<AbstractMesh>;
  64684. /**
  64685. * Gets the list of loaded particle systems
  64686. */
  64687. loadedParticleSystems: Array<IParticleSystem>;
  64688. /**
  64689. * Gets the list of loaded skeletons
  64690. */
  64691. loadedSkeletons: Array<Skeleton>;
  64692. /**
  64693. * Gets the list of loaded animation groups
  64694. */
  64695. loadedAnimationGroups: Array<AnimationGroup>;
  64696. /**
  64697. * Callback called when the task is successful
  64698. */
  64699. onSuccess: (task: MeshAssetTask) => void;
  64700. /**
  64701. * Callback called when the task is successful
  64702. */
  64703. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64704. /**
  64705. * Creates a new MeshAssetTask
  64706. * @param name defines the name of the task
  64707. * @param meshesNames defines the list of mesh's names you want to load
  64708. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64709. * @param sceneFilename defines the filename of the scene to load from
  64710. */
  64711. constructor(
  64712. /**
  64713. * Defines the name of the task
  64714. */
  64715. name: string,
  64716. /**
  64717. * Defines the list of mesh's names you want to load
  64718. */
  64719. meshesNames: any,
  64720. /**
  64721. * Defines the root url to use as a base to load your meshes and associated resources
  64722. */
  64723. rootUrl: string,
  64724. /**
  64725. * Defines the filename of the scene to load from
  64726. */
  64727. sceneFilename: string);
  64728. /**
  64729. * Execute the current task
  64730. * @param scene defines the scene where you want your assets to be loaded
  64731. * @param onSuccess is a callback called when the task is successfully executed
  64732. * @param onError is a callback called if an error occurs
  64733. */
  64734. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64735. }
  64736. /**
  64737. * Define a task used by AssetsManager to load text content
  64738. */
  64739. export class TextFileAssetTask extends AbstractAssetTask {
  64740. /**
  64741. * Defines the name of the task
  64742. */
  64743. name: string;
  64744. /**
  64745. * Defines the location of the file to load
  64746. */
  64747. url: string;
  64748. /**
  64749. * Gets the loaded text string
  64750. */
  64751. text: string;
  64752. /**
  64753. * Callback called when the task is successful
  64754. */
  64755. onSuccess: (task: TextFileAssetTask) => void;
  64756. /**
  64757. * Callback called when the task is successful
  64758. */
  64759. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64760. /**
  64761. * Creates a new TextFileAssetTask object
  64762. * @param name defines the name of the task
  64763. * @param url defines the location of the file to load
  64764. */
  64765. constructor(
  64766. /**
  64767. * Defines the name of the task
  64768. */
  64769. name: string,
  64770. /**
  64771. * Defines the location of the file to load
  64772. */
  64773. url: string);
  64774. /**
  64775. * Execute the current task
  64776. * @param scene defines the scene where you want your assets to be loaded
  64777. * @param onSuccess is a callback called when the task is successfully executed
  64778. * @param onError is a callback called if an error occurs
  64779. */
  64780. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64781. }
  64782. /**
  64783. * Define a task used by AssetsManager to load binary data
  64784. */
  64785. export class BinaryFileAssetTask extends AbstractAssetTask {
  64786. /**
  64787. * Defines the name of the task
  64788. */
  64789. name: string;
  64790. /**
  64791. * Defines the location of the file to load
  64792. */
  64793. url: string;
  64794. /**
  64795. * Gets the lodaded data (as an array buffer)
  64796. */
  64797. data: ArrayBuffer;
  64798. /**
  64799. * Callback called when the task is successful
  64800. */
  64801. onSuccess: (task: BinaryFileAssetTask) => void;
  64802. /**
  64803. * Callback called when the task is successful
  64804. */
  64805. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64806. /**
  64807. * Creates a new BinaryFileAssetTask object
  64808. * @param name defines the name of the new task
  64809. * @param url defines the location of the file to load
  64810. */
  64811. constructor(
  64812. /**
  64813. * Defines the name of the task
  64814. */
  64815. name: string,
  64816. /**
  64817. * Defines the location of the file to load
  64818. */
  64819. url: string);
  64820. /**
  64821. * Execute the current task
  64822. * @param scene defines the scene where you want your assets to be loaded
  64823. * @param onSuccess is a callback called when the task is successfully executed
  64824. * @param onError is a callback called if an error occurs
  64825. */
  64826. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64827. }
  64828. /**
  64829. * Define a task used by AssetsManager to load images
  64830. */
  64831. export class ImageAssetTask extends AbstractAssetTask {
  64832. /**
  64833. * Defines the name of the task
  64834. */
  64835. name: string;
  64836. /**
  64837. * Defines the location of the image to load
  64838. */
  64839. url: string;
  64840. /**
  64841. * Gets the loaded images
  64842. */
  64843. image: HTMLImageElement;
  64844. /**
  64845. * Callback called when the task is successful
  64846. */
  64847. onSuccess: (task: ImageAssetTask) => void;
  64848. /**
  64849. * Callback called when the task is successful
  64850. */
  64851. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64852. /**
  64853. * Creates a new ImageAssetTask
  64854. * @param name defines the name of the task
  64855. * @param url defines the location of the image to load
  64856. */
  64857. constructor(
  64858. /**
  64859. * Defines the name of the task
  64860. */
  64861. name: string,
  64862. /**
  64863. * Defines the location of the image to load
  64864. */
  64865. url: string);
  64866. /**
  64867. * Execute the current task
  64868. * @param scene defines the scene where you want your assets to be loaded
  64869. * @param onSuccess is a callback called when the task is successfully executed
  64870. * @param onError is a callback called if an error occurs
  64871. */
  64872. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64873. }
  64874. /**
  64875. * Defines the interface used by texture loading tasks
  64876. */
  64877. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64878. /**
  64879. * Gets the loaded texture
  64880. */
  64881. texture: TEX;
  64882. }
  64883. /**
  64884. * Define a task used by AssetsManager to load 2D textures
  64885. */
  64886. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64887. /**
  64888. * Defines the name of the task
  64889. */
  64890. name: string;
  64891. /**
  64892. * Defines the location of the file to load
  64893. */
  64894. url: string;
  64895. /**
  64896. * Defines if mipmap should not be generated (default is false)
  64897. */
  64898. noMipmap?: boolean | undefined;
  64899. /**
  64900. * Defines if texture must be inverted on Y axis (default is false)
  64901. */
  64902. invertY?: boolean | undefined;
  64903. /**
  64904. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64905. */
  64906. samplingMode: number;
  64907. /**
  64908. * Gets the loaded texture
  64909. */
  64910. texture: Texture;
  64911. /**
  64912. * Callback called when the task is successful
  64913. */
  64914. onSuccess: (task: TextureAssetTask) => void;
  64915. /**
  64916. * Callback called when the task is successful
  64917. */
  64918. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64919. /**
  64920. * Creates a new TextureAssetTask object
  64921. * @param name defines the name of the task
  64922. * @param url defines the location of the file to load
  64923. * @param noMipmap defines if mipmap should not be generated (default is false)
  64924. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64925. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64926. */
  64927. constructor(
  64928. /**
  64929. * Defines the name of the task
  64930. */
  64931. name: string,
  64932. /**
  64933. * Defines the location of the file to load
  64934. */
  64935. url: string,
  64936. /**
  64937. * Defines if mipmap should not be generated (default is false)
  64938. */
  64939. noMipmap?: boolean | undefined,
  64940. /**
  64941. * Defines if texture must be inverted on Y axis (default is false)
  64942. */
  64943. invertY?: boolean | undefined,
  64944. /**
  64945. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64946. */
  64947. samplingMode?: number);
  64948. /**
  64949. * Execute the current task
  64950. * @param scene defines the scene where you want your assets to be loaded
  64951. * @param onSuccess is a callback called when the task is successfully executed
  64952. * @param onError is a callback called if an error occurs
  64953. */
  64954. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64955. }
  64956. /**
  64957. * Define a task used by AssetsManager to load cube textures
  64958. */
  64959. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64960. /**
  64961. * Defines the name of the task
  64962. */
  64963. name: string;
  64964. /**
  64965. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64966. */
  64967. url: string;
  64968. /**
  64969. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64970. */
  64971. extensions?: string[] | undefined;
  64972. /**
  64973. * Defines if mipmaps should not be generated (default is false)
  64974. */
  64975. noMipmap?: boolean | undefined;
  64976. /**
  64977. * Defines the explicit list of files (undefined by default)
  64978. */
  64979. files?: string[] | undefined;
  64980. /**
  64981. * Gets the loaded texture
  64982. */
  64983. texture: CubeTexture;
  64984. /**
  64985. * Callback called when the task is successful
  64986. */
  64987. onSuccess: (task: CubeTextureAssetTask) => void;
  64988. /**
  64989. * Callback called when the task is successful
  64990. */
  64991. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64992. /**
  64993. * Creates a new CubeTextureAssetTask
  64994. * @param name defines the name of the task
  64995. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64996. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64997. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64998. * @param files defines the explicit list of files (undefined by default)
  64999. */
  65000. constructor(
  65001. /**
  65002. * Defines the name of the task
  65003. */
  65004. name: string,
  65005. /**
  65006. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65007. */
  65008. url: string,
  65009. /**
  65010. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65011. */
  65012. extensions?: string[] | undefined,
  65013. /**
  65014. * Defines if mipmaps should not be generated (default is false)
  65015. */
  65016. noMipmap?: boolean | undefined,
  65017. /**
  65018. * Defines the explicit list of files (undefined by default)
  65019. */
  65020. files?: string[] | undefined);
  65021. /**
  65022. * Execute the current task
  65023. * @param scene defines the scene where you want your assets to be loaded
  65024. * @param onSuccess is a callback called when the task is successfully executed
  65025. * @param onError is a callback called if an error occurs
  65026. */
  65027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65028. }
  65029. /**
  65030. * Define a task used by AssetsManager to load HDR cube textures
  65031. */
  65032. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65033. /**
  65034. * Defines the name of the task
  65035. */
  65036. name: string;
  65037. /**
  65038. * Defines the location of the file to load
  65039. */
  65040. url: string;
  65041. /**
  65042. * Defines the desired size (the more it increases the longer the generation will be)
  65043. */
  65044. size: number;
  65045. /**
  65046. * Defines if mipmaps should not be generated (default is false)
  65047. */
  65048. noMipmap: boolean;
  65049. /**
  65050. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65051. */
  65052. generateHarmonics: boolean;
  65053. /**
  65054. * 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)
  65055. */
  65056. gammaSpace: boolean;
  65057. /**
  65058. * Internal Use Only
  65059. */
  65060. reserved: boolean;
  65061. /**
  65062. * Gets the loaded texture
  65063. */
  65064. texture: HDRCubeTexture;
  65065. /**
  65066. * Callback called when the task is successful
  65067. */
  65068. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65069. /**
  65070. * Callback called when the task is successful
  65071. */
  65072. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65073. /**
  65074. * Creates a new HDRCubeTextureAssetTask object
  65075. * @param name defines the name of the task
  65076. * @param url defines the location of the file to load
  65077. * @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.
  65078. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65079. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65080. * @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)
  65081. * @param reserved Internal use only
  65082. */
  65083. constructor(
  65084. /**
  65085. * Defines the name of the task
  65086. */
  65087. name: string,
  65088. /**
  65089. * Defines the location of the file to load
  65090. */
  65091. url: string,
  65092. /**
  65093. * Defines the desired size (the more it increases the longer the generation will be)
  65094. */
  65095. size: number,
  65096. /**
  65097. * Defines if mipmaps should not be generated (default is false)
  65098. */
  65099. noMipmap?: boolean,
  65100. /**
  65101. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65102. */
  65103. generateHarmonics?: boolean,
  65104. /**
  65105. * 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)
  65106. */
  65107. gammaSpace?: boolean,
  65108. /**
  65109. * Internal Use Only
  65110. */
  65111. reserved?: boolean);
  65112. /**
  65113. * Execute the current task
  65114. * @param scene defines the scene where you want your assets to be loaded
  65115. * @param onSuccess is a callback called when the task is successfully executed
  65116. * @param onError is a callback called if an error occurs
  65117. */
  65118. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65119. }
  65120. /**
  65121. * Define a task used by AssetsManager to load Equirectangular cube textures
  65122. */
  65123. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65124. /**
  65125. * Defines the name of the task
  65126. */
  65127. name: string;
  65128. /**
  65129. * Defines the location of the file to load
  65130. */
  65131. url: string;
  65132. /**
  65133. * Defines the desired size (the more it increases the longer the generation will be)
  65134. */
  65135. size: number;
  65136. /**
  65137. * Defines if mipmaps should not be generated (default is false)
  65138. */
  65139. noMipmap: boolean;
  65140. /**
  65141. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65142. * but the standard material would require them in Gamma space) (default is true)
  65143. */
  65144. gammaSpace: boolean;
  65145. /**
  65146. * Gets the loaded texture
  65147. */
  65148. texture: EquiRectangularCubeTexture;
  65149. /**
  65150. * Callback called when the task is successful
  65151. */
  65152. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65153. /**
  65154. * Callback called when the task is successful
  65155. */
  65156. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65157. /**
  65158. * Creates a new EquiRectangularCubeTextureAssetTask object
  65159. * @param name defines the name of the task
  65160. * @param url defines the location of the file to load
  65161. * @param size defines the desired size (the more it increases the longer the generation will be)
  65162. * If the size is omitted this implies you are using a preprocessed cubemap.
  65163. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65164. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65165. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65166. * (default is true)
  65167. */
  65168. constructor(
  65169. /**
  65170. * Defines the name of the task
  65171. */
  65172. name: string,
  65173. /**
  65174. * Defines the location of the file to load
  65175. */
  65176. url: string,
  65177. /**
  65178. * Defines the desired size (the more it increases the longer the generation will be)
  65179. */
  65180. size: number,
  65181. /**
  65182. * Defines if mipmaps should not be generated (default is false)
  65183. */
  65184. noMipmap?: boolean,
  65185. /**
  65186. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65187. * but the standard material would require them in Gamma space) (default is true)
  65188. */
  65189. gammaSpace?: boolean);
  65190. /**
  65191. * Execute the current task
  65192. * @param scene defines the scene where you want your assets to be loaded
  65193. * @param onSuccess is a callback called when the task is successfully executed
  65194. * @param onError is a callback called if an error occurs
  65195. */
  65196. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65197. }
  65198. /**
  65199. * This class can be used to easily import assets into a scene
  65200. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65201. */
  65202. export class AssetsManager {
  65203. private _scene;
  65204. private _isLoading;
  65205. protected _tasks: AbstractAssetTask[];
  65206. protected _waitingTasksCount: number;
  65207. protected _totalTasksCount: number;
  65208. /**
  65209. * Callback called when all tasks are processed
  65210. */
  65211. onFinish: (tasks: AbstractAssetTask[]) => void;
  65212. /**
  65213. * Callback called when a task is successful
  65214. */
  65215. onTaskSuccess: (task: AbstractAssetTask) => void;
  65216. /**
  65217. * Callback called when a task had an error
  65218. */
  65219. onTaskError: (task: AbstractAssetTask) => void;
  65220. /**
  65221. * Callback called when a task is done (whatever the result is)
  65222. */
  65223. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65224. /**
  65225. * Observable called when all tasks are processed
  65226. */
  65227. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65228. /**
  65229. * Observable called when a task had an error
  65230. */
  65231. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65232. /**
  65233. * Observable called when all tasks were executed
  65234. */
  65235. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65236. /**
  65237. * Observable called when a task is done (whatever the result is)
  65238. */
  65239. onProgressObservable: Observable<IAssetsProgressEvent>;
  65240. /**
  65241. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65242. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65243. */
  65244. useDefaultLoadingScreen: boolean;
  65245. /**
  65246. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65247. * when all assets have been downloaded.
  65248. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65249. */
  65250. autoHideLoadingUI: boolean;
  65251. /**
  65252. * Creates a new AssetsManager
  65253. * @param scene defines the scene to work on
  65254. */
  65255. constructor(scene: Scene);
  65256. /**
  65257. * Add a MeshAssetTask to the list of active tasks
  65258. * @param taskName defines the name of the new task
  65259. * @param meshesNames defines the name of meshes to load
  65260. * @param rootUrl defines the root url to use to locate files
  65261. * @param sceneFilename defines the filename of the scene file
  65262. * @returns a new MeshAssetTask object
  65263. */
  65264. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65265. /**
  65266. * Add a TextFileAssetTask to the list of active tasks
  65267. * @param taskName defines the name of the new task
  65268. * @param url defines the url of the file to load
  65269. * @returns a new TextFileAssetTask object
  65270. */
  65271. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65272. /**
  65273. * Add a BinaryFileAssetTask to the list of active tasks
  65274. * @param taskName defines the name of the new task
  65275. * @param url defines the url of the file to load
  65276. * @returns a new BinaryFileAssetTask object
  65277. */
  65278. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65279. /**
  65280. * Add a ImageAssetTask to the list of active tasks
  65281. * @param taskName defines the name of the new task
  65282. * @param url defines the url of the file to load
  65283. * @returns a new ImageAssetTask object
  65284. */
  65285. addImageTask(taskName: string, url: string): ImageAssetTask;
  65286. /**
  65287. * Add a TextureAssetTask to the list of active tasks
  65288. * @param taskName defines the name of the new task
  65289. * @param url defines the url of the file to load
  65290. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65291. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65292. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65293. * @returns a new TextureAssetTask object
  65294. */
  65295. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65296. /**
  65297. * Add a CubeTextureAssetTask to the list of active tasks
  65298. * @param taskName defines the name of the new task
  65299. * @param url defines the url of the file to load
  65300. * @param extensions defines the extension to use to load the cube map (can be null)
  65301. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65302. * @param files defines the list of files to load (can be null)
  65303. * @returns a new CubeTextureAssetTask object
  65304. */
  65305. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65306. /**
  65307. *
  65308. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65309. * @param taskName defines the name of the new task
  65310. * @param url defines the url of the file to load
  65311. * @param size defines the size you want for the cubemap (can be null)
  65312. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65313. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65314. * @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)
  65315. * @param reserved Internal use only
  65316. * @returns a new HDRCubeTextureAssetTask object
  65317. */
  65318. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65319. /**
  65320. *
  65321. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65322. * @param taskName defines the name of the new task
  65323. * @param url defines the url of the file to load
  65324. * @param size defines the size you want for the cubemap (can be null)
  65325. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65326. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65327. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65328. * @returns a new EquiRectangularCubeTextureAssetTask object
  65329. */
  65330. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65331. /**
  65332. * Remove a task from the assets manager.
  65333. * @param task the task to remove
  65334. */
  65335. removeTask(task: AbstractAssetTask): void;
  65336. private _decreaseWaitingTasksCount;
  65337. private _runTask;
  65338. /**
  65339. * Reset the AssetsManager and remove all tasks
  65340. * @return the current instance of the AssetsManager
  65341. */
  65342. reset(): AssetsManager;
  65343. /**
  65344. * Start the loading process
  65345. * @return the current instance of the AssetsManager
  65346. */
  65347. load(): AssetsManager;
  65348. /**
  65349. * Start the loading process as an async operation
  65350. * @return a promise returning the list of failed tasks
  65351. */
  65352. loadAsync(): Promise<void>;
  65353. }
  65354. }
  65355. declare module BABYLON {
  65356. /**
  65357. * Wrapper class for promise with external resolve and reject.
  65358. */
  65359. export class Deferred<T> {
  65360. /**
  65361. * The promise associated with this deferred object.
  65362. */
  65363. readonly promise: Promise<T>;
  65364. private _resolve;
  65365. private _reject;
  65366. /**
  65367. * The resolve method of the promise associated with this deferred object.
  65368. */
  65369. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65370. /**
  65371. * The reject method of the promise associated with this deferred object.
  65372. */
  65373. readonly reject: (reason?: any) => void;
  65374. /**
  65375. * Constructor for this deferred object.
  65376. */
  65377. constructor();
  65378. }
  65379. }
  65380. declare module BABYLON {
  65381. /**
  65382. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65383. */
  65384. export class MeshExploder {
  65385. private _centerMesh;
  65386. private _meshes;
  65387. private _meshesOrigins;
  65388. private _toCenterVectors;
  65389. private _scaledDirection;
  65390. private _newPosition;
  65391. private _centerPosition;
  65392. /**
  65393. * Explodes meshes from a center mesh.
  65394. * @param meshes The meshes to explode.
  65395. * @param centerMesh The mesh to be center of explosion.
  65396. */
  65397. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65398. private _setCenterMesh;
  65399. /**
  65400. * Get class name
  65401. * @returns "MeshExploder"
  65402. */
  65403. getClassName(): string;
  65404. /**
  65405. * "Exploded meshes"
  65406. * @returns Array of meshes with the centerMesh at index 0.
  65407. */
  65408. getMeshes(): Array<Mesh>;
  65409. /**
  65410. * Explodes meshes giving a specific direction
  65411. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65412. */
  65413. explode(direction?: number): void;
  65414. }
  65415. }
  65416. declare module BABYLON {
  65417. /**
  65418. * Class used to help managing file picking and drag'n'drop
  65419. */
  65420. export class FilesInput {
  65421. /**
  65422. * List of files ready to be loaded
  65423. */
  65424. static readonly FilesToLoad: {
  65425. [key: string]: File;
  65426. };
  65427. /**
  65428. * Callback called when a file is processed
  65429. */
  65430. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65431. private _engine;
  65432. private _currentScene;
  65433. private _sceneLoadedCallback;
  65434. private _progressCallback;
  65435. private _additionalRenderLoopLogicCallback;
  65436. private _textureLoadingCallback;
  65437. private _startingProcessingFilesCallback;
  65438. private _onReloadCallback;
  65439. private _errorCallback;
  65440. private _elementToMonitor;
  65441. private _sceneFileToLoad;
  65442. private _filesToLoad;
  65443. /**
  65444. * Creates a new FilesInput
  65445. * @param engine defines the rendering engine
  65446. * @param scene defines the hosting scene
  65447. * @param sceneLoadedCallback callback called when scene is loaded
  65448. * @param progressCallback callback called to track progress
  65449. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65450. * @param textureLoadingCallback callback called when a texture is loading
  65451. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65452. * @param onReloadCallback callback called when a reload is requested
  65453. * @param errorCallback callback call if an error occurs
  65454. */
  65455. 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);
  65456. private _dragEnterHandler;
  65457. private _dragOverHandler;
  65458. private _dropHandler;
  65459. /**
  65460. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65461. * @param elementToMonitor defines the DOM element to track
  65462. */
  65463. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65464. /**
  65465. * Release all associated resources
  65466. */
  65467. dispose(): void;
  65468. private renderFunction;
  65469. private drag;
  65470. private drop;
  65471. private _traverseFolder;
  65472. private _processFiles;
  65473. /**
  65474. * Load files from a drop event
  65475. * @param event defines the drop event to use as source
  65476. */
  65477. loadFiles(event: any): void;
  65478. private _processReload;
  65479. /**
  65480. * Reload the current scene from the loaded files
  65481. */
  65482. reload(): void;
  65483. }
  65484. }
  65485. declare module BABYLON {
  65486. /**
  65487. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65488. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65489. */
  65490. export class SceneOptimization {
  65491. /**
  65492. * Defines the priority of this optimization (0 by default which means first in the list)
  65493. */
  65494. priority: number;
  65495. /**
  65496. * Gets a string describing the action executed by the current optimization
  65497. * @returns description string
  65498. */
  65499. getDescription(): string;
  65500. /**
  65501. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65502. * @param scene defines the current scene where to apply this optimization
  65503. * @param optimizer defines the current optimizer
  65504. * @returns true if everything that can be done was applied
  65505. */
  65506. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65507. /**
  65508. * Creates the SceneOptimization object
  65509. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65510. * @param desc defines the description associated with the optimization
  65511. */
  65512. constructor(
  65513. /**
  65514. * Defines the priority of this optimization (0 by default which means first in the list)
  65515. */
  65516. priority?: number);
  65517. }
  65518. /**
  65519. * Defines an optimization used to reduce the size of render target textures
  65520. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65521. */
  65522. export class TextureOptimization extends SceneOptimization {
  65523. /**
  65524. * Defines the priority of this optimization (0 by default which means first in the list)
  65525. */
  65526. priority: number;
  65527. /**
  65528. * 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
  65529. */
  65530. maximumSize: number;
  65531. /**
  65532. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65533. */
  65534. step: number;
  65535. /**
  65536. * Gets a string describing the action executed by the current optimization
  65537. * @returns description string
  65538. */
  65539. getDescription(): string;
  65540. /**
  65541. * Creates the TextureOptimization object
  65542. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65543. * @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
  65544. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65545. */
  65546. constructor(
  65547. /**
  65548. * Defines the priority of this optimization (0 by default which means first in the list)
  65549. */
  65550. priority?: number,
  65551. /**
  65552. * 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
  65553. */
  65554. maximumSize?: number,
  65555. /**
  65556. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65557. */
  65558. step?: number);
  65559. /**
  65560. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65561. * @param scene defines the current scene where to apply this optimization
  65562. * @param optimizer defines the current optimizer
  65563. * @returns true if everything that can be done was applied
  65564. */
  65565. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65566. }
  65567. /**
  65568. * Defines an optimization used to increase or decrease the rendering resolution
  65569. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65570. */
  65571. export class HardwareScalingOptimization extends SceneOptimization {
  65572. /**
  65573. * Defines the priority of this optimization (0 by default which means first in the list)
  65574. */
  65575. priority: number;
  65576. /**
  65577. * Defines the maximum scale to use (2 by default)
  65578. */
  65579. maximumScale: number;
  65580. /**
  65581. * Defines the step to use between two passes (0.5 by default)
  65582. */
  65583. step: number;
  65584. private _currentScale;
  65585. private _directionOffset;
  65586. /**
  65587. * Gets a string describing the action executed by the current optimization
  65588. * @return description string
  65589. */
  65590. getDescription(): string;
  65591. /**
  65592. * Creates the HardwareScalingOptimization object
  65593. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65594. * @param maximumScale defines the maximum scale to use (2 by default)
  65595. * @param step defines the step to use between two passes (0.5 by default)
  65596. */
  65597. constructor(
  65598. /**
  65599. * Defines the priority of this optimization (0 by default which means first in the list)
  65600. */
  65601. priority?: number,
  65602. /**
  65603. * Defines the maximum scale to use (2 by default)
  65604. */
  65605. maximumScale?: number,
  65606. /**
  65607. * Defines the step to use between two passes (0.5 by default)
  65608. */
  65609. step?: number);
  65610. /**
  65611. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65612. * @param scene defines the current scene where to apply this optimization
  65613. * @param optimizer defines the current optimizer
  65614. * @returns true if everything that can be done was applied
  65615. */
  65616. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65617. }
  65618. /**
  65619. * Defines an optimization used to remove shadows
  65620. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65621. */
  65622. export class ShadowsOptimization extends SceneOptimization {
  65623. /**
  65624. * Gets a string describing the action executed by the current optimization
  65625. * @return description string
  65626. */
  65627. getDescription(): string;
  65628. /**
  65629. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65630. * @param scene defines the current scene where to apply this optimization
  65631. * @param optimizer defines the current optimizer
  65632. * @returns true if everything that can be done was applied
  65633. */
  65634. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65635. }
  65636. /**
  65637. * Defines an optimization used to turn post-processes off
  65638. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65639. */
  65640. export class PostProcessesOptimization extends SceneOptimization {
  65641. /**
  65642. * Gets a string describing the action executed by the current optimization
  65643. * @return description string
  65644. */
  65645. getDescription(): string;
  65646. /**
  65647. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65648. * @param scene defines the current scene where to apply this optimization
  65649. * @param optimizer defines the current optimizer
  65650. * @returns true if everything that can be done was applied
  65651. */
  65652. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65653. }
  65654. /**
  65655. * Defines an optimization used to turn lens flares off
  65656. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65657. */
  65658. export class LensFlaresOptimization extends SceneOptimization {
  65659. /**
  65660. * Gets a string describing the action executed by the current optimization
  65661. * @return description string
  65662. */
  65663. getDescription(): string;
  65664. /**
  65665. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65666. * @param scene defines the current scene where to apply this optimization
  65667. * @param optimizer defines the current optimizer
  65668. * @returns true if everything that can be done was applied
  65669. */
  65670. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65671. }
  65672. /**
  65673. * Defines an optimization based on user defined callback.
  65674. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65675. */
  65676. export class CustomOptimization extends SceneOptimization {
  65677. /**
  65678. * Callback called to apply the custom optimization.
  65679. */
  65680. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65681. /**
  65682. * Callback called to get custom description
  65683. */
  65684. onGetDescription: () => string;
  65685. /**
  65686. * Gets a string describing the action executed by the current optimization
  65687. * @returns description string
  65688. */
  65689. getDescription(): string;
  65690. /**
  65691. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65692. * @param scene defines the current scene where to apply this optimization
  65693. * @param optimizer defines the current optimizer
  65694. * @returns true if everything that can be done was applied
  65695. */
  65696. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65697. }
  65698. /**
  65699. * Defines an optimization used to turn particles off
  65700. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65701. */
  65702. export class ParticlesOptimization extends SceneOptimization {
  65703. /**
  65704. * Gets a string describing the action executed by the current optimization
  65705. * @return description string
  65706. */
  65707. getDescription(): string;
  65708. /**
  65709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65710. * @param scene defines the current scene where to apply this optimization
  65711. * @param optimizer defines the current optimizer
  65712. * @returns true if everything that can be done was applied
  65713. */
  65714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65715. }
  65716. /**
  65717. * Defines an optimization used to turn render targets off
  65718. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65719. */
  65720. export class RenderTargetsOptimization extends SceneOptimization {
  65721. /**
  65722. * Gets a string describing the action executed by the current optimization
  65723. * @return description string
  65724. */
  65725. getDescription(): string;
  65726. /**
  65727. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65728. * @param scene defines the current scene where to apply this optimization
  65729. * @param optimizer defines the current optimizer
  65730. * @returns true if everything that can be done was applied
  65731. */
  65732. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65733. }
  65734. /**
  65735. * Defines an optimization used to merge meshes with compatible materials
  65736. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65737. */
  65738. export class MergeMeshesOptimization extends SceneOptimization {
  65739. private static _UpdateSelectionTree;
  65740. /**
  65741. * Gets or sets a boolean which defines if optimization octree has to be updated
  65742. */
  65743. /**
  65744. * Gets or sets a boolean which defines if optimization octree has to be updated
  65745. */
  65746. static UpdateSelectionTree: boolean;
  65747. /**
  65748. * Gets a string describing the action executed by the current optimization
  65749. * @return description string
  65750. */
  65751. getDescription(): string;
  65752. private _canBeMerged;
  65753. /**
  65754. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65755. * @param scene defines the current scene where to apply this optimization
  65756. * @param optimizer defines the current optimizer
  65757. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65758. * @returns true if everything that can be done was applied
  65759. */
  65760. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65761. }
  65762. /**
  65763. * Defines a list of options used by SceneOptimizer
  65764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65765. */
  65766. export class SceneOptimizerOptions {
  65767. /**
  65768. * Defines the target frame rate to reach (60 by default)
  65769. */
  65770. targetFrameRate: number;
  65771. /**
  65772. * Defines the interval between two checkes (2000ms by default)
  65773. */
  65774. trackerDuration: number;
  65775. /**
  65776. * Gets the list of optimizations to apply
  65777. */
  65778. optimizations: SceneOptimization[];
  65779. /**
  65780. * Creates a new list of options used by SceneOptimizer
  65781. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65782. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65783. */
  65784. constructor(
  65785. /**
  65786. * Defines the target frame rate to reach (60 by default)
  65787. */
  65788. targetFrameRate?: number,
  65789. /**
  65790. * Defines the interval between two checkes (2000ms by default)
  65791. */
  65792. trackerDuration?: number);
  65793. /**
  65794. * Add a new optimization
  65795. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65796. * @returns the current SceneOptimizerOptions
  65797. */
  65798. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65799. /**
  65800. * Add a new custom optimization
  65801. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65802. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65803. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65804. * @returns the current SceneOptimizerOptions
  65805. */
  65806. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65807. /**
  65808. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65809. * @param targetFrameRate defines the target frame rate (60 by default)
  65810. * @returns a SceneOptimizerOptions object
  65811. */
  65812. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65813. /**
  65814. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65815. * @param targetFrameRate defines the target frame rate (60 by default)
  65816. * @returns a SceneOptimizerOptions object
  65817. */
  65818. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65819. /**
  65820. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65821. * @param targetFrameRate defines the target frame rate (60 by default)
  65822. * @returns a SceneOptimizerOptions object
  65823. */
  65824. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65825. }
  65826. /**
  65827. * Class used to run optimizations in order to reach a target frame rate
  65828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65829. */
  65830. export class SceneOptimizer implements IDisposable {
  65831. private _isRunning;
  65832. private _options;
  65833. private _scene;
  65834. private _currentPriorityLevel;
  65835. private _targetFrameRate;
  65836. private _trackerDuration;
  65837. private _currentFrameRate;
  65838. private _sceneDisposeObserver;
  65839. private _improvementMode;
  65840. /**
  65841. * Defines an observable called when the optimizer reaches the target frame rate
  65842. */
  65843. onSuccessObservable: Observable<SceneOptimizer>;
  65844. /**
  65845. * Defines an observable called when the optimizer enables an optimization
  65846. */
  65847. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65848. /**
  65849. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65850. */
  65851. onFailureObservable: Observable<SceneOptimizer>;
  65852. /**
  65853. * Gets a boolean indicating if the optimizer is in improvement mode
  65854. */
  65855. readonly isInImprovementMode: boolean;
  65856. /**
  65857. * Gets the current priority level (0 at start)
  65858. */
  65859. readonly currentPriorityLevel: number;
  65860. /**
  65861. * Gets the current frame rate checked by the SceneOptimizer
  65862. */
  65863. readonly currentFrameRate: number;
  65864. /**
  65865. * Gets or sets the current target frame rate (60 by default)
  65866. */
  65867. /**
  65868. * Gets or sets the current target frame rate (60 by default)
  65869. */
  65870. targetFrameRate: number;
  65871. /**
  65872. * Gets or sets the current interval between two checks (every 2000ms by default)
  65873. */
  65874. /**
  65875. * Gets or sets the current interval between two checks (every 2000ms by default)
  65876. */
  65877. trackerDuration: number;
  65878. /**
  65879. * Gets the list of active optimizations
  65880. */
  65881. readonly optimizations: SceneOptimization[];
  65882. /**
  65883. * Creates a new SceneOptimizer
  65884. * @param scene defines the scene to work on
  65885. * @param options defines the options to use with the SceneOptimizer
  65886. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65887. * @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)
  65888. */
  65889. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65890. /**
  65891. * Stops the current optimizer
  65892. */
  65893. stop(): void;
  65894. /**
  65895. * Reset the optimizer to initial step (current priority level = 0)
  65896. */
  65897. reset(): void;
  65898. /**
  65899. * Start the optimizer. By default it will try to reach a specific framerate
  65900. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65901. */
  65902. start(): void;
  65903. private _checkCurrentState;
  65904. /**
  65905. * Release all resources
  65906. */
  65907. dispose(): void;
  65908. /**
  65909. * Helper function to create a SceneOptimizer with one single line of code
  65910. * @param scene defines the scene to work on
  65911. * @param options defines the options to use with the SceneOptimizer
  65912. * @param onSuccess defines a callback to call on success
  65913. * @param onFailure defines a callback to call on failure
  65914. * @returns the new SceneOptimizer object
  65915. */
  65916. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65917. }
  65918. }
  65919. declare module BABYLON {
  65920. /**
  65921. * Class used to serialize a scene into a string
  65922. */
  65923. export class SceneSerializer {
  65924. /**
  65925. * Clear cache used by a previous serialization
  65926. */
  65927. static ClearCache(): void;
  65928. /**
  65929. * Serialize a scene into a JSON compatible object
  65930. * @param scene defines the scene to serialize
  65931. * @returns a JSON compatible object
  65932. */
  65933. static Serialize(scene: Scene): any;
  65934. /**
  65935. * Serialize a mesh into a JSON compatible object
  65936. * @param toSerialize defines the mesh to serialize
  65937. * @param withParents defines if parents must be serialized as well
  65938. * @param withChildren defines if children must be serialized as well
  65939. * @returns a JSON compatible object
  65940. */
  65941. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65942. }
  65943. }
  65944. declare module BABYLON {
  65945. /**
  65946. * Class used to host texture specific utilities
  65947. */
  65948. export class TextureTools {
  65949. /**
  65950. * Uses the GPU to create a copy texture rescaled at a given size
  65951. * @param texture Texture to copy from
  65952. * @param width defines the desired width
  65953. * @param height defines the desired height
  65954. * @param useBilinearMode defines if bilinear mode has to be used
  65955. * @return the generated texture
  65956. */
  65957. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65958. }
  65959. }
  65960. declare module BABYLON {
  65961. /**
  65962. * This represents the different options available for the video capture.
  65963. */
  65964. export interface VideoRecorderOptions {
  65965. /** Defines the mime type of the video. */
  65966. mimeType: string;
  65967. /** Defines the FPS the video should be recorded at. */
  65968. fps: number;
  65969. /** Defines the chunk size for the recording data. */
  65970. recordChunckSize: number;
  65971. /** The audio tracks to attach to the recording. */
  65972. audioTracks?: MediaStreamTrack[];
  65973. }
  65974. /**
  65975. * This can help with recording videos from BabylonJS.
  65976. * This is based on the available WebRTC functionalities of the browser.
  65977. *
  65978. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65979. */
  65980. export class VideoRecorder {
  65981. private static readonly _defaultOptions;
  65982. /**
  65983. * Returns whether or not the VideoRecorder is available in your browser.
  65984. * @param engine Defines the Babylon Engine.
  65985. * @returns true if supported otherwise false.
  65986. */
  65987. static IsSupported(engine: Engine): boolean;
  65988. private readonly _options;
  65989. private _canvas;
  65990. private _mediaRecorder;
  65991. private _recordedChunks;
  65992. private _fileName;
  65993. private _resolve;
  65994. private _reject;
  65995. /**
  65996. * True when a recording is already in progress.
  65997. */
  65998. readonly isRecording: boolean;
  65999. /**
  66000. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66001. * @param engine Defines the BabylonJS Engine you wish to record.
  66002. * @param options Defines options that can be used to customize the capture.
  66003. */
  66004. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66005. /**
  66006. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66007. */
  66008. stopRecording(): void;
  66009. /**
  66010. * Starts recording the canvas for a max duration specified in parameters.
  66011. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66012. * If null no automatic download will start and you can rely on the promise to get the data back.
  66013. * @param maxDuration Defines the maximum recording time in seconds.
  66014. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66015. * @return A promise callback at the end of the recording with the video data in Blob.
  66016. */
  66017. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66018. /**
  66019. * Releases internal resources used during the recording.
  66020. */
  66021. dispose(): void;
  66022. private _handleDataAvailable;
  66023. private _handleError;
  66024. private _handleStop;
  66025. }
  66026. }
  66027. declare module BABYLON {
  66028. /**
  66029. * Class containing a set of static utilities functions for screenshots
  66030. */
  66031. export class ScreenshotTools {
  66032. /**
  66033. * Captures a screenshot of the current rendering
  66034. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66035. * @param engine defines the rendering engine
  66036. * @param camera defines the source camera
  66037. * @param size This parameter can be set to a single number or to an object with the
  66038. * following (optional) properties: precision, width, height. If a single number is passed,
  66039. * it will be used for both width and height. If an object is passed, the screenshot size
  66040. * will be derived from the parameters. The precision property is a multiplier allowing
  66041. * rendering at a higher or lower resolution
  66042. * @param successCallback defines the callback receives a single parameter which contains the
  66043. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66044. * src parameter of an <img> to display it
  66045. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66046. * Check your browser for supported MIME types
  66047. */
  66048. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66049. /**
  66050. * Captures a screenshot of the current rendering
  66051. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66052. * @param engine defines the rendering engine
  66053. * @param camera defines the source camera
  66054. * @param size This parameter can be set to a single number or to an object with the
  66055. * following (optional) properties: precision, width, height. If a single number is passed,
  66056. * it will be used for both width and height. If an object is passed, the screenshot size
  66057. * will be derived from the parameters. The precision property is a multiplier allowing
  66058. * rendering at a higher or lower resolution
  66059. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66060. * Check your browser for supported MIME types
  66061. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66062. * to the src parameter of an <img> to display it
  66063. */
  66064. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66065. /**
  66066. * Generates an image screenshot from the specified camera.
  66067. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66068. * @param engine The engine to use for rendering
  66069. * @param camera The camera to use for rendering
  66070. * @param size This parameter can be set to a single number or to an object with the
  66071. * following (optional) properties: precision, width, height. If a single number is passed,
  66072. * it will be used for both width and height. If an object is passed, the screenshot size
  66073. * will be derived from the parameters. The precision property is a multiplier allowing
  66074. * rendering at a higher or lower resolution
  66075. * @param successCallback The callback receives a single parameter which contains the
  66076. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66077. * src parameter of an <img> to display it
  66078. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66079. * Check your browser for supported MIME types
  66080. * @param samples Texture samples (default: 1)
  66081. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66082. * @param fileName A name for for the downloaded file.
  66083. */
  66084. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66085. /**
  66086. * Generates an image screenshot from the specified camera.
  66087. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66088. * @param engine The engine to use for rendering
  66089. * @param camera The camera to use for rendering
  66090. * @param size This parameter can be set to a single number or to an object with the
  66091. * following (optional) properties: precision, width, height. If a single number is passed,
  66092. * it will be used for both width and height. If an object is passed, the screenshot size
  66093. * will be derived from the parameters. The precision property is a multiplier allowing
  66094. * rendering at a higher or lower resolution
  66095. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66096. * Check your browser for supported MIME types
  66097. * @param samples Texture samples (default: 1)
  66098. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66099. * @param fileName A name for for the downloaded file.
  66100. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66101. * to the src parameter of an <img> to display it
  66102. */
  66103. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66104. /**
  66105. * Gets height and width for screenshot size
  66106. * @private
  66107. */
  66108. private static _getScreenshotSize;
  66109. }
  66110. }
  66111. declare module BABYLON {
  66112. /**
  66113. * Interface for a data buffer
  66114. */
  66115. export interface IDataBuffer {
  66116. /**
  66117. * Reads bytes from the data buffer.
  66118. * @param byteOffset The byte offset to read
  66119. * @param byteLength The byte length to read
  66120. * @returns A promise that resolves when the bytes are read
  66121. */
  66122. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  66123. /**
  66124. * The byte length of the buffer.
  66125. */
  66126. readonly byteLength: number;
  66127. }
  66128. /**
  66129. * Utility class for reading from a data buffer
  66130. */
  66131. export class DataReader {
  66132. /**
  66133. * The data buffer associated with this data reader.
  66134. */
  66135. readonly buffer: IDataBuffer;
  66136. /**
  66137. * The current byte offset from the beginning of the data buffer.
  66138. */
  66139. byteOffset: number;
  66140. private _dataView;
  66141. private _dataByteOffset;
  66142. /**
  66143. * Constructor
  66144. * @param buffer The buffer to read
  66145. */
  66146. constructor(buffer: IDataBuffer);
  66147. /**
  66148. * Loads the given byte length.
  66149. * @param byteLength The byte length to load
  66150. * @returns A promise that resolves when the load is complete
  66151. */
  66152. loadAsync(byteLength: number): Promise<void>;
  66153. /**
  66154. * Read a unsigned 32-bit integer from the currently loaded data range.
  66155. * @returns The 32-bit integer read
  66156. */
  66157. readUint32(): number;
  66158. /**
  66159. * Read a byte array from the currently loaded data range.
  66160. * @param byteLength The byte length to read
  66161. * @returns The byte array read
  66162. */
  66163. readUint8Array(byteLength: number): Uint8Array;
  66164. /**
  66165. * Read a string from the currently loaded data range.
  66166. * @param byteLength The byte length to read
  66167. * @returns The string read
  66168. */
  66169. readString(byteLength: number): string;
  66170. /**
  66171. * Skips the given byte length the currently loaded data range.
  66172. * @param byteLength The byte length to skip
  66173. */
  66174. skipBytes(byteLength: number): void;
  66175. }
  66176. }
  66177. declare module BABYLON {
  66178. /**
  66179. * A cursor which tracks a point on a path
  66180. */
  66181. export class PathCursor {
  66182. private path;
  66183. /**
  66184. * Stores path cursor callbacks for when an onchange event is triggered
  66185. */
  66186. private _onchange;
  66187. /**
  66188. * The value of the path cursor
  66189. */
  66190. value: number;
  66191. /**
  66192. * The animation array of the path cursor
  66193. */
  66194. animations: Animation[];
  66195. /**
  66196. * Initializes the path cursor
  66197. * @param path The path to track
  66198. */
  66199. constructor(path: Path2);
  66200. /**
  66201. * Gets the cursor point on the path
  66202. * @returns A point on the path cursor at the cursor location
  66203. */
  66204. getPoint(): Vector3;
  66205. /**
  66206. * Moves the cursor ahead by the step amount
  66207. * @param step The amount to move the cursor forward
  66208. * @returns This path cursor
  66209. */
  66210. moveAhead(step?: number): PathCursor;
  66211. /**
  66212. * Moves the cursor behind by the step amount
  66213. * @param step The amount to move the cursor back
  66214. * @returns This path cursor
  66215. */
  66216. moveBack(step?: number): PathCursor;
  66217. /**
  66218. * Moves the cursor by the step amount
  66219. * If the step amount is greater than one, an exception is thrown
  66220. * @param step The amount to move the cursor
  66221. * @returns This path cursor
  66222. */
  66223. move(step: number): PathCursor;
  66224. /**
  66225. * Ensures that the value is limited between zero and one
  66226. * @returns This path cursor
  66227. */
  66228. private ensureLimits;
  66229. /**
  66230. * Runs onchange callbacks on change (used by the animation engine)
  66231. * @returns This path cursor
  66232. */
  66233. private raiseOnChange;
  66234. /**
  66235. * Executes a function on change
  66236. * @param f A path cursor onchange callback
  66237. * @returns This path cursor
  66238. */
  66239. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66240. }
  66241. }
  66242. declare module BABYLON {
  66243. /** @hidden */
  66244. export var blurPixelShader: {
  66245. name: string;
  66246. shader: string;
  66247. };
  66248. }
  66249. declare module BABYLON {
  66250. /** @hidden */
  66251. export var pointCloudVertexDeclaration: {
  66252. name: string;
  66253. shader: string;
  66254. };
  66255. }
  66256. // Mixins
  66257. interface Window {
  66258. mozIndexedDB: IDBFactory;
  66259. webkitIndexedDB: IDBFactory;
  66260. msIndexedDB: IDBFactory;
  66261. webkitURL: typeof URL;
  66262. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  66263. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  66264. WebGLRenderingContext: WebGLRenderingContext;
  66265. MSGesture: MSGesture;
  66266. CANNON: any;
  66267. AudioContext: AudioContext;
  66268. webkitAudioContext: AudioContext;
  66269. PointerEvent: any;
  66270. Math: Math;
  66271. Uint8Array: Uint8ArrayConstructor;
  66272. Float32Array: Float32ArrayConstructor;
  66273. mozURL: typeof URL;
  66274. msURL: typeof URL;
  66275. VRFrameData: any; // WebVR, from specs 1.1
  66276. DracoDecoderModule: any;
  66277. setImmediate(handler: (...args: any[]) => void): number;
  66278. }
  66279. interface HTMLCanvasElement {
  66280. requestPointerLock(): void;
  66281. msRequestPointerLock?(): void;
  66282. mozRequestPointerLock?(): void;
  66283. webkitRequestPointerLock?(): void;
  66284. /** Track wether a record is in progress */
  66285. isRecording: boolean;
  66286. /** Capture Stream method defined by some browsers */
  66287. captureStream(fps?: number): MediaStream;
  66288. }
  66289. interface CanvasRenderingContext2D {
  66290. msImageSmoothingEnabled: boolean;
  66291. }
  66292. interface MouseEvent {
  66293. mozMovementX: number;
  66294. mozMovementY: number;
  66295. webkitMovementX: number;
  66296. webkitMovementY: number;
  66297. msMovementX: number;
  66298. msMovementY: number;
  66299. }
  66300. interface Navigator {
  66301. mozGetVRDevices: (any: any) => any;
  66302. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66303. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66304. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66305. webkitGetGamepads(): Gamepad[];
  66306. msGetGamepads(): Gamepad[];
  66307. webkitGamepads(): Gamepad[];
  66308. }
  66309. interface HTMLVideoElement {
  66310. mozSrcObject: any;
  66311. }
  66312. interface Math {
  66313. fround(x: number): number;
  66314. imul(a: number, b: number): number;
  66315. }
  66316. interface WebGLRenderingContext {
  66317. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  66318. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  66319. vertexAttribDivisor(index: number, divisor: number): void;
  66320. createVertexArray(): any;
  66321. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  66322. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  66323. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  66324. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  66325. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  66326. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  66327. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  66328. // Queries
  66329. createQuery(): WebGLQuery;
  66330. deleteQuery(query: WebGLQuery): void;
  66331. beginQuery(target: number, query: WebGLQuery): void;
  66332. endQuery(target: number): void;
  66333. getQueryParameter(query: WebGLQuery, pname: number): any;
  66334. getQuery(target: number, pname: number): any;
  66335. MAX_SAMPLES: number;
  66336. RGBA8: number;
  66337. READ_FRAMEBUFFER: number;
  66338. DRAW_FRAMEBUFFER: number;
  66339. UNIFORM_BUFFER: number;
  66340. HALF_FLOAT_OES: number;
  66341. RGBA16F: number;
  66342. RGBA32F: number;
  66343. R32F: number;
  66344. RG32F: number;
  66345. RGB32F: number;
  66346. R16F: number;
  66347. RG16F: number;
  66348. RGB16F: number;
  66349. RED: number;
  66350. RG: number;
  66351. R8: number;
  66352. RG8: number;
  66353. UNSIGNED_INT_24_8: number;
  66354. DEPTH24_STENCIL8: number;
  66355. MIN: number;
  66356. MAX: number;
  66357. /* Multiple Render Targets */
  66358. drawBuffers(buffers: number[]): void;
  66359. readBuffer(src: number): void;
  66360. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  66361. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  66362. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  66363. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  66364. // Occlusion Query
  66365. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  66366. ANY_SAMPLES_PASSED: number;
  66367. QUERY_RESULT_AVAILABLE: number;
  66368. QUERY_RESULT: number;
  66369. }
  66370. interface WebGLProgram {
  66371. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  66372. }
  66373. interface EXT_disjoint_timer_query {
  66374. QUERY_COUNTER_BITS_EXT: number;
  66375. TIME_ELAPSED_EXT: number;
  66376. TIMESTAMP_EXT: number;
  66377. GPU_DISJOINT_EXT: number;
  66378. QUERY_RESULT_EXT: number;
  66379. QUERY_RESULT_AVAILABLE_EXT: number;
  66380. queryCounterEXT(query: WebGLQuery, target: number): void;
  66381. createQueryEXT(): WebGLQuery;
  66382. beginQueryEXT(target: number, query: WebGLQuery): void;
  66383. endQueryEXT(target: number): void;
  66384. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  66385. deleteQueryEXT(query: WebGLQuery): void;
  66386. }
  66387. interface WebGLUniformLocation {
  66388. _currentState: any;
  66389. }
  66390. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  66391. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  66392. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  66393. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  66394. interface WebGLRenderingContext {
  66395. readonly RASTERIZER_DISCARD: number;
  66396. readonly DEPTH_COMPONENT24: number;
  66397. readonly TEXTURE_3D: number;
  66398. readonly TEXTURE_2D_ARRAY: number;
  66399. readonly TEXTURE_COMPARE_FUNC: number;
  66400. readonly TEXTURE_COMPARE_MODE: number;
  66401. readonly COMPARE_REF_TO_TEXTURE: number;
  66402. readonly TEXTURE_WRAP_R: number;
  66403. readonly HALF_FLOAT: number;
  66404. readonly RGB8: number;
  66405. readonly RED_INTEGER: number;
  66406. readonly RG_INTEGER: number;
  66407. readonly RGB_INTEGER: number;
  66408. readonly RGBA_INTEGER: number;
  66409. readonly R8_SNORM: number;
  66410. readonly RG8_SNORM: number;
  66411. readonly RGB8_SNORM: number;
  66412. readonly RGBA8_SNORM: number;
  66413. readonly R8I: number;
  66414. readonly RG8I: number;
  66415. readonly RGB8I: number;
  66416. readonly RGBA8I: number;
  66417. readonly R8UI: number;
  66418. readonly RG8UI: number;
  66419. readonly RGB8UI: number;
  66420. readonly RGBA8UI: number;
  66421. readonly R16I: number;
  66422. readonly RG16I: number;
  66423. readonly RGB16I: number;
  66424. readonly RGBA16I: number;
  66425. readonly R16UI: number;
  66426. readonly RG16UI: number;
  66427. readonly RGB16UI: number;
  66428. readonly RGBA16UI: number;
  66429. readonly R32I: number;
  66430. readonly RG32I: number;
  66431. readonly RGB32I: number;
  66432. readonly RGBA32I: number;
  66433. readonly R32UI: number;
  66434. readonly RG32UI: number;
  66435. readonly RGB32UI: number;
  66436. readonly RGBA32UI: number;
  66437. readonly RGB10_A2UI: number;
  66438. readonly R11F_G11F_B10F: number;
  66439. readonly RGB9_E5: number;
  66440. readonly RGB10_A2: number;
  66441. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  66442. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  66443. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  66444. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  66445. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  66446. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  66447. 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;
  66448. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  66449. readonly TRANSFORM_FEEDBACK: number;
  66450. readonly INTERLEAVED_ATTRIBS: number;
  66451. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  66452. createTransformFeedback(): WebGLTransformFeedback;
  66453. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  66454. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  66455. beginTransformFeedback(primitiveMode: number): void;
  66456. endTransformFeedback(): void;
  66457. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  66458. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  66459. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  66460. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  66461. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  66462. }
  66463. interface ImageBitmap {
  66464. readonly width: number;
  66465. readonly height: number;
  66466. close(): void;
  66467. }
  66468. interface WebGLQuery extends WebGLObject {
  66469. }
  66470. declare var WebGLQuery: {
  66471. prototype: WebGLQuery;
  66472. new(): WebGLQuery;
  66473. };
  66474. interface WebGLSampler extends WebGLObject {
  66475. }
  66476. declare var WebGLSampler: {
  66477. prototype: WebGLSampler;
  66478. new(): WebGLSampler;
  66479. };
  66480. interface WebGLSync extends WebGLObject {
  66481. }
  66482. declare var WebGLSync: {
  66483. prototype: WebGLSync;
  66484. new(): WebGLSync;
  66485. };
  66486. interface WebGLTransformFeedback extends WebGLObject {
  66487. }
  66488. declare var WebGLTransformFeedback: {
  66489. prototype: WebGLTransformFeedback;
  66490. new(): WebGLTransformFeedback;
  66491. };
  66492. interface WebGLVertexArrayObject extends WebGLObject {
  66493. }
  66494. declare var WebGLVertexArrayObject: {
  66495. prototype: WebGLVertexArrayObject;
  66496. new(): WebGLVertexArrayObject;
  66497. };
  66498. // Type definitions for WebVR API
  66499. // Project: https://w3c.github.io/webvr/
  66500. // Definitions by: six a <https://github.com/lostfictions>
  66501. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  66502. interface VRDisplay extends EventTarget {
  66503. /**
  66504. * Dictionary of capabilities describing the VRDisplay.
  66505. */
  66506. readonly capabilities: VRDisplayCapabilities;
  66507. /**
  66508. * z-depth defining the far plane of the eye view frustum
  66509. * enables mapping of values in the render target depth
  66510. * attachment to scene coordinates. Initially set to 10000.0.
  66511. */
  66512. depthFar: number;
  66513. /**
  66514. * z-depth defining the near plane of the eye view frustum
  66515. * enables mapping of values in the render target depth
  66516. * attachment to scene coordinates. Initially set to 0.01.
  66517. */
  66518. depthNear: number;
  66519. /**
  66520. * An identifier for this distinct VRDisplay. Used as an
  66521. * association point in the Gamepad API.
  66522. */
  66523. readonly displayId: number;
  66524. /**
  66525. * A display name, a user-readable name identifying it.
  66526. */
  66527. readonly displayName: string;
  66528. readonly isConnected: boolean;
  66529. readonly isPresenting: boolean;
  66530. /**
  66531. * If this VRDisplay supports room-scale experiences, the optional
  66532. * stage attribute contains details on the room-scale parameters.
  66533. */
  66534. readonly stageParameters: VRStageParameters | null;
  66535. /**
  66536. * Passing the value returned by `requestAnimationFrame` to
  66537. * `cancelAnimationFrame` will unregister the callback.
  66538. * @param handle Define the hanle of the request to cancel
  66539. */
  66540. cancelAnimationFrame(handle: number): void;
  66541. /**
  66542. * Stops presenting to the VRDisplay.
  66543. * @returns a promise to know when it stopped
  66544. */
  66545. exitPresent(): Promise<void>;
  66546. /**
  66547. * Return the current VREyeParameters for the given eye.
  66548. * @param whichEye Define the eye we want the parameter for
  66549. * @returns the eye parameters
  66550. */
  66551. getEyeParameters(whichEye: string): VREyeParameters;
  66552. /**
  66553. * Populates the passed VRFrameData with the information required to render
  66554. * the current frame.
  66555. * @param frameData Define the data structure to populate
  66556. * @returns true if ok otherwise false
  66557. */
  66558. getFrameData(frameData: VRFrameData): boolean;
  66559. /**
  66560. * Get the layers currently being presented.
  66561. * @returns the list of VR layers
  66562. */
  66563. getLayers(): VRLayer[];
  66564. /**
  66565. * Return a VRPose containing the future predicted pose of the VRDisplay
  66566. * when the current frame will be presented. The value returned will not
  66567. * change until JavaScript has returned control to the browser.
  66568. *
  66569. * The VRPose will contain the position, orientation, velocity,
  66570. * and acceleration of each of these properties.
  66571. * @returns the pose object
  66572. */
  66573. getPose(): VRPose;
  66574. /**
  66575. * Return the current instantaneous pose of the VRDisplay, with no
  66576. * prediction applied.
  66577. * @returns the current instantaneous pose
  66578. */
  66579. getImmediatePose(): VRPose;
  66580. /**
  66581. * The callback passed to `requestAnimationFrame` will be called
  66582. * any time a new frame should be rendered. When the VRDisplay is
  66583. * presenting the callback will be called at the native refresh
  66584. * rate of the HMD. When not presenting this function acts
  66585. * identically to how window.requestAnimationFrame acts. Content should
  66586. * make no assumptions of frame rate or vsync behavior as the HMD runs
  66587. * asynchronously from other displays and at differing refresh rates.
  66588. * @param callback Define the eaction to run next frame
  66589. * @returns the request handle it
  66590. */
  66591. requestAnimationFrame(callback: FrameRequestCallback): number;
  66592. /**
  66593. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  66594. * Repeat calls while already presenting will update the VRLayers being displayed.
  66595. * @param layers Define the list of layer to present
  66596. * @returns a promise to know when the request has been fulfilled
  66597. */
  66598. requestPresent(layers: VRLayer[]): Promise<void>;
  66599. /**
  66600. * Reset the pose for this display, treating its current position and
  66601. * orientation as the "origin/zero" values. VRPose.position,
  66602. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  66603. * updated when calling resetPose(). This should be called in only
  66604. * sitting-space experiences.
  66605. */
  66606. resetPose(): void;
  66607. /**
  66608. * The VRLayer provided to the VRDisplay will be captured and presented
  66609. * in the HMD. Calling this function has the same effect on the source
  66610. * canvas as any other operation that uses its source image, and canvases
  66611. * created without preserveDrawingBuffer set to true will be cleared.
  66612. * @param pose Define the pose to submit
  66613. */
  66614. submitFrame(pose?: VRPose): void;
  66615. }
  66616. declare var VRDisplay: {
  66617. prototype: VRDisplay;
  66618. new(): VRDisplay;
  66619. };
  66620. interface VRLayer {
  66621. leftBounds?: number[] | Float32Array | null;
  66622. rightBounds?: number[] | Float32Array | null;
  66623. source?: HTMLCanvasElement | null;
  66624. }
  66625. interface VRDisplayCapabilities {
  66626. readonly canPresent: boolean;
  66627. readonly hasExternalDisplay: boolean;
  66628. readonly hasOrientation: boolean;
  66629. readonly hasPosition: boolean;
  66630. readonly maxLayers: number;
  66631. }
  66632. interface VREyeParameters {
  66633. /** @deprecated */
  66634. readonly fieldOfView: VRFieldOfView;
  66635. readonly offset: Float32Array;
  66636. readonly renderHeight: number;
  66637. readonly renderWidth: number;
  66638. }
  66639. interface VRFieldOfView {
  66640. readonly downDegrees: number;
  66641. readonly leftDegrees: number;
  66642. readonly rightDegrees: number;
  66643. readonly upDegrees: number;
  66644. }
  66645. interface VRFrameData {
  66646. readonly leftProjectionMatrix: Float32Array;
  66647. readonly leftViewMatrix: Float32Array;
  66648. readonly pose: VRPose;
  66649. readonly rightProjectionMatrix: Float32Array;
  66650. readonly rightViewMatrix: Float32Array;
  66651. readonly timestamp: number;
  66652. }
  66653. interface VRPose {
  66654. readonly angularAcceleration: Float32Array | null;
  66655. readonly angularVelocity: Float32Array | null;
  66656. readonly linearAcceleration: Float32Array | null;
  66657. readonly linearVelocity: Float32Array | null;
  66658. readonly orientation: Float32Array | null;
  66659. readonly position: Float32Array | null;
  66660. readonly timestamp: number;
  66661. }
  66662. interface VRStageParameters {
  66663. sittingToStandingTransform?: Float32Array;
  66664. sizeX?: number;
  66665. sizeY?: number;
  66666. }
  66667. interface Navigator {
  66668. getVRDisplays(): Promise<VRDisplay[]>;
  66669. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  66670. }
  66671. interface Window {
  66672. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  66673. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  66674. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  66675. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  66676. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  66677. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  66678. }
  66679. interface Gamepad {
  66680. readonly displayId: number;
  66681. }
  66682. type XRSessionMode =
  66683. | "inline"
  66684. | "immersive-vr"
  66685. | "immersive-ar";
  66686. type XRReferenceSpaceType =
  66687. | "viewer"
  66688. | "local"
  66689. | "local-floor"
  66690. | "bounded-floor"
  66691. | "unbounded";
  66692. type XREnvironmentBlendMode =
  66693. | "opaque"
  66694. | "additive"
  66695. | "alpha-blend";
  66696. type XRVisibilityState =
  66697. | "visible"
  66698. | "visible-blurred"
  66699. | "hidden";
  66700. type XRHandedness =
  66701. | "none"
  66702. | "left"
  66703. | "right";
  66704. type XRTargetRayMode =
  66705. | "gaze"
  66706. | "tracked-pointer"
  66707. | "screen";
  66708. type XREye =
  66709. | "none"
  66710. | "left"
  66711. | "right";
  66712. interface XRSpace extends EventTarget {
  66713. }
  66714. interface XRRenderState {
  66715. depthNear?: number;
  66716. depthFar?: number;
  66717. inlineVerticalFieldOfView?: number;
  66718. baseLayer?: XRWebGLLayer;
  66719. }
  66720. interface XRInputSource {
  66721. handedness: XRHandedness;
  66722. targetRayMode: XRTargetRayMode;
  66723. targetRaySpace: XRSpace;
  66724. gripSpace: XRSpace | undefined;
  66725. gamepad: Gamepad | undefined;
  66726. profiles: Array<string>;
  66727. }
  66728. interface XRSession extends XRAnchorCreator {
  66729. addEventListener: Function;
  66730. removeEventListener: Function;
  66731. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  66732. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  66733. requestAnimationFrame: Function;
  66734. end(): Promise<void>;
  66735. renderState: XRRenderState;
  66736. inputSources: Array<XRInputSource>;
  66737. // AR hit test
  66738. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  66739. updateWorldTrackingState(options: {
  66740. planeDetectionState?: { enabled: boolean; }
  66741. }): void;
  66742. }
  66743. interface XRReferenceSpace extends XRSpace {
  66744. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  66745. onreset: any;
  66746. }
  66747. type XRPlaneSet = Set<XRPlane>;
  66748. type XRAnchorSet = Set<XRAnchor>;
  66749. interface XRFrame {
  66750. session: XRSession;
  66751. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  66752. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  66753. // Anchors
  66754. trackedAnchors?: XRAnchorSet;
  66755. // Planes
  66756. worldInformation: {
  66757. detectedPlanes?: XRPlaneSet;
  66758. };
  66759. }
  66760. interface XRViewerPose extends XRPose {
  66761. views: Array<XRView>;
  66762. }
  66763. interface XRPose {
  66764. transform: XRRigidTransform;
  66765. emulatedPosition: boolean;
  66766. }
  66767. interface XRWebGLLayerOptions {
  66768. antialias?: boolean;
  66769. depth?: boolean;
  66770. stencil?: boolean;
  66771. alpha?: boolean;
  66772. multiview?: boolean;
  66773. framebufferScaleFactor?: number;
  66774. }
  66775. declare var XRWebGLLayer: {
  66776. prototype: XRWebGLLayer;
  66777. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  66778. };
  66779. interface XRWebGLLayer {
  66780. framebuffer: WebGLFramebuffer;
  66781. framebufferWidth: number;
  66782. framebufferHeight: number;
  66783. getViewport: Function;
  66784. }
  66785. declare class XRRigidTransform {
  66786. constructor(matrix: Float32Array);
  66787. position: DOMPointReadOnly;
  66788. orientation: DOMPointReadOnly;
  66789. matrix: Float32Array;
  66790. inverse: XRRigidTransform;
  66791. }
  66792. interface XRView {
  66793. eye: XREye;
  66794. projectionMatrix: Float32Array;
  66795. transform: XRRigidTransform;
  66796. }
  66797. interface XRInputSourceChangeEvent {
  66798. session: XRSession;
  66799. removed: Array<XRInputSource>;
  66800. added: Array<XRInputSource>;
  66801. }
  66802. interface XRInputSourceEvent extends Event {
  66803. readonly frame: XRFrame;
  66804. readonly inputSource: XRInputSource;
  66805. }
  66806. // Experimental(er) features
  66807. declare class XRRay {
  66808. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  66809. origin: DOMPointReadOnly;
  66810. direction: DOMPointReadOnly;
  66811. matrix: Float32Array;
  66812. }
  66813. interface XRHitResult {
  66814. hitMatrix: Float32Array;
  66815. }
  66816. interface XRAnchor {
  66817. // remove?
  66818. id?: string;
  66819. anchorSpace: XRSpace;
  66820. lastChangedTime: number;
  66821. detach(): void;
  66822. }
  66823. interface XRPlane extends XRAnchorCreator {
  66824. orientation: "Horizontal" | "Vertical";
  66825. planeSpace: XRSpace;
  66826. polygon: Array<DOMPointReadOnly>;
  66827. lastChangedTime: number;
  66828. }
  66829. interface XRAnchorCreator {
  66830. // AR Anchors
  66831. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  66832. }
  66833. /**
  66834. * @ignore
  66835. */
  66836. declare module BABYLON.GLTF2.Exporter {
  66837. }
  66838. /**
  66839. * @ignore
  66840. */
  66841. declare module BABYLON.GLTF1 {
  66842. }
  66843. declare module BABYLON.GUI {
  66844. /**
  66845. * Class used to specific a value and its associated unit
  66846. */
  66847. export class ValueAndUnit {
  66848. /** defines the unit to store */
  66849. unit: number;
  66850. /** defines a boolean indicating if the value can be negative */
  66851. negativeValueAllowed: boolean;
  66852. private _value;
  66853. private _originalUnit;
  66854. /**
  66855. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  66856. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66857. */
  66858. ignoreAdaptiveScaling: boolean;
  66859. /**
  66860. * Creates a new ValueAndUnit
  66861. * @param value defines the value to store
  66862. * @param unit defines the unit to store
  66863. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  66864. */
  66865. constructor(value: number,
  66866. /** defines the unit to store */
  66867. unit?: number,
  66868. /** defines a boolean indicating if the value can be negative */
  66869. negativeValueAllowed?: boolean);
  66870. /** Gets a boolean indicating if the value is a percentage */
  66871. readonly isPercentage: boolean;
  66872. /** Gets a boolean indicating if the value is store as pixel */
  66873. readonly isPixel: boolean;
  66874. /** Gets direct internal value */
  66875. readonly internalValue: number;
  66876. /**
  66877. * Gets value as pixel
  66878. * @param host defines the root host
  66879. * @param refValue defines the reference value for percentages
  66880. * @returns the value as pixel
  66881. */
  66882. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  66883. /**
  66884. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  66885. * @param value defines the value to store
  66886. * @param unit defines the unit to store
  66887. * @returns the current ValueAndUnit
  66888. */
  66889. updateInPlace(value: number, unit?: number): ValueAndUnit;
  66890. /**
  66891. * Gets the value accordingly to its unit
  66892. * @param host defines the root host
  66893. * @returns the value
  66894. */
  66895. getValue(host: AdvancedDynamicTexture): number;
  66896. /**
  66897. * Gets a string representation of the value
  66898. * @param host defines the root host
  66899. * @param decimals defines an optional number of decimals to display
  66900. * @returns a string
  66901. */
  66902. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  66903. /**
  66904. * Store a value parsed from a string
  66905. * @param source defines the source string
  66906. * @returns true if the value was successfully parsed
  66907. */
  66908. fromString(source: string | number): boolean;
  66909. private static _Regex;
  66910. private static _UNITMODE_PERCENTAGE;
  66911. private static _UNITMODE_PIXEL;
  66912. /** UNITMODE_PERCENTAGE */
  66913. static readonly UNITMODE_PERCENTAGE: number;
  66914. /** UNITMODE_PIXEL */
  66915. static readonly UNITMODE_PIXEL: number;
  66916. }
  66917. }
  66918. declare module BABYLON.GUI {
  66919. /**
  66920. * Define a style used by control to automatically setup properties based on a template.
  66921. * Only support font related properties so far
  66922. */
  66923. export class Style implements BABYLON.IDisposable {
  66924. private _fontFamily;
  66925. private _fontStyle;
  66926. private _fontWeight;
  66927. /** @hidden */
  66928. _host: AdvancedDynamicTexture;
  66929. /** @hidden */
  66930. _fontSize: ValueAndUnit;
  66931. /**
  66932. * BABYLON.Observable raised when the style values are changed
  66933. */
  66934. onChangedObservable: BABYLON.Observable<Style>;
  66935. /**
  66936. * Creates a new style object
  66937. * @param host defines the AdvancedDynamicTexture which hosts this style
  66938. */
  66939. constructor(host: AdvancedDynamicTexture);
  66940. /**
  66941. * Gets or sets the font size
  66942. */
  66943. fontSize: string | number;
  66944. /**
  66945. * Gets or sets the font family
  66946. */
  66947. fontFamily: string;
  66948. /**
  66949. * Gets or sets the font style
  66950. */
  66951. fontStyle: string;
  66952. /** Gets or sets font weight */
  66953. fontWeight: string;
  66954. /** Dispose all associated resources */
  66955. dispose(): void;
  66956. }
  66957. }
  66958. declare module BABYLON.GUI {
  66959. /**
  66960. * Class used to transport BABYLON.Vector2 information for pointer events
  66961. */
  66962. export class Vector2WithInfo extends BABYLON.Vector2 {
  66963. /** defines the current mouse button index */
  66964. buttonIndex: number;
  66965. /**
  66966. * Creates a new Vector2WithInfo
  66967. * @param source defines the vector2 data to transport
  66968. * @param buttonIndex defines the current mouse button index
  66969. */
  66970. constructor(source: BABYLON.Vector2,
  66971. /** defines the current mouse button index */
  66972. buttonIndex?: number);
  66973. }
  66974. /** Class used to provide 2D matrix features */
  66975. export class Matrix2D {
  66976. /** Gets the internal array of 6 floats used to store matrix data */
  66977. m: Float32Array;
  66978. /**
  66979. * Creates a new matrix
  66980. * @param m00 defines value for (0, 0)
  66981. * @param m01 defines value for (0, 1)
  66982. * @param m10 defines value for (1, 0)
  66983. * @param m11 defines value for (1, 1)
  66984. * @param m20 defines value for (2, 0)
  66985. * @param m21 defines value for (2, 1)
  66986. */
  66987. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  66988. /**
  66989. * Fills the matrix from direct values
  66990. * @param m00 defines value for (0, 0)
  66991. * @param m01 defines value for (0, 1)
  66992. * @param m10 defines value for (1, 0)
  66993. * @param m11 defines value for (1, 1)
  66994. * @param m20 defines value for (2, 0)
  66995. * @param m21 defines value for (2, 1)
  66996. * @returns the current modified matrix
  66997. */
  66998. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  66999. /**
  67000. * Gets matrix determinant
  67001. * @returns the determinant
  67002. */
  67003. determinant(): number;
  67004. /**
  67005. * Inverses the matrix and stores it in a target matrix
  67006. * @param result defines the target matrix
  67007. * @returns the current matrix
  67008. */
  67009. invertToRef(result: Matrix2D): Matrix2D;
  67010. /**
  67011. * Multiplies the current matrix with another one
  67012. * @param other defines the second operand
  67013. * @param result defines the target matrix
  67014. * @returns the current matrix
  67015. */
  67016. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  67017. /**
  67018. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  67019. * @param x defines the x coordinate to transform
  67020. * @param y defines the x coordinate to transform
  67021. * @param result defines the target vector2
  67022. * @returns the current matrix
  67023. */
  67024. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  67025. /**
  67026. * Creates an identity matrix
  67027. * @returns a new matrix
  67028. */
  67029. static Identity(): Matrix2D;
  67030. /**
  67031. * Creates a translation matrix and stores it in a target matrix
  67032. * @param x defines the x coordinate of the translation
  67033. * @param y defines the y coordinate of the translation
  67034. * @param result defines the target matrix
  67035. */
  67036. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  67037. /**
  67038. * Creates a scaling matrix and stores it in a target matrix
  67039. * @param x defines the x coordinate of the scaling
  67040. * @param y defines the y coordinate of the scaling
  67041. * @param result defines the target matrix
  67042. */
  67043. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  67044. /**
  67045. * Creates a rotation matrix and stores it in a target matrix
  67046. * @param angle defines the rotation angle
  67047. * @param result defines the target matrix
  67048. */
  67049. static RotationToRef(angle: number, result: Matrix2D): void;
  67050. private static _TempPreTranslationMatrix;
  67051. private static _TempPostTranslationMatrix;
  67052. private static _TempRotationMatrix;
  67053. private static _TempScalingMatrix;
  67054. private static _TempCompose0;
  67055. private static _TempCompose1;
  67056. private static _TempCompose2;
  67057. /**
  67058. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  67059. * @param tx defines the x coordinate of the translation
  67060. * @param ty defines the y coordinate of the translation
  67061. * @param angle defines the rotation angle
  67062. * @param scaleX defines the x coordinate of the scaling
  67063. * @param scaleY defines the y coordinate of the scaling
  67064. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  67065. * @param result defines the target matrix
  67066. */
  67067. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  67068. }
  67069. }
  67070. declare module BABYLON.GUI {
  67071. /**
  67072. * Class used to store 2D control sizes
  67073. */
  67074. export class Measure {
  67075. /** defines left coordinate */
  67076. left: number;
  67077. /** defines top coordinate */
  67078. top: number;
  67079. /** defines width dimension */
  67080. width: number;
  67081. /** defines height dimension */
  67082. height: number;
  67083. /**
  67084. * Creates a new measure
  67085. * @param left defines left coordinate
  67086. * @param top defines top coordinate
  67087. * @param width defines width dimension
  67088. * @param height defines height dimension
  67089. */
  67090. constructor(
  67091. /** defines left coordinate */
  67092. left: number,
  67093. /** defines top coordinate */
  67094. top: number,
  67095. /** defines width dimension */
  67096. width: number,
  67097. /** defines height dimension */
  67098. height: number);
  67099. /**
  67100. * Copy from another measure
  67101. * @param other defines the other measure to copy from
  67102. */
  67103. copyFrom(other: Measure): void;
  67104. /**
  67105. * Copy from a group of 4 floats
  67106. * @param left defines left coordinate
  67107. * @param top defines top coordinate
  67108. * @param width defines width dimension
  67109. * @param height defines height dimension
  67110. */
  67111. copyFromFloats(left: number, top: number, width: number, height: number): void;
  67112. /**
  67113. * Computes the axis aligned bounding box measure for two given measures
  67114. * @param a Input measure
  67115. * @param b Input measure
  67116. * @param result the resulting bounding measure
  67117. */
  67118. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  67119. /**
  67120. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  67121. * @param transform the matrix to transform the measure before computing the AABB
  67122. * @param result the resulting AABB
  67123. */
  67124. transformToRef(transform: Matrix2D, result: Measure): void;
  67125. /**
  67126. * Check equality between this measure and another one
  67127. * @param other defines the other measures
  67128. * @returns true if both measures are equals
  67129. */
  67130. isEqualsTo(other: Measure): boolean;
  67131. /**
  67132. * Creates an empty measure
  67133. * @returns a new measure
  67134. */
  67135. static Empty(): Measure;
  67136. }
  67137. }
  67138. declare module BABYLON.GUI {
  67139. /**
  67140. * Interface used to define a control that can receive focus
  67141. */
  67142. export interface IFocusableControl {
  67143. /**
  67144. * Function called when the control receives the focus
  67145. */
  67146. onFocus(): void;
  67147. /**
  67148. * Function called when the control loses the focus
  67149. */
  67150. onBlur(): void;
  67151. /**
  67152. * Function called to let the control handle keyboard events
  67153. * @param evt defines the current keyboard event
  67154. */
  67155. processKeyboard(evt: KeyboardEvent): void;
  67156. /**
  67157. * Function called to get the list of controls that should not steal the focus from this control
  67158. * @returns an array of controls
  67159. */
  67160. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  67161. }
  67162. /**
  67163. * Class used to create texture to support 2D GUI elements
  67164. * @see http://doc.babylonjs.com/how_to/gui
  67165. */
  67166. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  67167. private _isDirty;
  67168. private _renderObserver;
  67169. private _resizeObserver;
  67170. private _preKeyboardObserver;
  67171. private _pointerMoveObserver;
  67172. private _pointerObserver;
  67173. private _canvasPointerOutObserver;
  67174. private _background;
  67175. /** @hidden */
  67176. _rootContainer: Container;
  67177. /** @hidden */
  67178. _lastPickedControl: Control;
  67179. /** @hidden */
  67180. _lastControlOver: {
  67181. [pointerId: number]: Control;
  67182. };
  67183. /** @hidden */
  67184. _lastControlDown: {
  67185. [pointerId: number]: Control;
  67186. };
  67187. /** @hidden */
  67188. _capturingControl: {
  67189. [pointerId: number]: Control;
  67190. };
  67191. /** @hidden */
  67192. _shouldBlockPointer: boolean;
  67193. /** @hidden */
  67194. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  67195. /** @hidden */
  67196. _linkedControls: Control[];
  67197. private _isFullscreen;
  67198. private _fullscreenViewport;
  67199. private _idealWidth;
  67200. private _idealHeight;
  67201. private _useSmallestIdeal;
  67202. private _renderAtIdealSize;
  67203. private _focusedControl;
  67204. private _blockNextFocusCheck;
  67205. private _renderScale;
  67206. private _rootElement;
  67207. private _cursorChanged;
  67208. /**
  67209. * Define type to string to ensure compatibility across browsers
  67210. * Safari doesn't support DataTransfer constructor
  67211. */
  67212. private _clipboardData;
  67213. /**
  67214. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  67215. */
  67216. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  67217. /**
  67218. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  67219. */
  67220. onControlPickedObservable: BABYLON.Observable<Control>;
  67221. /**
  67222. * BABYLON.Observable event triggered before layout is evaluated
  67223. */
  67224. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67225. /**
  67226. * BABYLON.Observable event triggered after the layout was evaluated
  67227. */
  67228. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67229. /**
  67230. * BABYLON.Observable event triggered before the texture is rendered
  67231. */
  67232. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67233. /**
  67234. * BABYLON.Observable event triggered after the texture was rendered
  67235. */
  67236. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67237. /**
  67238. * Gets or sets a boolean defining if alpha is stored as premultiplied
  67239. */
  67240. premulAlpha: boolean;
  67241. /**
  67242. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  67243. * Useful when you want more antialiasing
  67244. */
  67245. renderScale: number;
  67246. /** Gets or sets the background color */
  67247. background: string;
  67248. /**
  67249. * Gets or sets the ideal width used to design controls.
  67250. * The GUI will then rescale everything accordingly
  67251. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67252. */
  67253. idealWidth: number;
  67254. /**
  67255. * Gets or sets the ideal height used to design controls.
  67256. * The GUI will then rescale everything accordingly
  67257. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67258. */
  67259. idealHeight: number;
  67260. /**
  67261. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  67262. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67263. */
  67264. useSmallestIdeal: boolean;
  67265. /**
  67266. * Gets or sets a boolean indicating if adaptive scaling must be used
  67267. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67268. */
  67269. renderAtIdealSize: boolean;
  67270. /**
  67271. * Gets the underlying layer used to render the texture when in fullscreen mode
  67272. */
  67273. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  67274. /**
  67275. * Gets the root container control
  67276. */
  67277. readonly rootContainer: Container;
  67278. /**
  67279. * Returns an array containing the root container.
  67280. * This is mostly used to let the Inspector introspects the ADT
  67281. * @returns an array containing the rootContainer
  67282. */
  67283. getChildren(): Array<Container>;
  67284. /**
  67285. * Will return all controls that are inside this texture
  67286. * @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
  67287. * @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
  67288. * @return all child controls
  67289. */
  67290. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67291. /**
  67292. * Gets or sets the current focused control
  67293. */
  67294. focusedControl: BABYLON.Nullable<IFocusableControl>;
  67295. /**
  67296. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  67297. */
  67298. isForeground: boolean;
  67299. /**
  67300. * Gets or set information about clipboardData
  67301. */
  67302. clipboardData: string;
  67303. /**
  67304. * Creates a new AdvancedDynamicTexture
  67305. * @param name defines the name of the texture
  67306. * @param width defines the width of the texture
  67307. * @param height defines the height of the texture
  67308. * @param scene defines the hosting scene
  67309. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  67310. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  67311. */
  67312. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  67313. /**
  67314. * Get the current class name of the texture useful for serialization or dynamic coding.
  67315. * @returns "AdvancedDynamicTexture"
  67316. */
  67317. getClassName(): string;
  67318. /**
  67319. * Function used to execute a function on all controls
  67320. * @param func defines the function to execute
  67321. * @param container defines the container where controls belong. If null the root container will be used
  67322. */
  67323. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  67324. private _useInvalidateRectOptimization;
  67325. /**
  67326. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  67327. */
  67328. useInvalidateRectOptimization: boolean;
  67329. private _invalidatedRectangle;
  67330. /**
  67331. * Invalidates a rectangle area on the gui texture
  67332. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  67333. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  67334. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  67335. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  67336. */
  67337. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  67338. /**
  67339. * Marks the texture as dirty forcing a complete update
  67340. */
  67341. markAsDirty(): void;
  67342. /**
  67343. * Helper function used to create a new style
  67344. * @returns a new style
  67345. * @see http://doc.babylonjs.com/how_to/gui#styles
  67346. */
  67347. createStyle(): Style;
  67348. /**
  67349. * Adds a new control to the root container
  67350. * @param control defines the control to add
  67351. * @returns the current texture
  67352. */
  67353. addControl(control: Control): AdvancedDynamicTexture;
  67354. /**
  67355. * Removes a control from the root container
  67356. * @param control defines the control to remove
  67357. * @returns the current texture
  67358. */
  67359. removeControl(control: Control): AdvancedDynamicTexture;
  67360. /**
  67361. * Release all resources
  67362. */
  67363. dispose(): void;
  67364. private _onResize;
  67365. /** @hidden */
  67366. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  67367. /**
  67368. * Get screen coordinates for a vector3
  67369. * @param position defines the position to project
  67370. * @param worldMatrix defines the world matrix to use
  67371. * @returns the projected position
  67372. */
  67373. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  67374. private _checkUpdate;
  67375. private _clearMeasure;
  67376. private _render;
  67377. /** @hidden */
  67378. _changeCursor(cursor: string): void;
  67379. /** @hidden */
  67380. _registerLastControlDown(control: Control, pointerId: number): void;
  67381. private _doPicking;
  67382. /** @hidden */
  67383. _cleanControlAfterRemovalFromList(list: {
  67384. [pointerId: number]: Control;
  67385. }, control: Control): void;
  67386. /** @hidden */
  67387. _cleanControlAfterRemoval(control: Control): void;
  67388. /** Attach to all scene events required to support pointer events */
  67389. attach(): void;
  67390. /** @hidden */
  67391. private onClipboardCopy;
  67392. /** @hidden */
  67393. private onClipboardCut;
  67394. /** @hidden */
  67395. private onClipboardPaste;
  67396. /**
  67397. * Register the clipboard Events onto the canvas
  67398. */
  67399. registerClipboardEvents(): void;
  67400. /**
  67401. * Unregister the clipboard Events from the canvas
  67402. */
  67403. unRegisterClipboardEvents(): void;
  67404. /**
  67405. * Connect the texture to a hosting mesh to enable interactions
  67406. * @param mesh defines the mesh to attach to
  67407. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  67408. */
  67409. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  67410. /**
  67411. * Move the focus to a specific control
  67412. * @param control defines the control which will receive the focus
  67413. */
  67414. moveFocusToControl(control: IFocusableControl): void;
  67415. private _manageFocus;
  67416. private _attachToOnPointerOut;
  67417. /**
  67418. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  67419. * @param mesh defines the mesh which will receive the texture
  67420. * @param width defines the texture width (1024 by default)
  67421. * @param height defines the texture height (1024 by default)
  67422. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  67423. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  67424. * @returns a new AdvancedDynamicTexture
  67425. */
  67426. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  67427. /**
  67428. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  67429. * In this mode the texture will rely on a layer for its rendering.
  67430. * This allows it to be treated like any other layer.
  67431. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  67432. * LayerMask is set through advancedTexture.layer.layerMask
  67433. * @param name defines name for the texture
  67434. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  67435. * @param scene defines the hsoting scene
  67436. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  67437. * @returns a new AdvancedDynamicTexture
  67438. */
  67439. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  67440. }
  67441. }
  67442. declare module BABYLON.GUI {
  67443. /**
  67444. * Root class used for all 2D controls
  67445. * @see http://doc.babylonjs.com/how_to/gui#controls
  67446. */
  67447. export class Control {
  67448. /** defines the name of the control */
  67449. name?: string | undefined;
  67450. /**
  67451. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  67452. */
  67453. static AllowAlphaInheritance: boolean;
  67454. private _alpha;
  67455. private _alphaSet;
  67456. private _zIndex;
  67457. /** @hidden */
  67458. _host: AdvancedDynamicTexture;
  67459. /** Gets or sets the control parent */
  67460. parent: BABYLON.Nullable<Container>;
  67461. /** @hidden */
  67462. _currentMeasure: Measure;
  67463. private _fontFamily;
  67464. private _fontStyle;
  67465. private _fontWeight;
  67466. private _fontSize;
  67467. private _font;
  67468. /** @hidden */
  67469. _width: ValueAndUnit;
  67470. /** @hidden */
  67471. _height: ValueAndUnit;
  67472. /** @hidden */
  67473. protected _fontOffset: {
  67474. ascent: number;
  67475. height: number;
  67476. descent: number;
  67477. };
  67478. private _color;
  67479. private _style;
  67480. private _styleObserver;
  67481. /** @hidden */
  67482. protected _horizontalAlignment: number;
  67483. /** @hidden */
  67484. protected _verticalAlignment: number;
  67485. /** @hidden */
  67486. protected _isDirty: boolean;
  67487. /** @hidden */
  67488. protected _wasDirty: boolean;
  67489. /** @hidden */
  67490. _tempParentMeasure: Measure;
  67491. /** @hidden */
  67492. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  67493. /** @hidden */
  67494. protected _cachedParentMeasure: Measure;
  67495. private _paddingLeft;
  67496. private _paddingRight;
  67497. private _paddingTop;
  67498. private _paddingBottom;
  67499. /** @hidden */
  67500. _left: ValueAndUnit;
  67501. /** @hidden */
  67502. _top: ValueAndUnit;
  67503. private _scaleX;
  67504. private _scaleY;
  67505. private _rotation;
  67506. private _transformCenterX;
  67507. private _transformCenterY;
  67508. /** @hidden */
  67509. _transformMatrix: Matrix2D;
  67510. /** @hidden */
  67511. protected _invertTransformMatrix: Matrix2D;
  67512. /** @hidden */
  67513. protected _transformedPosition: BABYLON.Vector2;
  67514. private _isMatrixDirty;
  67515. private _cachedOffsetX;
  67516. private _cachedOffsetY;
  67517. private _isVisible;
  67518. private _isHighlighted;
  67519. /** @hidden */
  67520. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67521. private _fontSet;
  67522. private _dummyVector2;
  67523. private _downCount;
  67524. private _enterCount;
  67525. private _doNotRender;
  67526. private _downPointerIds;
  67527. protected _isEnabled: boolean;
  67528. protected _disabledColor: string;
  67529. /** @hidden */
  67530. protected _rebuildLayout: boolean;
  67531. /** @hidden */
  67532. _isClipped: boolean;
  67533. /** @hidden */
  67534. _automaticSize: boolean;
  67535. /** @hidden */
  67536. _tag: any;
  67537. /**
  67538. * 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
  67539. */
  67540. uniqueId: number;
  67541. /**
  67542. * Gets or sets an object used to store user defined information for the node
  67543. */
  67544. metadata: any;
  67545. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  67546. isHitTestVisible: boolean;
  67547. /** Gets or sets a boolean indicating if the control can block pointer events */
  67548. isPointerBlocker: boolean;
  67549. /** Gets or sets a boolean indicating if the control can be focusable */
  67550. isFocusInvisible: boolean;
  67551. /**
  67552. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  67553. * 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
  67554. */
  67555. clipChildren: boolean;
  67556. /**
  67557. * Gets or sets a boolean indicating that control content must be clipped
  67558. * 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
  67559. */
  67560. clipContent: boolean;
  67561. /**
  67562. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  67563. */
  67564. useBitmapCache: boolean;
  67565. private _cacheData;
  67566. private _shadowOffsetX;
  67567. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  67568. shadowOffsetX: number;
  67569. private _shadowOffsetY;
  67570. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  67571. shadowOffsetY: number;
  67572. private _shadowBlur;
  67573. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  67574. shadowBlur: number;
  67575. private _shadowColor;
  67576. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  67577. shadowColor: string;
  67578. /** Gets or sets the cursor to use when the control is hovered */
  67579. hoverCursor: string;
  67580. /** @hidden */
  67581. protected _linkOffsetX: ValueAndUnit;
  67582. /** @hidden */
  67583. protected _linkOffsetY: ValueAndUnit;
  67584. /** Gets the control type name */
  67585. readonly typeName: string;
  67586. /**
  67587. * Get the current class name of the control.
  67588. * @returns current class name
  67589. */
  67590. getClassName(): string;
  67591. /**
  67592. * An event triggered when the pointer move over the control.
  67593. */
  67594. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  67595. /**
  67596. * An event triggered when the pointer move out of the control.
  67597. */
  67598. onPointerOutObservable: BABYLON.Observable<Control>;
  67599. /**
  67600. * An event triggered when the pointer taps the control
  67601. */
  67602. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  67603. /**
  67604. * An event triggered when pointer up
  67605. */
  67606. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  67607. /**
  67608. * An event triggered when a control is clicked on
  67609. */
  67610. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  67611. /**
  67612. * An event triggered when pointer enters the control
  67613. */
  67614. onPointerEnterObservable: BABYLON.Observable<Control>;
  67615. /**
  67616. * An event triggered when the control is marked as dirty
  67617. */
  67618. onDirtyObservable: BABYLON.Observable<Control>;
  67619. /**
  67620. * An event triggered before drawing the control
  67621. */
  67622. onBeforeDrawObservable: BABYLON.Observable<Control>;
  67623. /**
  67624. * An event triggered after the control was drawn
  67625. */
  67626. onAfterDrawObservable: BABYLON.Observable<Control>;
  67627. /**
  67628. * Get the hosting AdvancedDynamicTexture
  67629. */
  67630. readonly host: AdvancedDynamicTexture;
  67631. /** Gets or set information about font offsets (used to render and align text) */
  67632. fontOffset: {
  67633. ascent: number;
  67634. height: number;
  67635. descent: number;
  67636. };
  67637. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  67638. alpha: number;
  67639. /**
  67640. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  67641. */
  67642. isHighlighted: boolean;
  67643. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  67644. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67645. */
  67646. scaleX: number;
  67647. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  67648. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67649. */
  67650. scaleY: number;
  67651. /** Gets or sets the rotation angle (0 by default)
  67652. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67653. */
  67654. rotation: number;
  67655. /** Gets or sets the transformation center on Y axis (0 by default)
  67656. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67657. */
  67658. transformCenterY: number;
  67659. /** Gets or sets the transformation center on X axis (0 by default)
  67660. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67661. */
  67662. transformCenterX: number;
  67663. /**
  67664. * Gets or sets the horizontal alignment
  67665. * @see http://doc.babylonjs.com/how_to/gui#alignments
  67666. */
  67667. horizontalAlignment: number;
  67668. /**
  67669. * Gets or sets the vertical alignment
  67670. * @see http://doc.babylonjs.com/how_to/gui#alignments
  67671. */
  67672. verticalAlignment: number;
  67673. /**
  67674. * Gets or sets control width
  67675. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67676. */
  67677. width: string | number;
  67678. /**
  67679. * Gets or sets the control width in pixel
  67680. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67681. */
  67682. widthInPixels: number;
  67683. /**
  67684. * Gets or sets control height
  67685. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67686. */
  67687. height: string | number;
  67688. /**
  67689. * Gets or sets control height in pixel
  67690. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67691. */
  67692. heightInPixels: number;
  67693. /** Gets or set font family */
  67694. fontFamily: string;
  67695. /** Gets or sets font style */
  67696. fontStyle: string;
  67697. /** Gets or sets font weight */
  67698. fontWeight: string;
  67699. /**
  67700. * Gets or sets style
  67701. * @see http://doc.babylonjs.com/how_to/gui#styles
  67702. */
  67703. style: BABYLON.Nullable<Style>;
  67704. /** @hidden */
  67705. readonly _isFontSizeInPercentage: boolean;
  67706. /** Gets or sets font size in pixels */
  67707. fontSizeInPixels: number;
  67708. /** Gets or sets font size */
  67709. fontSize: string | number;
  67710. /** Gets or sets foreground color */
  67711. color: string;
  67712. /** Gets or sets z index which is used to reorder controls on the z axis */
  67713. zIndex: number;
  67714. /** Gets or sets a boolean indicating if the control can be rendered */
  67715. notRenderable: boolean;
  67716. /** Gets or sets a boolean indicating if the control is visible */
  67717. isVisible: boolean;
  67718. /** Gets a boolean indicating that the control needs to update its rendering */
  67719. readonly isDirty: boolean;
  67720. /**
  67721. * Gets the current linked mesh (or null if none)
  67722. */
  67723. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67724. /**
  67725. * Gets or sets a value indicating the padding to use on the left of the control
  67726. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67727. */
  67728. paddingLeft: string | number;
  67729. /**
  67730. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  67731. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67732. */
  67733. paddingLeftInPixels: number;
  67734. /**
  67735. * Gets or sets a value indicating the padding to use on the right of the control
  67736. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67737. */
  67738. paddingRight: string | number;
  67739. /**
  67740. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  67741. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67742. */
  67743. paddingRightInPixels: number;
  67744. /**
  67745. * Gets or sets a value indicating the padding to use on the top of the control
  67746. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67747. */
  67748. paddingTop: string | number;
  67749. /**
  67750. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  67751. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67752. */
  67753. paddingTopInPixels: number;
  67754. /**
  67755. * Gets or sets a value indicating the padding to use on the bottom of the control
  67756. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67757. */
  67758. paddingBottom: string | number;
  67759. /**
  67760. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  67761. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67762. */
  67763. paddingBottomInPixels: number;
  67764. /**
  67765. * Gets or sets a value indicating the left coordinate of the control
  67766. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67767. */
  67768. left: string | number;
  67769. /**
  67770. * Gets or sets a value indicating the left coordinate in pixels of the control
  67771. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67772. */
  67773. leftInPixels: number;
  67774. /**
  67775. * Gets or sets a value indicating the top coordinate of the control
  67776. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67777. */
  67778. top: string | number;
  67779. /**
  67780. * Gets or sets a value indicating the top coordinate in pixels of the control
  67781. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67782. */
  67783. topInPixels: number;
  67784. /**
  67785. * Gets or sets a value indicating the offset on X axis to the linked mesh
  67786. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67787. */
  67788. linkOffsetX: string | number;
  67789. /**
  67790. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  67791. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67792. */
  67793. linkOffsetXInPixels: number;
  67794. /**
  67795. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  67796. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67797. */
  67798. linkOffsetY: string | number;
  67799. /**
  67800. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  67801. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67802. */
  67803. linkOffsetYInPixels: number;
  67804. /** Gets the center coordinate on X axis */
  67805. readonly centerX: number;
  67806. /** Gets the center coordinate on Y axis */
  67807. readonly centerY: number;
  67808. /** Gets or sets if control is Enabled*/
  67809. isEnabled: boolean;
  67810. /** Gets or sets background color of control if it's disabled*/
  67811. disabledColor: string;
  67812. /**
  67813. * Creates a new control
  67814. * @param name defines the name of the control
  67815. */
  67816. constructor(
  67817. /** defines the name of the control */
  67818. name?: string | undefined);
  67819. /** @hidden */
  67820. protected _getTypeName(): string;
  67821. /**
  67822. * Gets the first ascendant in the hierarchy of the given type
  67823. * @param className defines the required type
  67824. * @returns the ascendant or null if not found
  67825. */
  67826. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  67827. /** @hidden */
  67828. _resetFontCache(): void;
  67829. /**
  67830. * Determines if a container is an ascendant of the current control
  67831. * @param container defines the container to look for
  67832. * @returns true if the container is one of the ascendant of the control
  67833. */
  67834. isAscendant(container: Control): boolean;
  67835. /**
  67836. * Gets coordinates in local control space
  67837. * @param globalCoordinates defines the coordinates to transform
  67838. * @returns the new coordinates in local space
  67839. */
  67840. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  67841. /**
  67842. * Gets coordinates in local control space
  67843. * @param globalCoordinates defines the coordinates to transform
  67844. * @param result defines the target vector2 where to store the result
  67845. * @returns the current control
  67846. */
  67847. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  67848. /**
  67849. * Gets coordinates in parent local control space
  67850. * @param globalCoordinates defines the coordinates to transform
  67851. * @returns the new coordinates in parent local space
  67852. */
  67853. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  67854. /**
  67855. * Move the current control to a vector3 position projected onto the screen.
  67856. * @param position defines the target position
  67857. * @param scene defines the hosting scene
  67858. */
  67859. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  67860. /**
  67861. * Will store all controls that have this control as ascendant in a given array
  67862. * @param results defines the array where to store the descendants
  67863. * @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
  67864. * @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
  67865. */
  67866. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  67867. /**
  67868. * Will return all controls that have this control as ascendant
  67869. * @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
  67870. * @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
  67871. * @return all child controls
  67872. */
  67873. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67874. /**
  67875. * Link current control with a target mesh
  67876. * @param mesh defines the mesh to link with
  67877. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67878. */
  67879. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  67880. /** @hidden */
  67881. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  67882. /** @hidden */
  67883. _offsetLeft(offset: number): void;
  67884. /** @hidden */
  67885. _offsetTop(offset: number): void;
  67886. /** @hidden */
  67887. _markMatrixAsDirty(): void;
  67888. /** @hidden */
  67889. _flagDescendantsAsMatrixDirty(): void;
  67890. /** @hidden */
  67891. _intersectsRect(rect: Measure): boolean;
  67892. /** @hidden */
  67893. protected invalidateRect(): void;
  67894. /** @hidden */
  67895. _markAsDirty(force?: boolean): void;
  67896. /** @hidden */
  67897. _markAllAsDirty(): void;
  67898. /** @hidden */
  67899. _link(host: AdvancedDynamicTexture): void;
  67900. /** @hidden */
  67901. protected _transform(context?: CanvasRenderingContext2D): void;
  67902. /** @hidden */
  67903. _renderHighlight(context: CanvasRenderingContext2D): void;
  67904. /** @hidden */
  67905. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67906. /** @hidden */
  67907. protected _applyStates(context: CanvasRenderingContext2D): void;
  67908. /** @hidden */
  67909. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  67910. /** @hidden */
  67911. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67912. protected _evaluateClippingState(parentMeasure: Measure): void;
  67913. /** @hidden */
  67914. _measure(): void;
  67915. /** @hidden */
  67916. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67917. /** @hidden */
  67918. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67919. /** @hidden */
  67920. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67921. /** @hidden */
  67922. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67923. private static _ClipMeasure;
  67924. private _tmpMeasureA;
  67925. private _clip;
  67926. /** @hidden */
  67927. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  67928. /** @hidden */
  67929. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67930. /**
  67931. * Tests if a given coordinates belong to the current control
  67932. * @param x defines x coordinate to test
  67933. * @param y defines y coordinate to test
  67934. * @returns true if the coordinates are inside the control
  67935. */
  67936. contains(x: number, y: number): boolean;
  67937. /** @hidden */
  67938. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67939. /** @hidden */
  67940. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67941. /** @hidden */
  67942. _onPointerEnter(target: Control): boolean;
  67943. /** @hidden */
  67944. _onPointerOut(target: Control, force?: boolean): void;
  67945. /** @hidden */
  67946. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67947. /** @hidden */
  67948. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67949. /** @hidden */
  67950. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67951. /** @hidden */
  67952. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  67953. private _prepareFont;
  67954. /** Releases associated resources */
  67955. dispose(): void;
  67956. private static _HORIZONTAL_ALIGNMENT_LEFT;
  67957. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  67958. private static _HORIZONTAL_ALIGNMENT_CENTER;
  67959. private static _VERTICAL_ALIGNMENT_TOP;
  67960. private static _VERTICAL_ALIGNMENT_BOTTOM;
  67961. private static _VERTICAL_ALIGNMENT_CENTER;
  67962. /** HORIZONTAL_ALIGNMENT_LEFT */
  67963. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  67964. /** HORIZONTAL_ALIGNMENT_RIGHT */
  67965. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  67966. /** HORIZONTAL_ALIGNMENT_CENTER */
  67967. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  67968. /** VERTICAL_ALIGNMENT_TOP */
  67969. static readonly VERTICAL_ALIGNMENT_TOP: number;
  67970. /** VERTICAL_ALIGNMENT_BOTTOM */
  67971. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  67972. /** VERTICAL_ALIGNMENT_CENTER */
  67973. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  67974. private static _FontHeightSizes;
  67975. /** @hidden */
  67976. static _GetFontOffset(font: string): {
  67977. ascent: number;
  67978. height: number;
  67979. descent: number;
  67980. };
  67981. /**
  67982. * Creates a stack panel that can be used to render headers
  67983. * @param control defines the control to associate with the header
  67984. * @param text defines the text of the header
  67985. * @param size defines the size of the header
  67986. * @param options defines options used to configure the header
  67987. * @returns a new StackPanel
  67988. * @ignore
  67989. * @hidden
  67990. */
  67991. static AddHeader: (control: Control, text: string, size: string | number, options: {
  67992. isHorizontal: boolean;
  67993. controlFirst: boolean;
  67994. }) => any;
  67995. /** @hidden */
  67996. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  67997. }
  67998. }
  67999. declare module BABYLON.GUI {
  68000. /**
  68001. * Root class for 2D containers
  68002. * @see http://doc.babylonjs.com/how_to/gui#containers
  68003. */
  68004. export class Container extends Control {
  68005. name?: string | undefined;
  68006. /** @hidden */
  68007. protected _children: Control[];
  68008. /** @hidden */
  68009. protected _measureForChildren: Measure;
  68010. /** @hidden */
  68011. protected _background: string;
  68012. /** @hidden */
  68013. protected _adaptWidthToChildren: boolean;
  68014. /** @hidden */
  68015. protected _adaptHeightToChildren: boolean;
  68016. /**
  68017. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  68018. */
  68019. logLayoutCycleErrors: boolean;
  68020. /**
  68021. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  68022. */
  68023. maxLayoutCycle: number;
  68024. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  68025. adaptHeightToChildren: boolean;
  68026. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  68027. adaptWidthToChildren: boolean;
  68028. /** Gets or sets background color */
  68029. background: string;
  68030. /** Gets the list of children */
  68031. readonly children: Control[];
  68032. /**
  68033. * Creates a new Container
  68034. * @param name defines the name of the container
  68035. */
  68036. constructor(name?: string | undefined);
  68037. protected _getTypeName(): string;
  68038. _flagDescendantsAsMatrixDirty(): void;
  68039. /**
  68040. * Gets a child using its name
  68041. * @param name defines the child name to look for
  68042. * @returns the child control if found
  68043. */
  68044. getChildByName(name: string): BABYLON.Nullable<Control>;
  68045. /**
  68046. * Gets a child using its type and its name
  68047. * @param name defines the child name to look for
  68048. * @param type defines the child type to look for
  68049. * @returns the child control if found
  68050. */
  68051. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  68052. /**
  68053. * Search for a specific control in children
  68054. * @param control defines the control to look for
  68055. * @returns true if the control is in child list
  68056. */
  68057. containsControl(control: Control): boolean;
  68058. /**
  68059. * Adds a new control to the current container
  68060. * @param control defines the control to add
  68061. * @returns the current container
  68062. */
  68063. addControl(control: BABYLON.Nullable<Control>): Container;
  68064. /**
  68065. * Removes all controls from the current container
  68066. * @returns the current container
  68067. */
  68068. clearControls(): Container;
  68069. /**
  68070. * Removes a control from the current container
  68071. * @param control defines the control to remove
  68072. * @returns the current container
  68073. */
  68074. removeControl(control: Control): Container;
  68075. /** @hidden */
  68076. _reOrderControl(control: Control): void;
  68077. /** @hidden */
  68078. _offsetLeft(offset: number): void;
  68079. /** @hidden */
  68080. _offsetTop(offset: number): void;
  68081. /** @hidden */
  68082. _markAllAsDirty(): void;
  68083. /** @hidden */
  68084. protected _localDraw(context: CanvasRenderingContext2D): void;
  68085. /** @hidden */
  68086. _link(host: AdvancedDynamicTexture): void;
  68087. /** @hidden */
  68088. protected _beforeLayout(): void;
  68089. /** @hidden */
  68090. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68091. /** @hidden */
  68092. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68093. protected _postMeasure(): void;
  68094. /** @hidden */
  68095. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  68096. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68097. /** @hidden */
  68098. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68099. /** @hidden */
  68100. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68101. /** Releases associated resources */
  68102. dispose(): void;
  68103. }
  68104. }
  68105. declare module BABYLON.GUI {
  68106. /** Class used to create rectangle container */
  68107. export class Rectangle extends Container {
  68108. name?: string | undefined;
  68109. private _thickness;
  68110. private _cornerRadius;
  68111. /** Gets or sets border thickness */
  68112. thickness: number;
  68113. /** Gets or sets the corner radius angle */
  68114. cornerRadius: number;
  68115. /**
  68116. * Creates a new Rectangle
  68117. * @param name defines the control name
  68118. */
  68119. constructor(name?: string | undefined);
  68120. protected _getTypeName(): string;
  68121. protected _localDraw(context: CanvasRenderingContext2D): void;
  68122. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68123. private _drawRoundedRect;
  68124. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68125. }
  68126. }
  68127. declare module BABYLON.GUI {
  68128. /**
  68129. * Enum that determines the text-wrapping mode to use.
  68130. */
  68131. export enum TextWrapping {
  68132. /**
  68133. * Clip the text when it's larger than Control.width; this is the default mode.
  68134. */
  68135. Clip = 0,
  68136. /**
  68137. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  68138. */
  68139. WordWrap = 1,
  68140. /**
  68141. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  68142. */
  68143. Ellipsis = 2
  68144. }
  68145. /**
  68146. * Class used to create text block control
  68147. */
  68148. export class TextBlock extends Control {
  68149. /**
  68150. * Defines the name of the control
  68151. */
  68152. name?: string | undefined;
  68153. private _text;
  68154. private _textWrapping;
  68155. private _textHorizontalAlignment;
  68156. private _textVerticalAlignment;
  68157. private _lines;
  68158. private _resizeToFit;
  68159. private _lineSpacing;
  68160. private _outlineWidth;
  68161. private _outlineColor;
  68162. /**
  68163. * An event triggered after the text is changed
  68164. */
  68165. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  68166. /**
  68167. * An event triggered after the text was broken up into lines
  68168. */
  68169. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  68170. /**
  68171. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  68172. */
  68173. readonly lines: any[];
  68174. /**
  68175. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68176. */
  68177. /**
  68178. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68179. */
  68180. resizeToFit: boolean;
  68181. /**
  68182. * Gets or sets a boolean indicating if text must be wrapped
  68183. */
  68184. /**
  68185. * Gets or sets a boolean indicating if text must be wrapped
  68186. */
  68187. textWrapping: TextWrapping | boolean;
  68188. /**
  68189. * Gets or sets text to display
  68190. */
  68191. /**
  68192. * Gets or sets text to display
  68193. */
  68194. text: string;
  68195. /**
  68196. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68197. */
  68198. /**
  68199. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68200. */
  68201. textHorizontalAlignment: number;
  68202. /**
  68203. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68204. */
  68205. /**
  68206. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68207. */
  68208. textVerticalAlignment: number;
  68209. /**
  68210. * Gets or sets line spacing value
  68211. */
  68212. /**
  68213. * Gets or sets line spacing value
  68214. */
  68215. lineSpacing: string | number;
  68216. /**
  68217. * Gets or sets outlineWidth of the text to display
  68218. */
  68219. /**
  68220. * Gets or sets outlineWidth of the text to display
  68221. */
  68222. outlineWidth: number;
  68223. /**
  68224. * Gets or sets outlineColor of the text to display
  68225. */
  68226. /**
  68227. * Gets or sets outlineColor of the text to display
  68228. */
  68229. outlineColor: string;
  68230. /**
  68231. * Creates a new TextBlock object
  68232. * @param name defines the name of the control
  68233. * @param text defines the text to display (emptry string by default)
  68234. */
  68235. constructor(
  68236. /**
  68237. * Defines the name of the control
  68238. */
  68239. name?: string | undefined, text?: string);
  68240. protected _getTypeName(): string;
  68241. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68242. private _drawText;
  68243. /** @hidden */
  68244. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68245. protected _applyStates(context: CanvasRenderingContext2D): void;
  68246. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  68247. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  68248. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  68249. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  68250. protected _renderLines(context: CanvasRenderingContext2D): void;
  68251. /**
  68252. * Given a width constraint applied on the text block, find the expected height
  68253. * @returns expected height
  68254. */
  68255. computeExpectedHeight(): number;
  68256. dispose(): void;
  68257. }
  68258. }
  68259. declare module BABYLON.GUI {
  68260. /**
  68261. * Class used to create 2D images
  68262. */
  68263. export class Image extends Control {
  68264. name?: string | undefined;
  68265. private _workingCanvas;
  68266. private _domImage;
  68267. private _imageWidth;
  68268. private _imageHeight;
  68269. private _loaded;
  68270. private _stretch;
  68271. private _source;
  68272. private _autoScale;
  68273. private _sourceLeft;
  68274. private _sourceTop;
  68275. private _sourceWidth;
  68276. private _sourceHeight;
  68277. private _cellWidth;
  68278. private _cellHeight;
  68279. private _cellId;
  68280. private _populateNinePatchSlicesFromImage;
  68281. private _sliceLeft;
  68282. private _sliceRight;
  68283. private _sliceTop;
  68284. private _sliceBottom;
  68285. private _detectPointerOnOpaqueOnly;
  68286. /**
  68287. * BABYLON.Observable notified when the content is loaded
  68288. */
  68289. onImageLoadedObservable: BABYLON.Observable<Image>;
  68290. /**
  68291. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  68292. */
  68293. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  68294. /**
  68295. * Gets a boolean indicating that the content is loaded
  68296. */
  68297. readonly isLoaded: boolean;
  68298. /**
  68299. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  68300. */
  68301. populateNinePatchSlicesFromImage: boolean;
  68302. /**
  68303. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  68304. * Beware using this as this will comsume more memory as the image has to be stored twice
  68305. */
  68306. detectPointerOnOpaqueOnly: boolean;
  68307. /**
  68308. * Gets or sets the left value for slicing (9-patch)
  68309. */
  68310. sliceLeft: number;
  68311. /**
  68312. * Gets or sets the right value for slicing (9-patch)
  68313. */
  68314. sliceRight: number;
  68315. /**
  68316. * Gets or sets the top value for slicing (9-patch)
  68317. */
  68318. sliceTop: number;
  68319. /**
  68320. * Gets or sets the bottom value for slicing (9-patch)
  68321. */
  68322. sliceBottom: number;
  68323. /**
  68324. * Gets or sets the left coordinate in the source image
  68325. */
  68326. sourceLeft: number;
  68327. /**
  68328. * Gets or sets the top coordinate in the source image
  68329. */
  68330. sourceTop: number;
  68331. /**
  68332. * Gets or sets the width to capture in the source image
  68333. */
  68334. sourceWidth: number;
  68335. /**
  68336. * Gets or sets the height to capture in the source image
  68337. */
  68338. sourceHeight: number;
  68339. /**
  68340. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  68341. * @see http://doc.babylonjs.com/how_to/gui#image
  68342. */
  68343. autoScale: boolean;
  68344. /** Gets or sets the streching mode used by the image */
  68345. stretch: number;
  68346. /** @hidden */
  68347. _rotate90(n: number): Image;
  68348. /**
  68349. * Gets or sets the internal DOM image used to render the control
  68350. */
  68351. domImage: HTMLImageElement;
  68352. private _onImageLoaded;
  68353. private _extractNinePatchSliceDataFromImage;
  68354. /**
  68355. * Gets or sets image source url
  68356. */
  68357. source: BABYLON.Nullable<string>;
  68358. /**
  68359. * Checks for svg document with icon id present
  68360. */
  68361. private _svgCheck;
  68362. /**
  68363. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  68364. * given external svg file and icon id
  68365. */
  68366. private _getSVGAttribs;
  68367. /**
  68368. * Gets or sets the cell width to use when animation sheet is enabled
  68369. * @see http://doc.babylonjs.com/how_to/gui#image
  68370. */
  68371. cellWidth: number;
  68372. /**
  68373. * Gets or sets the cell height to use when animation sheet is enabled
  68374. * @see http://doc.babylonjs.com/how_to/gui#image
  68375. */
  68376. cellHeight: number;
  68377. /**
  68378. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  68379. * @see http://doc.babylonjs.com/how_to/gui#image
  68380. */
  68381. cellId: number;
  68382. /**
  68383. * Creates a new Image
  68384. * @param name defines the control name
  68385. * @param url defines the image url
  68386. */
  68387. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  68388. /**
  68389. * Tests if a given coordinates belong to the current control
  68390. * @param x defines x coordinate to test
  68391. * @param y defines y coordinate to test
  68392. * @returns true if the coordinates are inside the control
  68393. */
  68394. contains(x: number, y: number): boolean;
  68395. protected _getTypeName(): string;
  68396. /** Force the control to synchronize with its content */
  68397. synchronizeSizeWithContent(): void;
  68398. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68399. private _prepareWorkingCanvasForOpaqueDetection;
  68400. private _drawImage;
  68401. _draw(context: CanvasRenderingContext2D): void;
  68402. private _renderCornerPatch;
  68403. private _renderNinePatch;
  68404. dispose(): void;
  68405. /** STRETCH_NONE */
  68406. static readonly STRETCH_NONE: number;
  68407. /** STRETCH_FILL */
  68408. static readonly STRETCH_FILL: number;
  68409. /** STRETCH_UNIFORM */
  68410. static readonly STRETCH_UNIFORM: number;
  68411. /** STRETCH_EXTEND */
  68412. static readonly STRETCH_EXTEND: number;
  68413. /** NINE_PATCH */
  68414. static readonly STRETCH_NINE_PATCH: number;
  68415. }
  68416. }
  68417. declare module BABYLON.GUI {
  68418. /**
  68419. * Class used to create 2D buttons
  68420. */
  68421. export class Button extends Rectangle {
  68422. name?: string | undefined;
  68423. /**
  68424. * Function called to generate a pointer enter animation
  68425. */
  68426. pointerEnterAnimation: () => void;
  68427. /**
  68428. * Function called to generate a pointer out animation
  68429. */
  68430. pointerOutAnimation: () => void;
  68431. /**
  68432. * Function called to generate a pointer down animation
  68433. */
  68434. pointerDownAnimation: () => void;
  68435. /**
  68436. * Function called to generate a pointer up animation
  68437. */
  68438. pointerUpAnimation: () => void;
  68439. /**
  68440. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  68441. */
  68442. delegatePickingToChildren: boolean;
  68443. private _image;
  68444. /**
  68445. * Returns the image part of the button (if any)
  68446. */
  68447. readonly image: BABYLON.Nullable<Image>;
  68448. private _textBlock;
  68449. /**
  68450. * Returns the image part of the button (if any)
  68451. */
  68452. readonly textBlock: BABYLON.Nullable<TextBlock>;
  68453. /**
  68454. * Creates a new Button
  68455. * @param name defines the name of the button
  68456. */
  68457. constructor(name?: string | undefined);
  68458. protected _getTypeName(): string;
  68459. /** @hidden */
  68460. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68461. /** @hidden */
  68462. _onPointerEnter(target: Control): boolean;
  68463. /** @hidden */
  68464. _onPointerOut(target: Control, force?: boolean): void;
  68465. /** @hidden */
  68466. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68467. /** @hidden */
  68468. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68469. /**
  68470. * Creates a new button made with an image and a text
  68471. * @param name defines the name of the button
  68472. * @param text defines the text of the button
  68473. * @param imageUrl defines the url of the image
  68474. * @returns a new Button
  68475. */
  68476. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  68477. /**
  68478. * Creates a new button made with an image
  68479. * @param name defines the name of the button
  68480. * @param imageUrl defines the url of the image
  68481. * @returns a new Button
  68482. */
  68483. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  68484. /**
  68485. * Creates a new button made with a text
  68486. * @param name defines the name of the button
  68487. * @param text defines the text of the button
  68488. * @returns a new Button
  68489. */
  68490. static CreateSimpleButton(name: string, text: string): Button;
  68491. /**
  68492. * Creates a new button made with an image and a centered text
  68493. * @param name defines the name of the button
  68494. * @param text defines the text of the button
  68495. * @param imageUrl defines the url of the image
  68496. * @returns a new Button
  68497. */
  68498. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  68499. }
  68500. }
  68501. declare module BABYLON.GUI {
  68502. /**
  68503. * Class used to create a 2D stack panel container
  68504. */
  68505. export class StackPanel extends Container {
  68506. name?: string | undefined;
  68507. private _isVertical;
  68508. private _manualWidth;
  68509. private _manualHeight;
  68510. private _doNotTrackManualChanges;
  68511. /**
  68512. * Gets or sets a boolean indicating that layou warnings should be ignored
  68513. */
  68514. ignoreLayoutWarnings: boolean;
  68515. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  68516. isVertical: boolean;
  68517. /**
  68518. * Gets or sets panel width.
  68519. * This value should not be set when in horizontal mode as it will be computed automatically
  68520. */
  68521. width: string | number;
  68522. /**
  68523. * Gets or sets panel height.
  68524. * This value should not be set when in vertical mode as it will be computed automatically
  68525. */
  68526. height: string | number;
  68527. /**
  68528. * Creates a new StackPanel
  68529. * @param name defines control name
  68530. */
  68531. constructor(name?: string | undefined);
  68532. protected _getTypeName(): string;
  68533. /** @hidden */
  68534. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68535. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68536. protected _postMeasure(): void;
  68537. }
  68538. }
  68539. declare module BABYLON.GUI {
  68540. /**
  68541. * Class used to represent a 2D checkbox
  68542. */
  68543. export class Checkbox extends Control {
  68544. name?: string | undefined;
  68545. private _isChecked;
  68546. private _background;
  68547. private _checkSizeRatio;
  68548. private _thickness;
  68549. /** Gets or sets border thickness */
  68550. thickness: number;
  68551. /**
  68552. * BABYLON.Observable raised when isChecked property changes
  68553. */
  68554. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  68555. /** Gets or sets a value indicating the ratio between overall size and check size */
  68556. checkSizeRatio: number;
  68557. /** Gets or sets background color */
  68558. background: string;
  68559. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  68560. isChecked: boolean;
  68561. /**
  68562. * Creates a new CheckBox
  68563. * @param name defines the control name
  68564. */
  68565. constructor(name?: string | undefined);
  68566. protected _getTypeName(): string;
  68567. /** @hidden */
  68568. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68569. /** @hidden */
  68570. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68571. /**
  68572. * Utility function to easily create a checkbox with a header
  68573. * @param title defines the label to use for the header
  68574. * @param onValueChanged defines the callback to call when value changes
  68575. * @returns a StackPanel containing the checkbox and a textBlock
  68576. */
  68577. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  68578. }
  68579. }
  68580. declare module BABYLON.GUI {
  68581. /**
  68582. * Class used to store key control properties
  68583. */
  68584. export class KeyPropertySet {
  68585. /** Width */
  68586. width?: string;
  68587. /** Height */
  68588. height?: string;
  68589. /** Left padding */
  68590. paddingLeft?: string;
  68591. /** Right padding */
  68592. paddingRight?: string;
  68593. /** Top padding */
  68594. paddingTop?: string;
  68595. /** Bottom padding */
  68596. paddingBottom?: string;
  68597. /** Foreground color */
  68598. color?: string;
  68599. /** Background color */
  68600. background?: string;
  68601. }
  68602. /**
  68603. * Class used to create virtual keyboard
  68604. */
  68605. export class VirtualKeyboard extends StackPanel {
  68606. /** BABYLON.Observable raised when a key is pressed */
  68607. onKeyPressObservable: BABYLON.Observable<string>;
  68608. /** Gets or sets default key button width */
  68609. defaultButtonWidth: string;
  68610. /** Gets or sets default key button height */
  68611. defaultButtonHeight: string;
  68612. /** Gets or sets default key button left padding */
  68613. defaultButtonPaddingLeft: string;
  68614. /** Gets or sets default key button right padding */
  68615. defaultButtonPaddingRight: string;
  68616. /** Gets or sets default key button top padding */
  68617. defaultButtonPaddingTop: string;
  68618. /** Gets or sets default key button bottom padding */
  68619. defaultButtonPaddingBottom: string;
  68620. /** Gets or sets default key button foreground color */
  68621. defaultButtonColor: string;
  68622. /** Gets or sets default key button background color */
  68623. defaultButtonBackground: string;
  68624. /** Gets or sets shift button foreground color */
  68625. shiftButtonColor: string;
  68626. /** Gets or sets shift button thickness*/
  68627. selectedShiftThickness: number;
  68628. /** Gets shift key state */
  68629. shiftState: number;
  68630. protected _getTypeName(): string;
  68631. private _createKey;
  68632. /**
  68633. * Adds a new row of keys
  68634. * @param keys defines the list of keys to add
  68635. * @param propertySets defines the associated property sets
  68636. */
  68637. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  68638. /**
  68639. * Set the shift key to a specific state
  68640. * @param shiftState defines the new shift state
  68641. */
  68642. applyShiftState(shiftState: number): void;
  68643. private _currentlyConnectedInputText;
  68644. private _connectedInputTexts;
  68645. private _onKeyPressObserver;
  68646. /** Gets the input text control currently attached to the keyboard */
  68647. readonly connectedInputText: BABYLON.Nullable<InputText>;
  68648. /**
  68649. * Connects the keyboard with an input text control
  68650. *
  68651. * @param input defines the target control
  68652. */
  68653. connect(input: InputText): void;
  68654. /**
  68655. * Disconnects the keyboard from connected InputText controls
  68656. *
  68657. * @param input optionally defines a target control, otherwise all are disconnected
  68658. */
  68659. disconnect(input?: InputText): void;
  68660. private _removeConnectedInputObservables;
  68661. /**
  68662. * Release all resources
  68663. */
  68664. dispose(): void;
  68665. /**
  68666. * Creates a new keyboard using a default layout
  68667. *
  68668. * @param name defines control name
  68669. * @returns a new VirtualKeyboard
  68670. */
  68671. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  68672. }
  68673. }
  68674. declare module BABYLON.GUI {
  68675. /**
  68676. * Class used to create input text control
  68677. */
  68678. export class InputText extends Control implements IFocusableControl {
  68679. name?: string | undefined;
  68680. private _text;
  68681. private _placeholderText;
  68682. private _background;
  68683. private _focusedBackground;
  68684. private _focusedColor;
  68685. private _placeholderColor;
  68686. private _thickness;
  68687. private _margin;
  68688. private _autoStretchWidth;
  68689. private _maxWidth;
  68690. private _isFocused;
  68691. private _blinkTimeout;
  68692. private _blinkIsEven;
  68693. private _cursorOffset;
  68694. private _scrollLeft;
  68695. private _textWidth;
  68696. private _clickedCoordinate;
  68697. private _deadKey;
  68698. private _addKey;
  68699. private _currentKey;
  68700. private _isTextHighlightOn;
  68701. private _textHighlightColor;
  68702. private _highligherOpacity;
  68703. private _highlightedText;
  68704. private _startHighlightIndex;
  68705. private _endHighlightIndex;
  68706. private _cursorIndex;
  68707. private _onFocusSelectAll;
  68708. private _isPointerDown;
  68709. private _onClipboardObserver;
  68710. private _onPointerDblTapObserver;
  68711. /** @hidden */
  68712. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  68713. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  68714. promptMessage: string;
  68715. /** Force disable prompt on mobile device */
  68716. disableMobilePrompt: boolean;
  68717. /** BABYLON.Observable raised when the text changes */
  68718. onTextChangedObservable: BABYLON.Observable<InputText>;
  68719. /** BABYLON.Observable raised just before an entered character is to be added */
  68720. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  68721. /** BABYLON.Observable raised when the control gets the focus */
  68722. onFocusObservable: BABYLON.Observable<InputText>;
  68723. /** BABYLON.Observable raised when the control loses the focus */
  68724. onBlurObservable: BABYLON.Observable<InputText>;
  68725. /**Observable raised when the text is highlighted */
  68726. onTextHighlightObservable: BABYLON.Observable<InputText>;
  68727. /**Observable raised when copy event is triggered */
  68728. onTextCopyObservable: BABYLON.Observable<InputText>;
  68729. /** BABYLON.Observable raised when cut event is triggered */
  68730. onTextCutObservable: BABYLON.Observable<InputText>;
  68731. /** BABYLON.Observable raised when paste event is triggered */
  68732. onTextPasteObservable: BABYLON.Observable<InputText>;
  68733. /** BABYLON.Observable raised when a key event was processed */
  68734. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  68735. /** Gets or sets the maximum width allowed by the control */
  68736. maxWidth: string | number;
  68737. /** Gets the maximum width allowed by the control in pixels */
  68738. readonly maxWidthInPixels: number;
  68739. /** Gets or sets the text highlighter transparency; default: 0.4 */
  68740. highligherOpacity: number;
  68741. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  68742. onFocusSelectAll: boolean;
  68743. /** Gets or sets the text hightlight color */
  68744. textHighlightColor: string;
  68745. /** Gets or sets control margin */
  68746. margin: string;
  68747. /** Gets control margin in pixels */
  68748. readonly marginInPixels: number;
  68749. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  68750. autoStretchWidth: boolean;
  68751. /** Gets or sets border thickness */
  68752. thickness: number;
  68753. /** Gets or sets the background color when focused */
  68754. focusedBackground: string;
  68755. /** Gets or sets the background color when focused */
  68756. focusedColor: string;
  68757. /** Gets or sets the background color */
  68758. background: string;
  68759. /** Gets or sets the placeholder color */
  68760. placeholderColor: string;
  68761. /** Gets or sets the text displayed when the control is empty */
  68762. placeholderText: string;
  68763. /** Gets or sets the dead key flag */
  68764. deadKey: boolean;
  68765. /** Gets or sets the highlight text */
  68766. highlightedText: string;
  68767. /** Gets or sets if the current key should be added */
  68768. addKey: boolean;
  68769. /** Gets or sets the value of the current key being entered */
  68770. currentKey: string;
  68771. /** Gets or sets the text displayed in the control */
  68772. text: string;
  68773. /** Gets or sets control width */
  68774. width: string | number;
  68775. /**
  68776. * Creates a new InputText
  68777. * @param name defines the control name
  68778. * @param text defines the text of the control
  68779. */
  68780. constructor(name?: string | undefined, text?: string);
  68781. /** @hidden */
  68782. onBlur(): void;
  68783. /** @hidden */
  68784. onFocus(): void;
  68785. protected _getTypeName(): string;
  68786. /**
  68787. * Function called to get the list of controls that should not steal the focus from this control
  68788. * @returns an array of controls
  68789. */
  68790. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  68791. /** @hidden */
  68792. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  68793. /** @hidden */
  68794. private _updateValueFromCursorIndex;
  68795. /** @hidden */
  68796. private _processDblClick;
  68797. /** @hidden */
  68798. private _selectAllText;
  68799. /**
  68800. * Handles the keyboard event
  68801. * @param evt Defines the KeyboardEvent
  68802. */
  68803. processKeyboard(evt: KeyboardEvent): void;
  68804. /** @hidden */
  68805. private _onCopyText;
  68806. /** @hidden */
  68807. private _onCutText;
  68808. /** @hidden */
  68809. private _onPasteText;
  68810. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68811. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68812. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68813. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68814. protected _beforeRenderText(text: string): string;
  68815. dispose(): void;
  68816. }
  68817. }
  68818. declare module BABYLON.GUI {
  68819. /**
  68820. * Class used to create a 2D grid container
  68821. */
  68822. export class Grid extends Container {
  68823. name?: string | undefined;
  68824. private _rowDefinitions;
  68825. private _columnDefinitions;
  68826. private _cells;
  68827. private _childControls;
  68828. /**
  68829. * Gets the number of columns
  68830. */
  68831. readonly columnCount: number;
  68832. /**
  68833. * Gets the number of rows
  68834. */
  68835. readonly rowCount: number;
  68836. /** Gets the list of children */
  68837. readonly children: Control[];
  68838. /** Gets the list of cells (e.g. the containers) */
  68839. readonly cells: {
  68840. [key: string]: Container;
  68841. };
  68842. /**
  68843. * Gets the definition of a specific row
  68844. * @param index defines the index of the row
  68845. * @returns the row definition
  68846. */
  68847. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  68848. /**
  68849. * Gets the definition of a specific column
  68850. * @param index defines the index of the column
  68851. * @returns the column definition
  68852. */
  68853. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  68854. /**
  68855. * Adds a new row to the grid
  68856. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  68857. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  68858. * @returns the current grid
  68859. */
  68860. addRowDefinition(height: number, isPixel?: boolean): Grid;
  68861. /**
  68862. * Adds a new column to the grid
  68863. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  68864. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  68865. * @returns the current grid
  68866. */
  68867. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  68868. /**
  68869. * Update a row definition
  68870. * @param index defines the index of the row to update
  68871. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  68872. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  68873. * @returns the current grid
  68874. */
  68875. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  68876. /**
  68877. * Update a column definition
  68878. * @param index defines the index of the column to update
  68879. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  68880. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  68881. * @returns the current grid
  68882. */
  68883. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  68884. /**
  68885. * Gets the list of children stored in a specific cell
  68886. * @param row defines the row to check
  68887. * @param column defines the column to check
  68888. * @returns the list of controls
  68889. */
  68890. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  68891. /**
  68892. * Gets a string representing the child cell info (row x column)
  68893. * @param child defines the control to get info from
  68894. * @returns a string containing the child cell info (row x column)
  68895. */
  68896. getChildCellInfo(child: Control): string;
  68897. private _removeCell;
  68898. private _offsetCell;
  68899. /**
  68900. * Remove a column definition at specified index
  68901. * @param index defines the index of the column to remove
  68902. * @returns the current grid
  68903. */
  68904. removeColumnDefinition(index: number): Grid;
  68905. /**
  68906. * Remove a row definition at specified index
  68907. * @param index defines the index of the row to remove
  68908. * @returns the current grid
  68909. */
  68910. removeRowDefinition(index: number): Grid;
  68911. /**
  68912. * Adds a new control to the current grid
  68913. * @param control defines the control to add
  68914. * @param row defines the row where to add the control (0 by default)
  68915. * @param column defines the column where to add the control (0 by default)
  68916. * @returns the current grid
  68917. */
  68918. addControl(control: Control, row?: number, column?: number): Grid;
  68919. /**
  68920. * Removes a control from the current container
  68921. * @param control defines the control to remove
  68922. * @returns the current container
  68923. */
  68924. removeControl(control: Control): Container;
  68925. /**
  68926. * Creates a new Grid
  68927. * @param name defines control name
  68928. */
  68929. constructor(name?: string | undefined);
  68930. protected _getTypeName(): string;
  68931. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  68932. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68933. _flagDescendantsAsMatrixDirty(): void;
  68934. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68935. /** Releases associated resources */
  68936. dispose(): void;
  68937. }
  68938. }
  68939. declare module BABYLON.GUI {
  68940. /** Class used to create color pickers */
  68941. export class ColorPicker extends Control {
  68942. name?: string | undefined;
  68943. private static _Epsilon;
  68944. private _colorWheelCanvas;
  68945. private _value;
  68946. private _tmpColor;
  68947. private _pointerStartedOnSquare;
  68948. private _pointerStartedOnWheel;
  68949. private _squareLeft;
  68950. private _squareTop;
  68951. private _squareSize;
  68952. private _h;
  68953. private _s;
  68954. private _v;
  68955. private _lastPointerDownID;
  68956. /**
  68957. * BABYLON.Observable raised when the value changes
  68958. */
  68959. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  68960. /** Gets or sets the color of the color picker */
  68961. value: BABYLON.Color3;
  68962. /**
  68963. * Gets or sets control width
  68964. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68965. */
  68966. width: string | number;
  68967. /**
  68968. * Gets or sets control height
  68969. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68970. */
  68971. /** Gets or sets control height */
  68972. height: string | number;
  68973. /** Gets or sets control size */
  68974. size: string | number;
  68975. /**
  68976. * Creates a new ColorPicker
  68977. * @param name defines the control name
  68978. */
  68979. constructor(name?: string | undefined);
  68980. protected _getTypeName(): string;
  68981. /** @hidden */
  68982. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68983. private _updateSquareProps;
  68984. private _drawGradientSquare;
  68985. private _drawCircle;
  68986. private _createColorWheelCanvas;
  68987. /** @hidden */
  68988. _draw(context: CanvasRenderingContext2D): void;
  68989. private _pointerIsDown;
  68990. private _updateValueFromPointer;
  68991. private _isPointOnSquare;
  68992. private _isPointOnWheel;
  68993. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68994. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68995. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68996. /**
  68997. * This function expands the color picker by creating a color picker dialog with manual
  68998. * color value input and the ability to save colors into an array to be used later in
  68999. * subsequent launches of the dialogue.
  69000. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  69001. * @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.
  69002. * @returns picked color as a hex string and the saved colors array as hex strings.
  69003. */
  69004. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  69005. pickerWidth?: string;
  69006. pickerHeight?: string;
  69007. headerHeight?: string;
  69008. lastColor?: string;
  69009. swatchLimit?: number;
  69010. numSwatchesPerLine?: number;
  69011. savedColors?: Array<string>;
  69012. }): Promise<{
  69013. savedColors?: string[];
  69014. pickedColor: string;
  69015. }>;
  69016. }
  69017. }
  69018. declare module BABYLON.GUI {
  69019. /** Class used to create 2D ellipse containers */
  69020. export class Ellipse extends Container {
  69021. name?: string | undefined;
  69022. private _thickness;
  69023. /** Gets or sets border thickness */
  69024. thickness: number;
  69025. /**
  69026. * Creates a new Ellipse
  69027. * @param name defines the control name
  69028. */
  69029. constructor(name?: string | undefined);
  69030. protected _getTypeName(): string;
  69031. protected _localDraw(context: CanvasRenderingContext2D): void;
  69032. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69033. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  69034. }
  69035. }
  69036. declare module BABYLON.GUI {
  69037. /**
  69038. * Class used to create a password control
  69039. */
  69040. export class InputPassword extends InputText {
  69041. protected _beforeRenderText(text: string): string;
  69042. }
  69043. }
  69044. declare module BABYLON.GUI {
  69045. /** Class used to render 2D lines */
  69046. export class Line extends Control {
  69047. name?: string | undefined;
  69048. private _lineWidth;
  69049. private _x1;
  69050. private _y1;
  69051. private _x2;
  69052. private _y2;
  69053. private _dash;
  69054. private _connectedControl;
  69055. private _connectedControlDirtyObserver;
  69056. /** Gets or sets the dash pattern */
  69057. dash: Array<number>;
  69058. /** Gets or sets the control connected with the line end */
  69059. connectedControl: Control;
  69060. /** Gets or sets start coordinates on X axis */
  69061. x1: string | number;
  69062. /** Gets or sets start coordinates on Y axis */
  69063. y1: string | number;
  69064. /** Gets or sets end coordinates on X axis */
  69065. x2: string | number;
  69066. /** Gets or sets end coordinates on Y axis */
  69067. y2: string | number;
  69068. /** Gets or sets line width */
  69069. lineWidth: number;
  69070. /** Gets or sets horizontal alignment */
  69071. horizontalAlignment: number;
  69072. /** Gets or sets vertical alignment */
  69073. verticalAlignment: number;
  69074. private readonly _effectiveX2;
  69075. private readonly _effectiveY2;
  69076. /**
  69077. * Creates a new Line
  69078. * @param name defines the control name
  69079. */
  69080. constructor(name?: string | undefined);
  69081. protected _getTypeName(): string;
  69082. _draw(context: CanvasRenderingContext2D): void;
  69083. _measure(): void;
  69084. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69085. /**
  69086. * Move one end of the line given 3D cartesian coordinates.
  69087. * @param position Targeted world position
  69088. * @param scene BABYLON.Scene
  69089. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69090. */
  69091. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  69092. /**
  69093. * Move one end of the line to a position in screen absolute space.
  69094. * @param projectedPosition Position in screen absolute space (X, Y)
  69095. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69096. */
  69097. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  69098. }
  69099. }
  69100. declare module BABYLON.GUI {
  69101. /**
  69102. * Class used to store a point for a MultiLine object.
  69103. * The point can be pure 2D coordinates, a mesh or a control
  69104. */
  69105. export class MultiLinePoint {
  69106. private _multiLine;
  69107. private _x;
  69108. private _y;
  69109. private _control;
  69110. private _mesh;
  69111. private _controlObserver;
  69112. private _meshObserver;
  69113. /** @hidden */
  69114. _point: BABYLON.Vector2;
  69115. /**
  69116. * Creates a new MultiLinePoint
  69117. * @param multiLine defines the source MultiLine object
  69118. */
  69119. constructor(multiLine: MultiLine);
  69120. /** Gets or sets x coordinate */
  69121. x: string | number;
  69122. /** Gets or sets y coordinate */
  69123. y: string | number;
  69124. /** Gets or sets the control associated with this point */
  69125. control: BABYLON.Nullable<Control>;
  69126. /** Gets or sets the mesh associated with this point */
  69127. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  69128. /** Resets links */
  69129. resetLinks(): void;
  69130. /**
  69131. * Gets a translation vector
  69132. * @returns the translation vector
  69133. */
  69134. translate(): BABYLON.Vector2;
  69135. private _translatePoint;
  69136. /** Release associated resources */
  69137. dispose(): void;
  69138. }
  69139. }
  69140. declare module BABYLON.GUI {
  69141. /**
  69142. * Class used to create multi line control
  69143. */
  69144. export class MultiLine extends Control {
  69145. name?: string | undefined;
  69146. private _lineWidth;
  69147. private _dash;
  69148. private _points;
  69149. private _minX;
  69150. private _minY;
  69151. private _maxX;
  69152. private _maxY;
  69153. /**
  69154. * Creates a new MultiLine
  69155. * @param name defines the control name
  69156. */
  69157. constructor(name?: string | undefined);
  69158. /** Gets or sets dash pattern */
  69159. dash: Array<number>;
  69160. /**
  69161. * Gets point stored at specified index
  69162. * @param index defines the index to look for
  69163. * @returns the requested point if found
  69164. */
  69165. getAt(index: number): MultiLinePoint;
  69166. /** Function called when a point is updated */
  69167. onPointUpdate: () => void;
  69168. /**
  69169. * Adds new points to the point collection
  69170. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  69171. * @returns the list of created MultiLinePoint
  69172. */
  69173. add(...items: (AbstractMesh | Control | {
  69174. x: string | number;
  69175. y: string | number;
  69176. })[]): MultiLinePoint[];
  69177. /**
  69178. * Adds a new point to the point collection
  69179. * @param item defines the item (mesh, control or 2d coordiantes) to add
  69180. * @returns the created MultiLinePoint
  69181. */
  69182. push(item?: (AbstractMesh | Control | {
  69183. x: string | number;
  69184. y: string | number;
  69185. })): MultiLinePoint;
  69186. /**
  69187. * Remove a specific value or point from the active point collection
  69188. * @param value defines the value or point to remove
  69189. */
  69190. remove(value: number | MultiLinePoint): void;
  69191. /**
  69192. * Resets this object to initial state (no point)
  69193. */
  69194. reset(): void;
  69195. /**
  69196. * Resets all links
  69197. */
  69198. resetLinks(): void;
  69199. /** Gets or sets line width */
  69200. lineWidth: number;
  69201. horizontalAlignment: number;
  69202. verticalAlignment: number;
  69203. protected _getTypeName(): string;
  69204. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69205. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69206. _measure(): void;
  69207. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69208. dispose(): void;
  69209. }
  69210. }
  69211. declare module BABYLON.GUI {
  69212. /**
  69213. * Class used to create radio button controls
  69214. */
  69215. export class RadioButton extends Control {
  69216. name?: string | undefined;
  69217. private _isChecked;
  69218. private _background;
  69219. private _checkSizeRatio;
  69220. private _thickness;
  69221. /** Gets or sets border thickness */
  69222. thickness: number;
  69223. /** Gets or sets group name */
  69224. group: string;
  69225. /** BABYLON.Observable raised when isChecked is changed */
  69226. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  69227. /** Gets or sets a value indicating the ratio between overall size and check size */
  69228. checkSizeRatio: number;
  69229. /** Gets or sets background color */
  69230. background: string;
  69231. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  69232. isChecked: boolean;
  69233. /**
  69234. * Creates a new RadioButton
  69235. * @param name defines the control name
  69236. */
  69237. constructor(name?: string | undefined);
  69238. protected _getTypeName(): string;
  69239. _draw(context: CanvasRenderingContext2D): void;
  69240. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69241. /**
  69242. * Utility function to easily create a radio button with a header
  69243. * @param title defines the label to use for the header
  69244. * @param group defines the group to use for the radio button
  69245. * @param isChecked defines the initial state of the radio button
  69246. * @param onValueChanged defines the callback to call when value changes
  69247. * @returns a StackPanel containing the radio button and a textBlock
  69248. */
  69249. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  69250. }
  69251. }
  69252. declare module BABYLON.GUI {
  69253. /**
  69254. * Class used to create slider controls
  69255. */
  69256. export class BaseSlider extends Control {
  69257. name?: string | undefined;
  69258. protected _thumbWidth: ValueAndUnit;
  69259. private _minimum;
  69260. private _maximum;
  69261. private _value;
  69262. private _isVertical;
  69263. protected _barOffset: ValueAndUnit;
  69264. private _isThumbClamped;
  69265. protected _displayThumb: boolean;
  69266. private _step;
  69267. private _lastPointerDownID;
  69268. protected _effectiveBarOffset: number;
  69269. protected _renderLeft: number;
  69270. protected _renderTop: number;
  69271. protected _renderWidth: number;
  69272. protected _renderHeight: number;
  69273. protected _backgroundBoxLength: number;
  69274. protected _backgroundBoxThickness: number;
  69275. protected _effectiveThumbThickness: number;
  69276. /** BABYLON.Observable raised when the sldier value changes */
  69277. onValueChangedObservable: BABYLON.Observable<number>;
  69278. /** Gets or sets a boolean indicating if the thumb must be rendered */
  69279. displayThumb: boolean;
  69280. /** Gets or sets a step to apply to values (0 by default) */
  69281. step: number;
  69282. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  69283. barOffset: string | number;
  69284. /** Gets main bar offset in pixels*/
  69285. readonly barOffsetInPixels: number;
  69286. /** Gets or sets thumb width */
  69287. thumbWidth: string | number;
  69288. /** Gets thumb width in pixels */
  69289. readonly thumbWidthInPixels: number;
  69290. /** Gets or sets minimum value */
  69291. minimum: number;
  69292. /** Gets or sets maximum value */
  69293. maximum: number;
  69294. /** Gets or sets current value */
  69295. value: number;
  69296. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  69297. isVertical: boolean;
  69298. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  69299. isThumbClamped: boolean;
  69300. /**
  69301. * Creates a new BaseSlider
  69302. * @param name defines the control name
  69303. */
  69304. constructor(name?: string | undefined);
  69305. protected _getTypeName(): string;
  69306. protected _getThumbPosition(): number;
  69307. protected _getThumbThickness(type: string): number;
  69308. protected _prepareRenderingData(type: string): void;
  69309. private _pointerIsDown;
  69310. /** @hidden */
  69311. protected _updateValueFromPointer(x: number, y: number): void;
  69312. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69313. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69314. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69315. }
  69316. }
  69317. declare module BABYLON.GUI {
  69318. /**
  69319. * Class used to create slider controls
  69320. */
  69321. export class Slider extends BaseSlider {
  69322. name?: string | undefined;
  69323. private _background;
  69324. private _borderColor;
  69325. private _isThumbCircle;
  69326. protected _displayValueBar: boolean;
  69327. /** Gets or sets a boolean indicating if the value bar must be rendered */
  69328. displayValueBar: boolean;
  69329. /** Gets or sets border color */
  69330. borderColor: string;
  69331. /** Gets or sets background color */
  69332. background: string;
  69333. /** Gets or sets a boolean indicating if the thumb should be round or square */
  69334. isThumbCircle: boolean;
  69335. /**
  69336. * Creates a new Slider
  69337. * @param name defines the control name
  69338. */
  69339. constructor(name?: string | undefined);
  69340. protected _getTypeName(): string;
  69341. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69342. }
  69343. }
  69344. declare module BABYLON.GUI {
  69345. /** Class used to create a RadioGroup
  69346. * which contains groups of radio buttons
  69347. */
  69348. export class SelectorGroup {
  69349. /** name of SelectorGroup */
  69350. name: string;
  69351. private _groupPanel;
  69352. private _selectors;
  69353. private _groupHeader;
  69354. /**
  69355. * Creates a new SelectorGroup
  69356. * @param name of group, used as a group heading
  69357. */
  69358. constructor(
  69359. /** name of SelectorGroup */
  69360. name: string);
  69361. /** Gets the groupPanel of the SelectorGroup */
  69362. readonly groupPanel: StackPanel;
  69363. /** Gets the selectors array */
  69364. readonly selectors: StackPanel[];
  69365. /** Gets and sets the group header */
  69366. header: string;
  69367. /** @hidden */
  69368. private _addGroupHeader;
  69369. /** @hidden*/
  69370. _getSelector(selectorNb: number): StackPanel | undefined;
  69371. /** Removes the selector at the given position
  69372. * @param selectorNb the position of the selector within the group
  69373. */
  69374. removeSelector(selectorNb: number): void;
  69375. }
  69376. /** Class used to create a CheckboxGroup
  69377. * which contains groups of checkbox buttons
  69378. */
  69379. export class CheckboxGroup extends SelectorGroup {
  69380. /** Adds a checkbox as a control
  69381. * @param text is the label for the selector
  69382. * @param func is the function called when the Selector is checked
  69383. * @param checked is true when Selector is checked
  69384. */
  69385. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  69386. /** @hidden */
  69387. _setSelectorLabel(selectorNb: number, label: string): void;
  69388. /** @hidden */
  69389. _setSelectorLabelColor(selectorNb: number, color: string): void;
  69390. /** @hidden */
  69391. _setSelectorButtonColor(selectorNb: number, color: string): void;
  69392. /** @hidden */
  69393. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  69394. }
  69395. /** Class used to create a RadioGroup
  69396. * which contains groups of radio buttons
  69397. */
  69398. export class RadioGroup extends SelectorGroup {
  69399. private _selectNb;
  69400. /** Adds a radio button as a control
  69401. * @param label is the label for the selector
  69402. * @param func is the function called when the Selector is checked
  69403. * @param checked is true when Selector is checked
  69404. */
  69405. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  69406. /** @hidden */
  69407. _setSelectorLabel(selectorNb: number, label: string): void;
  69408. /** @hidden */
  69409. _setSelectorLabelColor(selectorNb: number, color: string): void;
  69410. /** @hidden */
  69411. _setSelectorButtonColor(selectorNb: number, color: string): void;
  69412. /** @hidden */
  69413. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  69414. }
  69415. /** Class used to create a SliderGroup
  69416. * which contains groups of slider buttons
  69417. */
  69418. export class SliderGroup extends SelectorGroup {
  69419. /**
  69420. * Adds a slider to the SelectorGroup
  69421. * @param label is the label for the SliderBar
  69422. * @param func is the function called when the Slider moves
  69423. * @param unit is a string describing the units used, eg degrees or metres
  69424. * @param min is the minimum value for the Slider
  69425. * @param max is the maximum value for the Slider
  69426. * @param value is the start value for the Slider between min and max
  69427. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  69428. */
  69429. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  69430. /** @hidden */
  69431. _setSelectorLabel(selectorNb: number, label: string): void;
  69432. /** @hidden */
  69433. _setSelectorLabelColor(selectorNb: number, color: string): void;
  69434. /** @hidden */
  69435. _setSelectorButtonColor(selectorNb: number, color: string): void;
  69436. /** @hidden */
  69437. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  69438. }
  69439. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  69440. * @see http://doc.babylonjs.com/how_to/selector
  69441. */
  69442. export class SelectionPanel extends Rectangle {
  69443. /** name of SelectionPanel */
  69444. name: string;
  69445. /** an array of SelectionGroups */
  69446. groups: SelectorGroup[];
  69447. private _panel;
  69448. private _buttonColor;
  69449. private _buttonBackground;
  69450. private _headerColor;
  69451. private _barColor;
  69452. private _barHeight;
  69453. private _spacerHeight;
  69454. private _labelColor;
  69455. private _groups;
  69456. private _bars;
  69457. /**
  69458. * Creates a new SelectionPanel
  69459. * @param name of SelectionPanel
  69460. * @param groups is an array of SelectionGroups
  69461. */
  69462. constructor(
  69463. /** name of SelectionPanel */
  69464. name: string,
  69465. /** an array of SelectionGroups */
  69466. groups?: SelectorGroup[]);
  69467. protected _getTypeName(): string;
  69468. /** Gets or sets the headerColor */
  69469. headerColor: string;
  69470. private _setHeaderColor;
  69471. /** Gets or sets the button color */
  69472. buttonColor: string;
  69473. private _setbuttonColor;
  69474. /** Gets or sets the label color */
  69475. labelColor: string;
  69476. private _setLabelColor;
  69477. /** Gets or sets the button background */
  69478. buttonBackground: string;
  69479. private _setButtonBackground;
  69480. /** Gets or sets the color of separator bar */
  69481. barColor: string;
  69482. private _setBarColor;
  69483. /** Gets or sets the height of separator bar */
  69484. barHeight: string;
  69485. private _setBarHeight;
  69486. /** Gets or sets the height of spacers*/
  69487. spacerHeight: string;
  69488. private _setSpacerHeight;
  69489. /** Adds a bar between groups */
  69490. private _addSpacer;
  69491. /** Add a group to the selection panel
  69492. * @param group is the selector group to add
  69493. */
  69494. addGroup(group: SelectorGroup): void;
  69495. /** Remove the group from the given position
  69496. * @param groupNb is the position of the group in the list
  69497. */
  69498. removeGroup(groupNb: number): void;
  69499. /** Change a group header label
  69500. * @param label is the new group header label
  69501. * @param groupNb is the number of the group to relabel
  69502. * */
  69503. setHeaderName(label: string, groupNb: number): void;
  69504. /** Change selector label to the one given
  69505. * @param label is the new selector label
  69506. * @param groupNb is the number of the groupcontaining the selector
  69507. * @param selectorNb is the number of the selector within a group to relabel
  69508. * */
  69509. relabel(label: string, groupNb: number, selectorNb: number): void;
  69510. /** For a given group position remove the selector at the given position
  69511. * @param groupNb is the number of the group to remove the selector from
  69512. * @param selectorNb is the number of the selector within the group
  69513. */
  69514. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  69515. /** For a given group position of correct type add a checkbox button
  69516. * @param groupNb is the number of the group to remove the selector from
  69517. * @param label is the label for the selector
  69518. * @param func is the function called when the Selector is checked
  69519. * @param checked is true when Selector is checked
  69520. */
  69521. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  69522. /** For a given group position of correct type add a radio button
  69523. * @param groupNb is the number of the group to remove the selector from
  69524. * @param label is the label for the selector
  69525. * @param func is the function called when the Selector is checked
  69526. * @param checked is true when Selector is checked
  69527. */
  69528. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  69529. /**
  69530. * For a given slider group add a slider
  69531. * @param groupNb is the number of the group to add the slider to
  69532. * @param label is the label for the Slider
  69533. * @param func is the function called when the Slider moves
  69534. * @param unit is a string describing the units used, eg degrees or metres
  69535. * @param min is the minimum value for the Slider
  69536. * @param max is the maximum value for the Slider
  69537. * @param value is the start value for the Slider between min and max
  69538. * @param onVal is the function used to format the value displayed, eg radians to degrees
  69539. */
  69540. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  69541. }
  69542. }
  69543. declare module BABYLON.GUI {
  69544. /**
  69545. * Class used to hold a the container for ScrollViewer
  69546. * @hidden
  69547. */
  69548. export class _ScrollViewerWindow extends Container {
  69549. parentClientWidth: number;
  69550. parentClientHeight: number;
  69551. /**
  69552. * Creates a new ScrollViewerWindow
  69553. * @param name of ScrollViewerWindow
  69554. */
  69555. constructor(name?: string);
  69556. protected _getTypeName(): string;
  69557. /** @hidden */
  69558. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69559. protected _postMeasure(): void;
  69560. }
  69561. }
  69562. declare module BABYLON.GUI {
  69563. /**
  69564. * Class used to create slider controls
  69565. */
  69566. export class ScrollBar extends BaseSlider {
  69567. name?: string | undefined;
  69568. private _background;
  69569. private _borderColor;
  69570. private _tempMeasure;
  69571. /** Gets or sets border color */
  69572. borderColor: string;
  69573. /** Gets or sets background color */
  69574. background: string;
  69575. /**
  69576. * Creates a new Slider
  69577. * @param name defines the control name
  69578. */
  69579. constructor(name?: string | undefined);
  69580. protected _getTypeName(): string;
  69581. protected _getThumbThickness(): number;
  69582. _draw(context: CanvasRenderingContext2D): void;
  69583. private _first;
  69584. private _originX;
  69585. private _originY;
  69586. /** @hidden */
  69587. protected _updateValueFromPointer(x: number, y: number): void;
  69588. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69589. }
  69590. }
  69591. declare module BABYLON.GUI {
  69592. /**
  69593. * Class used to create slider controls
  69594. */
  69595. export class ImageScrollBar extends BaseSlider {
  69596. name?: string | undefined;
  69597. private _backgroundBaseImage;
  69598. private _backgroundImage;
  69599. private _thumbImage;
  69600. private _thumbBaseImage;
  69601. private _thumbLength;
  69602. private _thumbHeight;
  69603. private _barImageHeight;
  69604. private _tempMeasure;
  69605. /**
  69606. * Gets or sets the image used to render the background for horizontal bar
  69607. */
  69608. backgroundImage: Image;
  69609. /**
  69610. * Gets or sets the image used to render the thumb
  69611. */
  69612. thumbImage: Image;
  69613. /**
  69614. * Gets or sets the length of the thumb
  69615. */
  69616. thumbLength: number;
  69617. /**
  69618. * Gets or sets the height of the thumb
  69619. */
  69620. thumbHeight: number;
  69621. /**
  69622. * Gets or sets the height of the bar image
  69623. */
  69624. barImageHeight: number;
  69625. /**
  69626. * Creates a new ImageScrollBar
  69627. * @param name defines the control name
  69628. */
  69629. constructor(name?: string | undefined);
  69630. protected _getTypeName(): string;
  69631. protected _getThumbThickness(): number;
  69632. _draw(context: CanvasRenderingContext2D): void;
  69633. private _first;
  69634. private _originX;
  69635. private _originY;
  69636. /** @hidden */
  69637. protected _updateValueFromPointer(x: number, y: number): void;
  69638. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69639. }
  69640. }
  69641. declare module BABYLON.GUI {
  69642. /**
  69643. * Class used to hold a viewer window and sliders in a grid
  69644. */
  69645. export class ScrollViewer extends Rectangle {
  69646. private _grid;
  69647. private _horizontalBarSpace;
  69648. private _verticalBarSpace;
  69649. private _dragSpace;
  69650. private _horizontalBar;
  69651. private _verticalBar;
  69652. private _barColor;
  69653. private _barBackground;
  69654. private _barImage;
  69655. private _barBackgroundImage;
  69656. private _barSize;
  69657. private _endLeft;
  69658. private _endTop;
  69659. private _window;
  69660. private _pointerIsOver;
  69661. private _wheelPrecision;
  69662. private _onPointerObserver;
  69663. private _clientWidth;
  69664. private _clientHeight;
  69665. private _useImageBar;
  69666. private _thumbLength;
  69667. private _thumbHeight;
  69668. private _barImageHeight;
  69669. /**
  69670. * Gets the horizontal scrollbar
  69671. */
  69672. readonly horizontalBar: ScrollBar | ImageScrollBar;
  69673. /**
  69674. * Gets the vertical scrollbar
  69675. */
  69676. readonly verticalBar: ScrollBar | ImageScrollBar;
  69677. /**
  69678. * Adds a new control to the current container
  69679. * @param control defines the control to add
  69680. * @returns the current container
  69681. */
  69682. addControl(control: BABYLON.Nullable<Control>): Container;
  69683. /**
  69684. * Removes a control from the current container
  69685. * @param control defines the control to remove
  69686. * @returns the current container
  69687. */
  69688. removeControl(control: Control): Container;
  69689. /** Gets the list of children */
  69690. readonly children: Control[];
  69691. _flagDescendantsAsMatrixDirty(): void;
  69692. /**
  69693. * Creates a new ScrollViewer
  69694. * @param name of ScrollViewer
  69695. */
  69696. constructor(name?: string, isImageBased?: boolean);
  69697. /** Reset the scroll viewer window to initial size */
  69698. resetWindow(): void;
  69699. protected _getTypeName(): string;
  69700. private _buildClientSizes;
  69701. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69702. protected _postMeasure(): void;
  69703. /**
  69704. * Gets or sets the mouse wheel precision
  69705. * from 0 to 1 with a default value of 0.05
  69706. * */
  69707. wheelPrecision: number;
  69708. /** Gets or sets the scroll bar container background color */
  69709. scrollBackground: string;
  69710. /** Gets or sets the bar color */
  69711. barColor: string;
  69712. /** Gets or sets the bar image */
  69713. thumbImage: Image;
  69714. /** Gets or sets the size of the bar */
  69715. barSize: number;
  69716. /** Gets or sets the length of the thumb */
  69717. thumbLength: number;
  69718. /** Gets or sets the height of the thumb */
  69719. thumbHeight: number;
  69720. /** Gets or sets the height of the bar image */
  69721. barImageHeight: number;
  69722. /** Gets or sets the bar background */
  69723. barBackground: string;
  69724. /** Gets or sets the bar background image */
  69725. barImage: Image;
  69726. /** @hidden */
  69727. private _updateScroller;
  69728. _link(host: AdvancedDynamicTexture): void;
  69729. /** @hidden */
  69730. private _addBar;
  69731. /** @hidden */
  69732. private _attachWheel;
  69733. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  69734. /** Releases associated resources */
  69735. dispose(): void;
  69736. }
  69737. }
  69738. declare module BABYLON.GUI {
  69739. /** Class used to render a grid */
  69740. export class DisplayGrid extends Control {
  69741. name?: string | undefined;
  69742. private _cellWidth;
  69743. private _cellHeight;
  69744. private _minorLineTickness;
  69745. private _minorLineColor;
  69746. private _majorLineTickness;
  69747. private _majorLineColor;
  69748. private _majorLineFrequency;
  69749. private _background;
  69750. private _displayMajorLines;
  69751. private _displayMinorLines;
  69752. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  69753. displayMinorLines: boolean;
  69754. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  69755. displayMajorLines: boolean;
  69756. /** Gets or sets background color (Black by default) */
  69757. background: string;
  69758. /** Gets or sets the width of each cell (20 by default) */
  69759. cellWidth: number;
  69760. /** Gets or sets the height of each cell (20 by default) */
  69761. cellHeight: number;
  69762. /** Gets or sets the tickness of minor lines (1 by default) */
  69763. minorLineTickness: number;
  69764. /** Gets or sets the color of minor lines (DarkGray by default) */
  69765. minorLineColor: string;
  69766. /** Gets or sets the tickness of major lines (2 by default) */
  69767. majorLineTickness: number;
  69768. /** Gets or sets the color of major lines (White by default) */
  69769. majorLineColor: string;
  69770. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  69771. majorLineFrequency: number;
  69772. /**
  69773. * Creates a new GridDisplayRectangle
  69774. * @param name defines the control name
  69775. */
  69776. constructor(name?: string | undefined);
  69777. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69778. protected _getTypeName(): string;
  69779. }
  69780. }
  69781. declare module BABYLON.GUI {
  69782. /**
  69783. * Class used to create slider controls based on images
  69784. */
  69785. export class ImageBasedSlider extends BaseSlider {
  69786. name?: string | undefined;
  69787. private _backgroundImage;
  69788. private _thumbImage;
  69789. private _valueBarImage;
  69790. private _tempMeasure;
  69791. displayThumb: boolean;
  69792. /**
  69793. * Gets or sets the image used to render the background
  69794. */
  69795. backgroundImage: Image;
  69796. /**
  69797. * Gets or sets the image used to render the value bar
  69798. */
  69799. valueBarImage: Image;
  69800. /**
  69801. * Gets or sets the image used to render the thumb
  69802. */
  69803. thumbImage: Image;
  69804. /**
  69805. * Creates a new ImageBasedSlider
  69806. * @param name defines the control name
  69807. */
  69808. constructor(name?: string | undefined);
  69809. protected _getTypeName(): string;
  69810. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69811. }
  69812. }
  69813. declare module BABYLON.GUI {
  69814. /**
  69815. * Forcing an export so that this code will execute
  69816. * @hidden
  69817. */
  69818. const name = "Statics";
  69819. }
  69820. declare module BABYLON.GUI {
  69821. /**
  69822. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  69823. */
  69824. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  69825. /**
  69826. * Define the instrumented AdvancedDynamicTexture.
  69827. */
  69828. texture: AdvancedDynamicTexture;
  69829. private _captureRenderTime;
  69830. private _renderTime;
  69831. private _captureLayoutTime;
  69832. private _layoutTime;
  69833. private _onBeginRenderObserver;
  69834. private _onEndRenderObserver;
  69835. private _onBeginLayoutObserver;
  69836. private _onEndLayoutObserver;
  69837. /**
  69838. * Gets the perf counter used to capture render time
  69839. */
  69840. readonly renderTimeCounter: BABYLON.PerfCounter;
  69841. /**
  69842. * Gets the perf counter used to capture layout time
  69843. */
  69844. readonly layoutTimeCounter: BABYLON.PerfCounter;
  69845. /**
  69846. * Enable or disable the render time capture
  69847. */
  69848. captureRenderTime: boolean;
  69849. /**
  69850. * Enable or disable the layout time capture
  69851. */
  69852. captureLayoutTime: boolean;
  69853. /**
  69854. * Instantiates a new advanced dynamic texture instrumentation.
  69855. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  69856. * @param texture Defines the AdvancedDynamicTexture to instrument
  69857. */
  69858. constructor(
  69859. /**
  69860. * Define the instrumented AdvancedDynamicTexture.
  69861. */
  69862. texture: AdvancedDynamicTexture);
  69863. /**
  69864. * Dispose and release associated resources.
  69865. */
  69866. dispose(): void;
  69867. }
  69868. }
  69869. declare module BABYLON.GUI {
  69870. /**
  69871. * Class used to load GUI via XML.
  69872. */
  69873. export class XmlLoader {
  69874. private _nodes;
  69875. private _nodeTypes;
  69876. private _isLoaded;
  69877. private _objectAttributes;
  69878. private _parentClass;
  69879. /**
  69880. * Create a new xml loader
  69881. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  69882. */
  69883. constructor(parentClass?: null);
  69884. private _getChainElement;
  69885. private _getClassAttribute;
  69886. private _createGuiElement;
  69887. private _parseGrid;
  69888. private _parseElement;
  69889. private _prepareSourceElement;
  69890. private _parseElementsFromSource;
  69891. private _parseXml;
  69892. /**
  69893. * Gets if the loading has finished.
  69894. * @returns whether the loading has finished or not
  69895. */
  69896. isLoaded(): boolean;
  69897. /**
  69898. * Gets a loaded node / control by id.
  69899. * @param id the Controls id set in the xml
  69900. * @returns element of type Control
  69901. */
  69902. getNodeById(id: string): any;
  69903. /**
  69904. * Gets all loaded nodes / controls
  69905. * @returns Array of controls
  69906. */
  69907. getNodes(): any;
  69908. /**
  69909. * Initiates the xml layout loading
  69910. * @param xmlFile defines the xml layout to load
  69911. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  69912. * @param callback defines the callback called on layout load.
  69913. */
  69914. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  69915. }
  69916. }
  69917. declare module BABYLON.GUI {
  69918. /**
  69919. * Class used to create containers for controls
  69920. */
  69921. export class Container3D extends Control3D {
  69922. private _blockLayout;
  69923. /**
  69924. * Gets the list of child controls
  69925. */
  69926. protected _children: Control3D[];
  69927. /**
  69928. * Gets the list of child controls
  69929. */
  69930. readonly children: Array<Control3D>;
  69931. /**
  69932. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  69933. * This is helpful to optimize layout operation when adding multiple children in a row
  69934. */
  69935. blockLayout: boolean;
  69936. /**
  69937. * Creates a new container
  69938. * @param name defines the container name
  69939. */
  69940. constructor(name?: string);
  69941. /**
  69942. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  69943. * @returns the current container
  69944. */
  69945. updateLayout(): Container3D;
  69946. /**
  69947. * Gets a boolean indicating if the given control is in the children of this control
  69948. * @param control defines the control to check
  69949. * @returns true if the control is in the child list
  69950. */
  69951. containsControl(control: Control3D): boolean;
  69952. /**
  69953. * Adds a control to the children of this control
  69954. * @param control defines the control to add
  69955. * @returns the current container
  69956. */
  69957. addControl(control: Control3D): Container3D;
  69958. /**
  69959. * This function will be called everytime a new control is added
  69960. */
  69961. protected _arrangeChildren(): void;
  69962. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  69963. /**
  69964. * Removes a control from the children of this control
  69965. * @param control defines the control to remove
  69966. * @returns the current container
  69967. */
  69968. removeControl(control: Control3D): Container3D;
  69969. protected _getTypeName(): string;
  69970. /**
  69971. * Releases all associated resources
  69972. */
  69973. dispose(): void;
  69974. /** Control rotation will remain unchanged */
  69975. static readonly UNSET_ORIENTATION: number;
  69976. /** Control will rotate to make it look at sphere central axis */
  69977. static readonly FACEORIGIN_ORIENTATION: number;
  69978. /** Control will rotate to make it look back at sphere central axis */
  69979. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  69980. /** Control will rotate to look at z axis (0, 0, 1) */
  69981. static readonly FACEFORWARD_ORIENTATION: number;
  69982. /** Control will rotate to look at negative z axis (0, 0, -1) */
  69983. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  69984. }
  69985. }
  69986. declare module BABYLON.GUI {
  69987. /**
  69988. * Class used to manage 3D user interface
  69989. * @see http://doc.babylonjs.com/how_to/gui3d
  69990. */
  69991. export class GUI3DManager implements BABYLON.IDisposable {
  69992. private _scene;
  69993. private _sceneDisposeObserver;
  69994. private _utilityLayer;
  69995. private _rootContainer;
  69996. private _pointerObserver;
  69997. private _pointerOutObserver;
  69998. /** @hidden */
  69999. _lastPickedControl: Control3D;
  70000. /** @hidden */
  70001. _lastControlOver: {
  70002. [pointerId: number]: Control3D;
  70003. };
  70004. /** @hidden */
  70005. _lastControlDown: {
  70006. [pointerId: number]: Control3D;
  70007. };
  70008. /**
  70009. * BABYLON.Observable raised when the point picked by the pointer events changed
  70010. */
  70011. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  70012. /** @hidden */
  70013. _sharedMaterials: {
  70014. [key: string]: BABYLON.Material;
  70015. };
  70016. /** Gets the hosting scene */
  70017. readonly scene: BABYLON.Scene;
  70018. /** Gets associated utility layer */
  70019. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  70020. /**
  70021. * Creates a new GUI3DManager
  70022. * @param scene
  70023. */
  70024. constructor(scene?: BABYLON.Scene);
  70025. private _handlePointerOut;
  70026. private _doPicking;
  70027. /**
  70028. * Gets the root container
  70029. */
  70030. readonly rootContainer: Container3D;
  70031. /**
  70032. * Gets a boolean indicating if the given control is in the root child list
  70033. * @param control defines the control to check
  70034. * @returns true if the control is in the root child list
  70035. */
  70036. containsControl(control: Control3D): boolean;
  70037. /**
  70038. * Adds a control to the root child list
  70039. * @param control defines the control to add
  70040. * @returns the current manager
  70041. */
  70042. addControl(control: Control3D): GUI3DManager;
  70043. /**
  70044. * Removes a control from the root child list
  70045. * @param control defines the control to remove
  70046. * @returns the current container
  70047. */
  70048. removeControl(control: Control3D): GUI3DManager;
  70049. /**
  70050. * Releases all associated resources
  70051. */
  70052. dispose(): void;
  70053. }
  70054. }
  70055. declare module BABYLON.GUI {
  70056. /**
  70057. * Class used to transport BABYLON.Vector3 information for pointer events
  70058. */
  70059. export class Vector3WithInfo extends BABYLON.Vector3 {
  70060. /** defines the current mouse button index */
  70061. buttonIndex: number;
  70062. /**
  70063. * Creates a new Vector3WithInfo
  70064. * @param source defines the vector3 data to transport
  70065. * @param buttonIndex defines the current mouse button index
  70066. */
  70067. constructor(source: BABYLON.Vector3,
  70068. /** defines the current mouse button index */
  70069. buttonIndex?: number);
  70070. }
  70071. }
  70072. declare module BABYLON.GUI {
  70073. /**
  70074. * Class used as base class for controls
  70075. */
  70076. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  70077. /** Defines the control name */
  70078. name?: string | undefined;
  70079. /** @hidden */
  70080. _host: GUI3DManager;
  70081. private _node;
  70082. private _downCount;
  70083. private _enterCount;
  70084. private _downPointerIds;
  70085. private _isVisible;
  70086. /** Gets or sets the control position in world space */
  70087. position: BABYLON.Vector3;
  70088. /** Gets or sets the control scaling in world space */
  70089. scaling: BABYLON.Vector3;
  70090. /** Callback used to start pointer enter animation */
  70091. pointerEnterAnimation: () => void;
  70092. /** Callback used to start pointer out animation */
  70093. pointerOutAnimation: () => void;
  70094. /** Callback used to start pointer down animation */
  70095. pointerDownAnimation: () => void;
  70096. /** Callback used to start pointer up animation */
  70097. pointerUpAnimation: () => void;
  70098. /**
  70099. * An event triggered when the pointer move over the control
  70100. */
  70101. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  70102. /**
  70103. * An event triggered when the pointer move out of the control
  70104. */
  70105. onPointerOutObservable: BABYLON.Observable<Control3D>;
  70106. /**
  70107. * An event triggered when the pointer taps the control
  70108. */
  70109. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  70110. /**
  70111. * An event triggered when pointer is up
  70112. */
  70113. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  70114. /**
  70115. * An event triggered when a control is clicked on (with a mouse)
  70116. */
  70117. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  70118. /**
  70119. * An event triggered when pointer enters the control
  70120. */
  70121. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  70122. /**
  70123. * Gets or sets the parent container
  70124. */
  70125. parent: BABYLON.Nullable<Container3D>;
  70126. private _behaviors;
  70127. /**
  70128. * Gets the list of attached behaviors
  70129. * @see http://doc.babylonjs.com/features/behaviour
  70130. */
  70131. readonly behaviors: BABYLON.Behavior<Control3D>[];
  70132. /**
  70133. * Attach a behavior to the control
  70134. * @see http://doc.babylonjs.com/features/behaviour
  70135. * @param behavior defines the behavior to attach
  70136. * @returns the current control
  70137. */
  70138. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  70139. /**
  70140. * Remove an attached behavior
  70141. * @see http://doc.babylonjs.com/features/behaviour
  70142. * @param behavior defines the behavior to attach
  70143. * @returns the current control
  70144. */
  70145. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  70146. /**
  70147. * Gets an attached behavior by name
  70148. * @param name defines the name of the behavior to look for
  70149. * @see http://doc.babylonjs.com/features/behaviour
  70150. * @returns null if behavior was not found else the requested behavior
  70151. */
  70152. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  70153. /** Gets or sets a boolean indicating if the control is visible */
  70154. isVisible: boolean;
  70155. /**
  70156. * Creates a new control
  70157. * @param name defines the control name
  70158. */
  70159. constructor(
  70160. /** Defines the control name */
  70161. name?: string | undefined);
  70162. /**
  70163. * Gets a string representing the class name
  70164. */
  70165. readonly typeName: string;
  70166. /**
  70167. * Get the current class name of the control.
  70168. * @returns current class name
  70169. */
  70170. getClassName(): string;
  70171. protected _getTypeName(): string;
  70172. /**
  70173. * Gets the transform node used by this control
  70174. */
  70175. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  70176. /**
  70177. * Gets the mesh used to render this control
  70178. */
  70179. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70180. /**
  70181. * Link the control as child of the given node
  70182. * @param node defines the node to link to. Use null to unlink the control
  70183. * @returns the current control
  70184. */
  70185. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  70186. /** @hidden **/
  70187. _prepareNode(scene: BABYLON.Scene): void;
  70188. /**
  70189. * Node creation.
  70190. * Can be overriden by children
  70191. * @param scene defines the scene where the node must be attached
  70192. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  70193. */
  70194. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  70195. /**
  70196. * Affect a material to the given mesh
  70197. * @param mesh defines the mesh which will represent the control
  70198. */
  70199. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  70200. /** @hidden */
  70201. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  70202. /** @hidden */
  70203. _onPointerEnter(target: Control3D): boolean;
  70204. /** @hidden */
  70205. _onPointerOut(target: Control3D): void;
  70206. /** @hidden */
  70207. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  70208. /** @hidden */
  70209. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70210. /** @hidden */
  70211. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  70212. /** @hidden */
  70213. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  70214. /** @hidden */
  70215. _disposeNode(): void;
  70216. /**
  70217. * Releases all associated resources
  70218. */
  70219. dispose(): void;
  70220. }
  70221. }
  70222. declare module BABYLON.GUI {
  70223. /**
  70224. * Class used as a root to all buttons
  70225. */
  70226. export class AbstractButton3D extends Control3D {
  70227. /**
  70228. * Creates a new button
  70229. * @param name defines the control name
  70230. */
  70231. constructor(name?: string);
  70232. protected _getTypeName(): string;
  70233. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70234. }
  70235. }
  70236. declare module BABYLON.GUI {
  70237. /**
  70238. * Class used to create a button in 3D
  70239. */
  70240. export class Button3D extends AbstractButton3D {
  70241. /** @hidden */
  70242. protected _currentMaterial: BABYLON.Material;
  70243. private _facadeTexture;
  70244. private _content;
  70245. private _contentResolution;
  70246. private _contentScaleRatio;
  70247. /**
  70248. * Gets or sets the texture resolution used to render content (512 by default)
  70249. */
  70250. contentResolution: BABYLON.int;
  70251. /**
  70252. * Gets or sets the texture scale ratio used to render content (2 by default)
  70253. */
  70254. contentScaleRatio: number;
  70255. protected _disposeFacadeTexture(): void;
  70256. protected _resetContent(): void;
  70257. /**
  70258. * Creates a new button
  70259. * @param name defines the control name
  70260. */
  70261. constructor(name?: string);
  70262. /**
  70263. * Gets or sets the GUI 2D content used to display the button's facade
  70264. */
  70265. content: Control;
  70266. /**
  70267. * Apply the facade texture (created from the content property).
  70268. * This function can be overloaded by child classes
  70269. * @param facadeTexture defines the AdvancedDynamicTexture to use
  70270. */
  70271. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  70272. protected _getTypeName(): string;
  70273. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70274. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  70275. /**
  70276. * Releases all associated resources
  70277. */
  70278. dispose(): void;
  70279. }
  70280. }
  70281. declare module BABYLON.GUI {
  70282. /**
  70283. * Abstract class used to create a container panel deployed on the surface of a volume
  70284. */
  70285. export abstract class VolumeBasedPanel extends Container3D {
  70286. private _columns;
  70287. private _rows;
  70288. private _rowThenColum;
  70289. private _orientation;
  70290. protected _cellWidth: number;
  70291. protected _cellHeight: number;
  70292. /**
  70293. * Gets or sets the distance between elements
  70294. */
  70295. margin: number;
  70296. /**
  70297. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  70298. * | Value | Type | Description |
  70299. * | ----- | ----------------------------------- | ----------- |
  70300. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  70301. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  70302. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  70303. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  70304. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  70305. */
  70306. orientation: number;
  70307. /**
  70308. * Gets or sets the number of columns requested (10 by default).
  70309. * The panel will automatically compute the number of rows based on number of child controls.
  70310. */
  70311. columns: BABYLON.int;
  70312. /**
  70313. * Gets or sets a the number of rows requested.
  70314. * The panel will automatically compute the number of columns based on number of child controls.
  70315. */
  70316. rows: BABYLON.int;
  70317. /**
  70318. * Creates new VolumeBasedPanel
  70319. */
  70320. constructor();
  70321. protected _arrangeChildren(): void;
  70322. /** Child classes must implement this function to provide correct control positioning */
  70323. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70324. /** Child classes can implement this function to provide additional processing */
  70325. protected _finalProcessing(): void;
  70326. }
  70327. }
  70328. declare module BABYLON.GUI {
  70329. /**
  70330. * Class used to create a container panel deployed on the surface of a cylinder
  70331. */
  70332. export class CylinderPanel extends VolumeBasedPanel {
  70333. private _radius;
  70334. /**
  70335. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  70336. */
  70337. radius: BABYLON.float;
  70338. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70339. private _cylindricalMapping;
  70340. }
  70341. }
  70342. declare module BABYLON.GUI {
  70343. /** @hidden */
  70344. export var fluentVertexShader: {
  70345. name: string;
  70346. shader: string;
  70347. };
  70348. }
  70349. declare module BABYLON.GUI {
  70350. /** @hidden */
  70351. export var fluentPixelShader: {
  70352. name: string;
  70353. shader: string;
  70354. };
  70355. }
  70356. declare module BABYLON.GUI {
  70357. /** @hidden */
  70358. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  70359. INNERGLOW: boolean;
  70360. BORDER: boolean;
  70361. HOVERLIGHT: boolean;
  70362. TEXTURE: boolean;
  70363. constructor();
  70364. }
  70365. /**
  70366. * Class used to render controls with fluent desgin
  70367. */
  70368. export class FluentMaterial extends BABYLON.PushMaterial {
  70369. /**
  70370. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  70371. */
  70372. innerGlowColorIntensity: number;
  70373. /**
  70374. * Gets or sets the inner glow color (white by default)
  70375. */
  70376. innerGlowColor: BABYLON.Color3;
  70377. /**
  70378. * Gets or sets alpha value (default is 1.0)
  70379. */
  70380. alpha: number;
  70381. /**
  70382. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  70383. */
  70384. albedoColor: BABYLON.Color3;
  70385. /**
  70386. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  70387. */
  70388. renderBorders: boolean;
  70389. /**
  70390. * Gets or sets border width (default is 0.5)
  70391. */
  70392. borderWidth: number;
  70393. /**
  70394. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  70395. */
  70396. edgeSmoothingValue: number;
  70397. /**
  70398. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  70399. */
  70400. borderMinValue: number;
  70401. /**
  70402. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  70403. */
  70404. renderHoverLight: boolean;
  70405. /**
  70406. * Gets or sets the radius used to render the hover light (default is 1.0)
  70407. */
  70408. hoverRadius: number;
  70409. /**
  70410. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  70411. */
  70412. hoverColor: BABYLON.Color4;
  70413. /**
  70414. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  70415. */
  70416. hoverPosition: BABYLON.Vector3;
  70417. private _albedoTexture;
  70418. /** Gets or sets the texture to use for albedo color */
  70419. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70420. /**
  70421. * Creates a new Fluent material
  70422. * @param name defines the name of the material
  70423. * @param scene defines the hosting scene
  70424. */
  70425. constructor(name: string, scene: BABYLON.Scene);
  70426. needAlphaBlending(): boolean;
  70427. needAlphaTesting(): boolean;
  70428. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70429. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70430. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70431. getActiveTextures(): BABYLON.BaseTexture[];
  70432. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70433. dispose(forceDisposeEffect?: boolean): void;
  70434. clone(name: string): FluentMaterial;
  70435. serialize(): any;
  70436. getClassName(): string;
  70437. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  70438. }
  70439. }
  70440. declare module BABYLON.GUI {
  70441. /**
  70442. * Class used to create a holographic button in 3D
  70443. */
  70444. export class HolographicButton extends Button3D {
  70445. private _backPlate;
  70446. private _textPlate;
  70447. private _frontPlate;
  70448. private _text;
  70449. private _imageUrl;
  70450. private _shareMaterials;
  70451. private _frontMaterial;
  70452. private _backMaterial;
  70453. private _plateMaterial;
  70454. private _pickedPointObserver;
  70455. private _tooltipFade;
  70456. private _tooltipTextBlock;
  70457. private _tooltipTexture;
  70458. private _tooltipMesh;
  70459. private _tooltipHoverObserver;
  70460. private _tooltipOutObserver;
  70461. private _disposeTooltip;
  70462. /**
  70463. * Rendering ground id of all the mesh in the button
  70464. */
  70465. renderingGroupId: number;
  70466. /**
  70467. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  70468. */
  70469. tooltipText: BABYLON.Nullable<string>;
  70470. /**
  70471. * Gets or sets text for the button
  70472. */
  70473. text: string;
  70474. /**
  70475. * Gets or sets the image url for the button
  70476. */
  70477. imageUrl: string;
  70478. /**
  70479. * Gets the back material used by this button
  70480. */
  70481. readonly backMaterial: FluentMaterial;
  70482. /**
  70483. * Gets the front material used by this button
  70484. */
  70485. readonly frontMaterial: FluentMaterial;
  70486. /**
  70487. * Gets the plate material used by this button
  70488. */
  70489. readonly plateMaterial: BABYLON.StandardMaterial;
  70490. /**
  70491. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  70492. */
  70493. readonly shareMaterials: boolean;
  70494. /**
  70495. * Creates a new button
  70496. * @param name defines the control name
  70497. */
  70498. constructor(name?: string, shareMaterials?: boolean);
  70499. protected _getTypeName(): string;
  70500. private _rebuildContent;
  70501. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70502. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  70503. private _createBackMaterial;
  70504. private _createFrontMaterial;
  70505. private _createPlateMaterial;
  70506. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  70507. /**
  70508. * Releases all associated resources
  70509. */
  70510. dispose(): void;
  70511. }
  70512. }
  70513. declare module BABYLON.GUI {
  70514. /**
  70515. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  70516. */
  70517. export class MeshButton3D extends Button3D {
  70518. /** @hidden */
  70519. protected _currentMesh: BABYLON.Mesh;
  70520. /**
  70521. * Creates a new 3D button based on a mesh
  70522. * @param mesh mesh to become a 3D button
  70523. * @param name defines the control name
  70524. */
  70525. constructor(mesh: BABYLON.Mesh, name?: string);
  70526. protected _getTypeName(): string;
  70527. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70528. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  70529. }
  70530. }
  70531. declare module BABYLON.GUI {
  70532. /**
  70533. * Class used to create a container panel deployed on the surface of a plane
  70534. */
  70535. export class PlanePanel extends VolumeBasedPanel {
  70536. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70537. }
  70538. }
  70539. declare module BABYLON.GUI {
  70540. /**
  70541. * Class used to create a container panel where items get randomized planar mapping
  70542. */
  70543. export class ScatterPanel extends VolumeBasedPanel {
  70544. private _iteration;
  70545. /**
  70546. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  70547. */
  70548. iteration: BABYLON.float;
  70549. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70550. private _scatterMapping;
  70551. protected _finalProcessing(): void;
  70552. }
  70553. }
  70554. declare module BABYLON.GUI {
  70555. /**
  70556. * Class used to create a container panel deployed on the surface of a sphere
  70557. */
  70558. export class SpherePanel extends VolumeBasedPanel {
  70559. private _radius;
  70560. /**
  70561. * Gets or sets the radius of the sphere where to project controls (5 by default)
  70562. */
  70563. radius: BABYLON.float;
  70564. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70565. private _sphericalMapping;
  70566. }
  70567. }
  70568. declare module BABYLON.GUI {
  70569. /**
  70570. * Class used to create a stack panel in 3D on XY plane
  70571. */
  70572. export class StackPanel3D extends Container3D {
  70573. private _isVertical;
  70574. /**
  70575. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  70576. */
  70577. isVertical: boolean;
  70578. /**
  70579. * Gets or sets the distance between elements
  70580. */
  70581. margin: number;
  70582. /**
  70583. * Creates new StackPanel
  70584. * @param isVertical
  70585. */
  70586. constructor(isVertical?: boolean);
  70587. protected _arrangeChildren(): void;
  70588. }
  70589. }
  70590. declare module BABYLON {
  70591. /**
  70592. * Mode that determines the coordinate system to use.
  70593. */
  70594. export enum GLTFLoaderCoordinateSystemMode {
  70595. /**
  70596. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  70597. */
  70598. AUTO = 0,
  70599. /**
  70600. * Sets the useRightHandedSystem flag on the scene.
  70601. */
  70602. FORCE_RIGHT_HANDED = 1
  70603. }
  70604. /**
  70605. * Mode that determines what animations will start.
  70606. */
  70607. export enum GLTFLoaderAnimationStartMode {
  70608. /**
  70609. * No animation will start.
  70610. */
  70611. NONE = 0,
  70612. /**
  70613. * The first animation will start.
  70614. */
  70615. FIRST = 1,
  70616. /**
  70617. * All animations will start.
  70618. */
  70619. ALL = 2
  70620. }
  70621. /**
  70622. * Interface that contains the data for the glTF asset.
  70623. */
  70624. export interface IGLTFLoaderData {
  70625. /**
  70626. * The object that represents the glTF JSON.
  70627. */
  70628. json: Object;
  70629. /**
  70630. * The BIN chunk of a binary glTF.
  70631. */
  70632. bin: Nullable<IDataBuffer>;
  70633. }
  70634. /**
  70635. * Interface for extending the loader.
  70636. */
  70637. export interface IGLTFLoaderExtension {
  70638. /**
  70639. * The name of this extension.
  70640. */
  70641. readonly name: string;
  70642. /**
  70643. * Defines whether this extension is enabled.
  70644. */
  70645. enabled: boolean;
  70646. /**
  70647. * Defines the order of this extension.
  70648. * The loader sorts the extensions using these values when loading.
  70649. */
  70650. order?: number;
  70651. }
  70652. /**
  70653. * Loader state.
  70654. */
  70655. export enum GLTFLoaderState {
  70656. /**
  70657. * The asset is loading.
  70658. */
  70659. LOADING = 0,
  70660. /**
  70661. * The asset is ready for rendering.
  70662. */
  70663. READY = 1,
  70664. /**
  70665. * The asset is completely loaded.
  70666. */
  70667. COMPLETE = 2
  70668. }
  70669. /** @hidden */
  70670. export interface IGLTFLoader extends IDisposable {
  70671. readonly state: Nullable<GLTFLoaderState>;
  70672. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  70673. meshes: AbstractMesh[];
  70674. particleSystems: IParticleSystem[];
  70675. skeletons: Skeleton[];
  70676. animationGroups: AnimationGroup[];
  70677. }>;
  70678. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  70679. }
  70680. /**
  70681. * File loader for loading glTF files into a scene.
  70682. */
  70683. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70684. /** @hidden */
  70685. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  70686. /** @hidden */
  70687. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  70688. /**
  70689. * Raised when the asset has been parsed
  70690. */
  70691. onParsedObservable: Observable<IGLTFLoaderData>;
  70692. private _onParsedObserver;
  70693. /**
  70694. * Raised when the asset has been parsed
  70695. */
  70696. onParsed: (loaderData: IGLTFLoaderData) => void;
  70697. /**
  70698. * 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.
  70699. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  70700. * Defaults to true.
  70701. * @hidden
  70702. */
  70703. static IncrementalLoading: boolean;
  70704. /**
  70705. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  70706. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  70707. * @hidden
  70708. */
  70709. static HomogeneousCoordinates: boolean;
  70710. /**
  70711. * The coordinate system mode. Defaults to AUTO.
  70712. */
  70713. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  70714. /**
  70715. * The animation start mode. Defaults to FIRST.
  70716. */
  70717. animationStartMode: GLTFLoaderAnimationStartMode;
  70718. /**
  70719. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  70720. */
  70721. compileMaterials: boolean;
  70722. /**
  70723. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  70724. */
  70725. useClipPlane: boolean;
  70726. /**
  70727. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  70728. */
  70729. compileShadowGenerators: boolean;
  70730. /**
  70731. * Defines if the Alpha blended materials are only applied as coverage.
  70732. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  70733. * If true, no extra effects are applied to transparent pixels.
  70734. */
  70735. transparencyAsCoverage: boolean;
  70736. /**
  70737. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  70738. * Enabling will disable offline support and glTF validator.
  70739. * Defaults to false.
  70740. */
  70741. useRangeRequests: boolean;
  70742. /**
  70743. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  70744. */
  70745. createInstances: boolean;
  70746. /**
  70747. * Function called before loading a url referenced by the asset.
  70748. */
  70749. preprocessUrlAsync: (url: string) => Promise<string>;
  70750. /**
  70751. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  70752. */
  70753. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  70754. private _onMeshLoadedObserver;
  70755. /**
  70756. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  70757. */
  70758. onMeshLoaded: (mesh: AbstractMesh) => void;
  70759. /**
  70760. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  70761. */
  70762. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  70763. private _onTextureLoadedObserver;
  70764. /**
  70765. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  70766. */
  70767. onTextureLoaded: (texture: BaseTexture) => void;
  70768. /**
  70769. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  70770. */
  70771. readonly onMaterialLoadedObservable: Observable<Material>;
  70772. private _onMaterialLoadedObserver;
  70773. /**
  70774. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  70775. */
  70776. onMaterialLoaded: (material: Material) => void;
  70777. /**
  70778. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  70779. */
  70780. readonly onCameraLoadedObservable: Observable<Camera>;
  70781. private _onCameraLoadedObserver;
  70782. /**
  70783. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  70784. */
  70785. onCameraLoaded: (camera: Camera) => void;
  70786. /**
  70787. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  70788. * For assets with LODs, raised when all of the LODs are complete.
  70789. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  70790. */
  70791. readonly onCompleteObservable: Observable<void>;
  70792. private _onCompleteObserver;
  70793. /**
  70794. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  70795. * For assets with LODs, raised when all of the LODs are complete.
  70796. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  70797. */
  70798. onComplete: () => void;
  70799. /**
  70800. * Observable raised when an error occurs.
  70801. */
  70802. readonly onErrorObservable: Observable<any>;
  70803. private _onErrorObserver;
  70804. /**
  70805. * Callback raised when an error occurs.
  70806. */
  70807. onError: (reason: any) => void;
  70808. /**
  70809. * Observable raised after the loader is disposed.
  70810. */
  70811. readonly onDisposeObservable: Observable<void>;
  70812. private _onDisposeObserver;
  70813. /**
  70814. * Callback raised after the loader is disposed.
  70815. */
  70816. onDispose: () => void;
  70817. /**
  70818. * Observable raised after a loader extension is created.
  70819. * Set additional options for a loader extension in this event.
  70820. */
  70821. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  70822. private _onExtensionLoadedObserver;
  70823. /**
  70824. * Callback raised after a loader extension is created.
  70825. */
  70826. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  70827. /**
  70828. * Defines if the loader logging is enabled.
  70829. */
  70830. loggingEnabled: boolean;
  70831. /**
  70832. * Defines if the loader should capture performance counters.
  70833. */
  70834. capturePerformanceCounters: boolean;
  70835. /**
  70836. * Defines if the loader should validate the asset.
  70837. */
  70838. validate: boolean;
  70839. /**
  70840. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  70841. */
  70842. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  70843. private _onValidatedObserver;
  70844. /**
  70845. * Callback raised after a loader extension is created.
  70846. */
  70847. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  70848. private _loader;
  70849. /**
  70850. * Name of the loader ("gltf")
  70851. */
  70852. name: string;
  70853. /** @hidden */
  70854. extensions: ISceneLoaderPluginExtensions;
  70855. /**
  70856. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  70857. */
  70858. dispose(): void;
  70859. /** @hidden */
  70860. _clear(): void;
  70861. /** @hidden */
  70862. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  70863. /** @hidden */
  70864. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  70865. /** @hidden */
  70866. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70867. meshes: AbstractMesh[];
  70868. particleSystems: IParticleSystem[];
  70869. skeletons: Skeleton[];
  70870. animationGroups: AnimationGroup[];
  70871. }>;
  70872. /** @hidden */
  70873. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70874. /** @hidden */
  70875. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70876. /** @hidden */
  70877. canDirectLoad(data: string): boolean;
  70878. /** @hidden */
  70879. directLoad(scene: Scene, data: string): any;
  70880. /**
  70881. * The callback that allows custom handling of the root url based on the response url.
  70882. * @param rootUrl the original root url
  70883. * @param responseURL the response url if available
  70884. * @returns the new root url
  70885. */
  70886. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  70887. /** @hidden */
  70888. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  70889. /**
  70890. * The loader state or null if the loader is not active.
  70891. */
  70892. readonly loaderState: Nullable<GLTFLoaderState>;
  70893. /**
  70894. * Returns a promise that resolves when the asset is completely loaded.
  70895. * @returns a promise that resolves when the asset is completely loaded.
  70896. */
  70897. whenCompleteAsync(): Promise<void>;
  70898. private _validateAsync;
  70899. private _getLoader;
  70900. private _parseJson;
  70901. private _unpackBinaryAsync;
  70902. private _unpackBinaryV1Async;
  70903. private _unpackBinaryV2Async;
  70904. private static _parseVersion;
  70905. private static _compareVersion;
  70906. private static readonly _logSpaces;
  70907. private _logIndentLevel;
  70908. private _loggingEnabled;
  70909. /** @hidden */
  70910. _log: (message: string) => void;
  70911. /** @hidden */
  70912. _logOpen(message: string): void;
  70913. /** @hidden */
  70914. _logClose(): void;
  70915. private _logEnabled;
  70916. private _logDisabled;
  70917. private _capturePerformanceCounters;
  70918. /** @hidden */
  70919. _startPerformanceCounter: (counterName: string) => void;
  70920. /** @hidden */
  70921. _endPerformanceCounter: (counterName: string) => void;
  70922. private _startPerformanceCounterEnabled;
  70923. private _startPerformanceCounterDisabled;
  70924. private _endPerformanceCounterEnabled;
  70925. private _endPerformanceCounterDisabled;
  70926. }
  70927. }
  70928. declare module BABYLON.GLTF1 {
  70929. /**
  70930. * Enums
  70931. * @hidden
  70932. */
  70933. export enum EComponentType {
  70934. BYTE = 5120,
  70935. UNSIGNED_BYTE = 5121,
  70936. SHORT = 5122,
  70937. UNSIGNED_SHORT = 5123,
  70938. FLOAT = 5126
  70939. }
  70940. /** @hidden */
  70941. export enum EShaderType {
  70942. FRAGMENT = 35632,
  70943. VERTEX = 35633
  70944. }
  70945. /** @hidden */
  70946. export enum EParameterType {
  70947. BYTE = 5120,
  70948. UNSIGNED_BYTE = 5121,
  70949. SHORT = 5122,
  70950. UNSIGNED_SHORT = 5123,
  70951. INT = 5124,
  70952. UNSIGNED_INT = 5125,
  70953. FLOAT = 5126,
  70954. FLOAT_VEC2 = 35664,
  70955. FLOAT_VEC3 = 35665,
  70956. FLOAT_VEC4 = 35666,
  70957. INT_VEC2 = 35667,
  70958. INT_VEC3 = 35668,
  70959. INT_VEC4 = 35669,
  70960. BOOL = 35670,
  70961. BOOL_VEC2 = 35671,
  70962. BOOL_VEC3 = 35672,
  70963. BOOL_VEC4 = 35673,
  70964. FLOAT_MAT2 = 35674,
  70965. FLOAT_MAT3 = 35675,
  70966. FLOAT_MAT4 = 35676,
  70967. SAMPLER_2D = 35678
  70968. }
  70969. /** @hidden */
  70970. export enum ETextureWrapMode {
  70971. CLAMP_TO_EDGE = 33071,
  70972. MIRRORED_REPEAT = 33648,
  70973. REPEAT = 10497
  70974. }
  70975. /** @hidden */
  70976. export enum ETextureFilterType {
  70977. NEAREST = 9728,
  70978. LINEAR = 9728,
  70979. NEAREST_MIPMAP_NEAREST = 9984,
  70980. LINEAR_MIPMAP_NEAREST = 9985,
  70981. NEAREST_MIPMAP_LINEAR = 9986,
  70982. LINEAR_MIPMAP_LINEAR = 9987
  70983. }
  70984. /** @hidden */
  70985. export enum ETextureFormat {
  70986. ALPHA = 6406,
  70987. RGB = 6407,
  70988. RGBA = 6408,
  70989. LUMINANCE = 6409,
  70990. LUMINANCE_ALPHA = 6410
  70991. }
  70992. /** @hidden */
  70993. export enum ECullingType {
  70994. FRONT = 1028,
  70995. BACK = 1029,
  70996. FRONT_AND_BACK = 1032
  70997. }
  70998. /** @hidden */
  70999. export enum EBlendingFunction {
  71000. ZERO = 0,
  71001. ONE = 1,
  71002. SRC_COLOR = 768,
  71003. ONE_MINUS_SRC_COLOR = 769,
  71004. DST_COLOR = 774,
  71005. ONE_MINUS_DST_COLOR = 775,
  71006. SRC_ALPHA = 770,
  71007. ONE_MINUS_SRC_ALPHA = 771,
  71008. DST_ALPHA = 772,
  71009. ONE_MINUS_DST_ALPHA = 773,
  71010. CONSTANT_COLOR = 32769,
  71011. ONE_MINUS_CONSTANT_COLOR = 32770,
  71012. CONSTANT_ALPHA = 32771,
  71013. ONE_MINUS_CONSTANT_ALPHA = 32772,
  71014. SRC_ALPHA_SATURATE = 776
  71015. }
  71016. /** @hidden */
  71017. export interface IGLTFProperty {
  71018. extensions?: {
  71019. [key: string]: any;
  71020. };
  71021. extras?: Object;
  71022. }
  71023. /** @hidden */
  71024. export interface IGLTFChildRootProperty extends IGLTFProperty {
  71025. name?: string;
  71026. }
  71027. /** @hidden */
  71028. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  71029. bufferView: string;
  71030. byteOffset: number;
  71031. byteStride: number;
  71032. count: number;
  71033. type: string;
  71034. componentType: EComponentType;
  71035. max?: number[];
  71036. min?: number[];
  71037. name?: string;
  71038. }
  71039. /** @hidden */
  71040. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  71041. buffer: string;
  71042. byteOffset: number;
  71043. byteLength: number;
  71044. byteStride: number;
  71045. target?: number;
  71046. }
  71047. /** @hidden */
  71048. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  71049. uri: string;
  71050. byteLength?: number;
  71051. type?: string;
  71052. }
  71053. /** @hidden */
  71054. export interface IGLTFShader extends IGLTFChildRootProperty {
  71055. uri: string;
  71056. type: EShaderType;
  71057. }
  71058. /** @hidden */
  71059. export interface IGLTFProgram extends IGLTFChildRootProperty {
  71060. attributes: string[];
  71061. fragmentShader: string;
  71062. vertexShader: string;
  71063. }
  71064. /** @hidden */
  71065. export interface IGLTFTechniqueParameter {
  71066. type: number;
  71067. count?: number;
  71068. semantic?: string;
  71069. node?: string;
  71070. value?: number | boolean | string | Array<any>;
  71071. source?: string;
  71072. babylonValue?: any;
  71073. }
  71074. /** @hidden */
  71075. export interface IGLTFTechniqueCommonProfile {
  71076. lightingModel: string;
  71077. texcoordBindings: Object;
  71078. parameters?: Array<any>;
  71079. }
  71080. /** @hidden */
  71081. export interface IGLTFTechniqueStatesFunctions {
  71082. blendColor?: number[];
  71083. blendEquationSeparate?: number[];
  71084. blendFuncSeparate?: number[];
  71085. colorMask: boolean[];
  71086. cullFace: number[];
  71087. }
  71088. /** @hidden */
  71089. export interface IGLTFTechniqueStates {
  71090. enable: number[];
  71091. functions: IGLTFTechniqueStatesFunctions;
  71092. }
  71093. /** @hidden */
  71094. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  71095. parameters: {
  71096. [key: string]: IGLTFTechniqueParameter;
  71097. };
  71098. program: string;
  71099. attributes: {
  71100. [key: string]: string;
  71101. };
  71102. uniforms: {
  71103. [key: string]: string;
  71104. };
  71105. states: IGLTFTechniqueStates;
  71106. }
  71107. /** @hidden */
  71108. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  71109. technique?: string;
  71110. values: string[];
  71111. }
  71112. /** @hidden */
  71113. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  71114. attributes: {
  71115. [key: string]: string;
  71116. };
  71117. indices: string;
  71118. material: string;
  71119. mode?: number;
  71120. }
  71121. /** @hidden */
  71122. export interface IGLTFMesh extends IGLTFChildRootProperty {
  71123. primitives: IGLTFMeshPrimitive[];
  71124. }
  71125. /** @hidden */
  71126. export interface IGLTFImage extends IGLTFChildRootProperty {
  71127. uri: string;
  71128. }
  71129. /** @hidden */
  71130. export interface IGLTFSampler extends IGLTFChildRootProperty {
  71131. magFilter?: number;
  71132. minFilter?: number;
  71133. wrapS?: number;
  71134. wrapT?: number;
  71135. }
  71136. /** @hidden */
  71137. export interface IGLTFTexture extends IGLTFChildRootProperty {
  71138. sampler: string;
  71139. source: string;
  71140. format?: ETextureFormat;
  71141. internalFormat?: ETextureFormat;
  71142. target?: number;
  71143. type?: number;
  71144. babylonTexture?: Texture;
  71145. }
  71146. /** @hidden */
  71147. export interface IGLTFAmbienLight {
  71148. color?: number[];
  71149. }
  71150. /** @hidden */
  71151. export interface IGLTFDirectionalLight {
  71152. color?: number[];
  71153. }
  71154. /** @hidden */
  71155. export interface IGLTFPointLight {
  71156. color?: number[];
  71157. constantAttenuation?: number;
  71158. linearAttenuation?: number;
  71159. quadraticAttenuation?: number;
  71160. }
  71161. /** @hidden */
  71162. export interface IGLTFSpotLight {
  71163. color?: number[];
  71164. constantAttenuation?: number;
  71165. fallOfAngle?: number;
  71166. fallOffExponent?: number;
  71167. linearAttenuation?: number;
  71168. quadraticAttenuation?: number;
  71169. }
  71170. /** @hidden */
  71171. export interface IGLTFLight extends IGLTFChildRootProperty {
  71172. type: string;
  71173. }
  71174. /** @hidden */
  71175. export interface IGLTFCameraOrthographic {
  71176. xmag: number;
  71177. ymag: number;
  71178. zfar: number;
  71179. znear: number;
  71180. }
  71181. /** @hidden */
  71182. export interface IGLTFCameraPerspective {
  71183. aspectRatio: number;
  71184. yfov: number;
  71185. zfar: number;
  71186. znear: number;
  71187. }
  71188. /** @hidden */
  71189. export interface IGLTFCamera extends IGLTFChildRootProperty {
  71190. type: string;
  71191. }
  71192. /** @hidden */
  71193. export interface IGLTFAnimationChannelTarget {
  71194. id: string;
  71195. path: string;
  71196. }
  71197. /** @hidden */
  71198. export interface IGLTFAnimationChannel {
  71199. sampler: string;
  71200. target: IGLTFAnimationChannelTarget;
  71201. }
  71202. /** @hidden */
  71203. export interface IGLTFAnimationSampler {
  71204. input: string;
  71205. output: string;
  71206. interpolation?: string;
  71207. }
  71208. /** @hidden */
  71209. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  71210. channels?: IGLTFAnimationChannel[];
  71211. parameters?: {
  71212. [key: string]: string;
  71213. };
  71214. samplers?: {
  71215. [key: string]: IGLTFAnimationSampler;
  71216. };
  71217. }
  71218. /** @hidden */
  71219. export interface IGLTFNodeInstanceSkin {
  71220. skeletons: string[];
  71221. skin: string;
  71222. meshes: string[];
  71223. }
  71224. /** @hidden */
  71225. export interface IGLTFSkins extends IGLTFChildRootProperty {
  71226. bindShapeMatrix: number[];
  71227. inverseBindMatrices: string;
  71228. jointNames: string[];
  71229. babylonSkeleton?: Skeleton;
  71230. }
  71231. /** @hidden */
  71232. export interface IGLTFNode extends IGLTFChildRootProperty {
  71233. camera?: string;
  71234. children: string[];
  71235. skin?: string;
  71236. jointName?: string;
  71237. light?: string;
  71238. matrix: number[];
  71239. mesh?: string;
  71240. meshes?: string[];
  71241. rotation?: number[];
  71242. scale?: number[];
  71243. translation?: number[];
  71244. babylonNode?: Node;
  71245. }
  71246. /** @hidden */
  71247. export interface IGLTFScene extends IGLTFChildRootProperty {
  71248. nodes: string[];
  71249. }
  71250. /** @hidden */
  71251. export interface IGLTFRuntime {
  71252. extensions: {
  71253. [key: string]: any;
  71254. };
  71255. accessors: {
  71256. [key: string]: IGLTFAccessor;
  71257. };
  71258. buffers: {
  71259. [key: string]: IGLTFBuffer;
  71260. };
  71261. bufferViews: {
  71262. [key: string]: IGLTFBufferView;
  71263. };
  71264. meshes: {
  71265. [key: string]: IGLTFMesh;
  71266. };
  71267. lights: {
  71268. [key: string]: IGLTFLight;
  71269. };
  71270. cameras: {
  71271. [key: string]: IGLTFCamera;
  71272. };
  71273. nodes: {
  71274. [key: string]: IGLTFNode;
  71275. };
  71276. images: {
  71277. [key: string]: IGLTFImage;
  71278. };
  71279. textures: {
  71280. [key: string]: IGLTFTexture;
  71281. };
  71282. shaders: {
  71283. [key: string]: IGLTFShader;
  71284. };
  71285. programs: {
  71286. [key: string]: IGLTFProgram;
  71287. };
  71288. samplers: {
  71289. [key: string]: IGLTFSampler;
  71290. };
  71291. techniques: {
  71292. [key: string]: IGLTFTechnique;
  71293. };
  71294. materials: {
  71295. [key: string]: IGLTFMaterial;
  71296. };
  71297. animations: {
  71298. [key: string]: IGLTFAnimation;
  71299. };
  71300. skins: {
  71301. [key: string]: IGLTFSkins;
  71302. };
  71303. currentScene?: Object;
  71304. scenes: {
  71305. [key: string]: IGLTFScene;
  71306. };
  71307. extensionsUsed: string[];
  71308. extensionsRequired?: string[];
  71309. buffersCount: number;
  71310. shaderscount: number;
  71311. scene: Scene;
  71312. rootUrl: string;
  71313. loadedBufferCount: number;
  71314. loadedBufferViews: {
  71315. [name: string]: ArrayBufferView;
  71316. };
  71317. loadedShaderCount: number;
  71318. importOnlyMeshes: boolean;
  71319. importMeshesNames?: string[];
  71320. dummyNodes: Node[];
  71321. }
  71322. /** @hidden */
  71323. export interface INodeToRoot {
  71324. bone: Bone;
  71325. node: IGLTFNode;
  71326. id: string;
  71327. }
  71328. /** @hidden */
  71329. export interface IJointNode {
  71330. node: IGLTFNode;
  71331. id: string;
  71332. }
  71333. }
  71334. declare module BABYLON.GLTF1 {
  71335. /**
  71336. * Utils functions for GLTF
  71337. * @hidden
  71338. */
  71339. export class GLTFUtils {
  71340. /**
  71341. * Sets the given "parameter" matrix
  71342. * @param scene: the Scene object
  71343. * @param source: the source node where to pick the matrix
  71344. * @param parameter: the GLTF technique parameter
  71345. * @param uniformName: the name of the shader's uniform
  71346. * @param shaderMaterial: the shader material
  71347. */
  71348. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  71349. /**
  71350. * Sets the given "parameter" matrix
  71351. * @param shaderMaterial: the shader material
  71352. * @param uniform: the name of the shader's uniform
  71353. * @param value: the value of the uniform
  71354. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  71355. */
  71356. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  71357. /**
  71358. * Returns the wrap mode of the texture
  71359. * @param mode: the mode value
  71360. */
  71361. static GetWrapMode(mode: number): number;
  71362. /**
  71363. * Returns the byte stride giving an accessor
  71364. * @param accessor: the GLTF accessor objet
  71365. */
  71366. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  71367. /**
  71368. * Returns the texture filter mode giving a mode value
  71369. * @param mode: the filter mode value
  71370. */
  71371. static GetTextureFilterMode(mode: number): ETextureFilterType;
  71372. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  71373. /**
  71374. * Returns a buffer from its accessor
  71375. * @param gltfRuntime: the GLTF runtime
  71376. * @param accessor: the GLTF accessor
  71377. */
  71378. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  71379. /**
  71380. * Decodes a buffer view into a string
  71381. * @param view: the buffer view
  71382. */
  71383. static DecodeBufferToText(view: ArrayBufferView): string;
  71384. /**
  71385. * Returns the default material of gltf. Related to
  71386. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  71387. * @param scene: the Babylon.js scene
  71388. */
  71389. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  71390. private static _DefaultMaterial;
  71391. }
  71392. }
  71393. declare module BABYLON.GLTF1 {
  71394. /**
  71395. * Implementation of the base glTF spec
  71396. * @hidden
  71397. */
  71398. export class GLTFLoaderBase {
  71399. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  71400. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  71401. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  71402. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  71403. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  71404. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  71405. }
  71406. /**
  71407. * glTF V1 Loader
  71408. * @hidden
  71409. */
  71410. export class GLTFLoader implements IGLTFLoader {
  71411. static Extensions: {
  71412. [name: string]: GLTFLoaderExtension;
  71413. };
  71414. static RegisterExtension(extension: GLTFLoaderExtension): void;
  71415. state: Nullable<GLTFLoaderState>;
  71416. dispose(): void;
  71417. private _importMeshAsync;
  71418. /**
  71419. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  71420. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  71421. * @param scene the scene the meshes should be added to
  71422. * @param data gltf data containing information of the meshes in a loaded file
  71423. * @param rootUrl root url to load from
  71424. * @param onProgress event that fires when loading progress has occured
  71425. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  71426. */
  71427. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  71428. meshes: AbstractMesh[];
  71429. particleSystems: IParticleSystem[];
  71430. skeletons: Skeleton[];
  71431. animationGroups: AnimationGroup[];
  71432. }>;
  71433. private _loadAsync;
  71434. /**
  71435. * Imports all objects from a loaded gltf file and adds them to the scene
  71436. * @param scene the scene the objects should be added to
  71437. * @param data gltf data containing information of the meshes in a loaded file
  71438. * @param rootUrl root url to load from
  71439. * @param onProgress event that fires when loading progress has occured
  71440. * @returns a promise which completes when objects have been loaded to the scene
  71441. */
  71442. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  71443. private _loadShadersAsync;
  71444. private _loadBuffersAsync;
  71445. private _createNodes;
  71446. }
  71447. /** @hidden */
  71448. export abstract class GLTFLoaderExtension {
  71449. private _name;
  71450. constructor(name: string);
  71451. readonly name: string;
  71452. /**
  71453. * Defines an override for loading the runtime
  71454. * Return true to stop further extensions from loading the runtime
  71455. */
  71456. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  71457. /**
  71458. * Defines an onverride for creating gltf runtime
  71459. * Return true to stop further extensions from creating the runtime
  71460. */
  71461. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  71462. /**
  71463. * Defines an override for loading buffers
  71464. * Return true to stop further extensions from loading this buffer
  71465. */
  71466. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  71467. /**
  71468. * Defines an override for loading texture buffers
  71469. * Return true to stop further extensions from loading this texture data
  71470. */
  71471. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  71472. /**
  71473. * Defines an override for creating textures
  71474. * Return true to stop further extensions from loading this texture
  71475. */
  71476. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  71477. /**
  71478. * Defines an override for loading shader strings
  71479. * Return true to stop further extensions from loading this shader data
  71480. */
  71481. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  71482. /**
  71483. * Defines an override for loading materials
  71484. * Return true to stop further extensions from loading this material
  71485. */
  71486. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  71487. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  71488. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  71489. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  71490. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  71491. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  71492. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  71493. private static LoadTextureBufferAsync;
  71494. private static CreateTextureAsync;
  71495. private static ApplyExtensions;
  71496. }
  71497. }
  71498. declare module BABYLON.GLTF1 {
  71499. /** @hidden */
  71500. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  71501. private _bin;
  71502. constructor();
  71503. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  71504. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  71505. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  71506. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  71507. }
  71508. }
  71509. declare module BABYLON.GLTF1 {
  71510. /** @hidden */
  71511. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  71512. constructor();
  71513. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  71514. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  71515. private _loadTexture;
  71516. }
  71517. }
  71518. declare module BABYLON.GLTF2.Loader {
  71519. /**
  71520. * Loader interface with an index field.
  71521. */
  71522. export interface IArrayItem {
  71523. /**
  71524. * The index of this item in the array.
  71525. */
  71526. index: number;
  71527. }
  71528. /**
  71529. * Loader interface with additional members.
  71530. */
  71531. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  71532. /** @hidden */
  71533. _data?: Promise<ArrayBufferView>;
  71534. /** @hidden */
  71535. _babylonVertexBuffer?: Promise<VertexBuffer>;
  71536. }
  71537. /**
  71538. * Loader interface with additional members.
  71539. */
  71540. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  71541. }
  71542. /** @hidden */
  71543. export interface _IAnimationSamplerData {
  71544. input: Float32Array;
  71545. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  71546. output: Float32Array;
  71547. }
  71548. /**
  71549. * Loader interface with additional members.
  71550. */
  71551. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  71552. /** @hidden */
  71553. _data?: Promise<_IAnimationSamplerData>;
  71554. }
  71555. /**
  71556. * Loader interface with additional members.
  71557. */
  71558. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  71559. channels: IAnimationChannel[];
  71560. samplers: IAnimationSampler[];
  71561. /** @hidden */
  71562. _babylonAnimationGroup?: AnimationGroup;
  71563. }
  71564. /**
  71565. * Loader interface with additional members.
  71566. */
  71567. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  71568. /** @hidden */
  71569. _data?: Promise<ArrayBufferView>;
  71570. }
  71571. /**
  71572. * Loader interface with additional members.
  71573. */
  71574. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  71575. /** @hidden */
  71576. _data?: Promise<ArrayBufferView>;
  71577. /** @hidden */
  71578. _babylonBuffer?: Promise<Buffer>;
  71579. }
  71580. /**
  71581. * Loader interface with additional members.
  71582. */
  71583. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  71584. }
  71585. /**
  71586. * Loader interface with additional members.
  71587. */
  71588. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  71589. /** @hidden */
  71590. _data?: Promise<ArrayBufferView>;
  71591. }
  71592. /**
  71593. * Loader interface with additional members.
  71594. */
  71595. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  71596. }
  71597. /**
  71598. * Loader interface with additional members.
  71599. */
  71600. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  71601. }
  71602. /**
  71603. * Loader interface with additional members.
  71604. */
  71605. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  71606. baseColorTexture?: ITextureInfo;
  71607. metallicRoughnessTexture?: ITextureInfo;
  71608. }
  71609. /**
  71610. * Loader interface with additional members.
  71611. */
  71612. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  71613. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71614. normalTexture?: IMaterialNormalTextureInfo;
  71615. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71616. emissiveTexture?: ITextureInfo;
  71617. /** @hidden */
  71618. _data?: {
  71619. [babylonDrawMode: number]: {
  71620. babylonMaterial: Material;
  71621. babylonMeshes: AbstractMesh[];
  71622. promise: Promise<void>;
  71623. };
  71624. };
  71625. }
  71626. /**
  71627. * Loader interface with additional members.
  71628. */
  71629. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  71630. primitives: IMeshPrimitive[];
  71631. }
  71632. /**
  71633. * Loader interface with additional members.
  71634. */
  71635. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  71636. /** @hidden */
  71637. _instanceData?: {
  71638. babylonSourceMesh: Mesh;
  71639. promise: Promise<any>;
  71640. };
  71641. }
  71642. /**
  71643. * Loader interface with additional members.
  71644. */
  71645. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  71646. /**
  71647. * The parent glTF node.
  71648. */
  71649. parent?: INode;
  71650. /** @hidden */
  71651. _babylonTransformNode?: TransformNode;
  71652. /** @hidden */
  71653. _primitiveBabylonMeshes?: AbstractMesh[];
  71654. /** @hidden */
  71655. _babylonBones?: Bone[];
  71656. /** @hidden */
  71657. _numMorphTargets?: number;
  71658. }
  71659. /** @hidden */
  71660. export interface _ISamplerData {
  71661. noMipMaps: boolean;
  71662. samplingMode: number;
  71663. wrapU: number;
  71664. wrapV: number;
  71665. }
  71666. /**
  71667. * Loader interface with additional members.
  71668. */
  71669. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  71670. /** @hidden */
  71671. _data?: _ISamplerData;
  71672. }
  71673. /**
  71674. * Loader interface with additional members.
  71675. */
  71676. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  71677. }
  71678. /**
  71679. * Loader interface with additional members.
  71680. */
  71681. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  71682. /** @hidden */
  71683. _data?: {
  71684. babylonSkeleton: Skeleton;
  71685. promise: Promise<void>;
  71686. };
  71687. }
  71688. /**
  71689. * Loader interface with additional members.
  71690. */
  71691. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  71692. }
  71693. /**
  71694. * Loader interface with additional members.
  71695. */
  71696. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  71697. }
  71698. /**
  71699. * Loader interface with additional members.
  71700. */
  71701. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  71702. accessors?: IAccessor[];
  71703. animations?: IAnimation[];
  71704. buffers?: IBuffer[];
  71705. bufferViews?: IBufferView[];
  71706. cameras?: ICamera[];
  71707. images?: IImage[];
  71708. materials?: IMaterial[];
  71709. meshes?: IMesh[];
  71710. nodes?: INode[];
  71711. samplers?: ISampler[];
  71712. scenes?: IScene[];
  71713. skins?: ISkin[];
  71714. textures?: ITexture[];
  71715. }
  71716. }
  71717. declare module BABYLON.GLTF2 {
  71718. /**
  71719. * Interface for a glTF loader extension.
  71720. */
  71721. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  71722. /**
  71723. * Called after the loader state changes to LOADING.
  71724. */
  71725. onLoading?(): void;
  71726. /**
  71727. * Called after the loader state changes to READY.
  71728. */
  71729. onReady?(): void;
  71730. /**
  71731. * Define this method to modify the default behavior when loading scenes.
  71732. * @param context The context when loading the asset
  71733. * @param scene The glTF scene property
  71734. * @returns A promise that resolves when the load is complete or null if not handled
  71735. */
  71736. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  71737. /**
  71738. * Define this method to modify the default behavior when loading nodes.
  71739. * @param context The context when loading the asset
  71740. * @param node The glTF node property
  71741. * @param assign A function called synchronously after parsing the glTF properties
  71742. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  71743. */
  71744. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71745. /**
  71746. * Define this method to modify the default behavior when loading cameras.
  71747. * @param context The context when loading the asset
  71748. * @param camera The glTF camera property
  71749. * @param assign A function called synchronously after parsing the glTF properties
  71750. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  71751. */
  71752. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  71753. /**
  71754. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  71755. * @param context The context when loading the asset
  71756. * @param primitive The glTF mesh primitive property
  71757. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  71758. */
  71759. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  71760. /**
  71761. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  71762. * @param context The context when loading the asset
  71763. * @param name The mesh name when loading the asset
  71764. * @param node The glTF node when loading the asset
  71765. * @param mesh The glTF mesh when loading the asset
  71766. * @param primitive The glTF mesh primitive property
  71767. * @param assign A function called synchronously after parsing the glTF properties
  71768. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  71769. */
  71770. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  71771. /**
  71772. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  71773. * @param context The context when loading the asset
  71774. * @param material The glTF material property
  71775. * @param assign A function called synchronously after parsing the glTF properties
  71776. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  71777. */
  71778. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  71779. /**
  71780. * Define this method to modify the default behavior when creating materials.
  71781. * @param context The context when loading the asset
  71782. * @param material The glTF material property
  71783. * @param babylonDrawMode The draw mode for the Babylon material
  71784. * @returns The Babylon material or null if not handled
  71785. */
  71786. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  71787. /**
  71788. * Define this method to modify the default behavior when loading material properties.
  71789. * @param context The context when loading the asset
  71790. * @param material The glTF material property
  71791. * @param babylonMaterial The Babylon material
  71792. * @returns A promise that resolves when the load is complete or null if not handled
  71793. */
  71794. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71795. /**
  71796. * Define this method to modify the default behavior when loading texture infos.
  71797. * @param context The context when loading the asset
  71798. * @param textureInfo The glTF texture info property
  71799. * @param assign A function called synchronously after parsing the glTF properties
  71800. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  71801. */
  71802. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  71803. /**
  71804. * Define this method to modify the default behavior when loading animations.
  71805. * @param context The context when loading the asset
  71806. * @param animation The glTF animation property
  71807. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  71808. */
  71809. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  71810. /**
  71811. * @hidden Define this method to modify the default behavior when loading skins.
  71812. * @param context The context when loading the asset
  71813. * @param node The glTF node property
  71814. * @param skin The glTF skin property
  71815. * @returns A promise that resolves when the load is complete or null if not handled
  71816. */
  71817. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  71818. /**
  71819. * @hidden Define this method to modify the default behavior when loading uris.
  71820. * @param context The context when loading the asset
  71821. * @param property The glTF property associated with the uri
  71822. * @param uri The uri to load
  71823. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71824. */
  71825. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  71826. /**
  71827. * Define this method to modify the default behavior when loading buffer views.
  71828. * @param context The context when loading the asset
  71829. * @param bufferView The glTF buffer view property
  71830. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71831. */
  71832. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  71833. /**
  71834. * Define this method to modify the default behavior when loading buffers.
  71835. * @param context The context when loading the asset
  71836. * @param buffer The glTF buffer property
  71837. * @param byteOffset The byte offset to load
  71838. * @param byteLength The byte length to load
  71839. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71840. */
  71841. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  71842. }
  71843. }
  71844. declare module BABYLON.GLTF2 {
  71845. /**
  71846. * Helper class for working with arrays when loading the glTF asset
  71847. */
  71848. export class ArrayItem {
  71849. /**
  71850. * Gets an item from the given array.
  71851. * @param context The context when loading the asset
  71852. * @param array The array to get the item from
  71853. * @param index The index to the array
  71854. * @returns The array item
  71855. */
  71856. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  71857. /**
  71858. * Assign an `index` field to each item of the given array.
  71859. * @param array The array of items
  71860. */
  71861. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  71862. }
  71863. /**
  71864. * The glTF 2.0 loader
  71865. */
  71866. export class GLTFLoader implements IGLTFLoader {
  71867. /** @hidden */
  71868. _completePromises: Promise<any>[];
  71869. private _disposed;
  71870. private _parent;
  71871. private _state;
  71872. private _extensions;
  71873. private _rootUrl;
  71874. private _fileName;
  71875. private _uniqueRootUrl;
  71876. private _gltf;
  71877. private _bin;
  71878. private _babylonScene;
  71879. private _rootBabylonMesh;
  71880. private _defaultBabylonMaterialData;
  71881. private _progressCallback?;
  71882. private _requests;
  71883. private static readonly _DefaultSampler;
  71884. private static _RegisteredExtensions;
  71885. /**
  71886. * Registers a loader extension.
  71887. * @param name The name of the loader extension.
  71888. * @param factory The factory function that creates the loader extension.
  71889. */
  71890. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  71891. /**
  71892. * Unregisters a loader extension.
  71893. * @param name The name of the loader extension.
  71894. * @returns A boolean indicating whether the extension has been unregistered
  71895. */
  71896. static UnregisterExtension(name: string): boolean;
  71897. /**
  71898. * Gets the loader state.
  71899. */
  71900. readonly state: Nullable<GLTFLoaderState>;
  71901. /**
  71902. * The object that represents the glTF JSON.
  71903. */
  71904. readonly gltf: IGLTF;
  71905. /**
  71906. * The BIN chunk of a binary glTF.
  71907. */
  71908. readonly bin: Nullable<IDataBuffer>;
  71909. /**
  71910. * The parent file loader.
  71911. */
  71912. readonly parent: GLTFFileLoader;
  71913. /**
  71914. * The Babylon scene when loading the asset.
  71915. */
  71916. readonly babylonScene: Scene;
  71917. /**
  71918. * The root Babylon mesh when loading the asset.
  71919. */
  71920. readonly rootBabylonMesh: Mesh;
  71921. /** @hidden */
  71922. constructor(parent: GLTFFileLoader);
  71923. /** @hidden */
  71924. dispose(): void;
  71925. /** @hidden */
  71926. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71927. meshes: AbstractMesh[];
  71928. particleSystems: IParticleSystem[];
  71929. skeletons: Skeleton[];
  71930. animationGroups: AnimationGroup[];
  71931. }>;
  71932. /** @hidden */
  71933. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71934. private _loadAsync;
  71935. private _loadData;
  71936. private _setupData;
  71937. private _loadExtensions;
  71938. private _checkExtensions;
  71939. private _setState;
  71940. private _createRootNode;
  71941. /**
  71942. * Loads a glTF scene.
  71943. * @param context The context when loading the asset
  71944. * @param scene The glTF scene property
  71945. * @returns A promise that resolves when the load is complete
  71946. */
  71947. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  71948. private _forEachPrimitive;
  71949. private _getMeshes;
  71950. private _getSkeletons;
  71951. private _getAnimationGroups;
  71952. private _startAnimations;
  71953. /**
  71954. * Loads a glTF node.
  71955. * @param context The context when loading the asset
  71956. * @param node The glTF node property
  71957. * @param assign A function called synchronously after parsing the glTF properties
  71958. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  71959. */
  71960. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  71961. private _loadMeshAsync;
  71962. /**
  71963. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  71964. * @param context The context when loading the asset
  71965. * @param name The mesh name when loading the asset
  71966. * @param node The glTF node when loading the asset
  71967. * @param mesh The glTF mesh when loading the asset
  71968. * @param primitive The glTF mesh primitive property
  71969. * @param assign A function called synchronously after parsing the glTF properties
  71970. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  71971. */
  71972. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  71973. private _loadVertexDataAsync;
  71974. private _createMorphTargets;
  71975. private _loadMorphTargetsAsync;
  71976. private _loadMorphTargetVertexDataAsync;
  71977. private static _LoadTransform;
  71978. private _loadSkinAsync;
  71979. private _loadBones;
  71980. private _loadBone;
  71981. private _loadSkinInverseBindMatricesDataAsync;
  71982. private _updateBoneMatrices;
  71983. private _getNodeMatrix;
  71984. /**
  71985. * Loads a glTF camera.
  71986. * @param context The context when loading the asset
  71987. * @param camera The glTF camera property
  71988. * @param assign A function called synchronously after parsing the glTF properties
  71989. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  71990. */
  71991. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  71992. private _loadAnimationsAsync;
  71993. /**
  71994. * Loads a glTF animation.
  71995. * @param context The context when loading the asset
  71996. * @param animation The glTF animation property
  71997. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  71998. */
  71999. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  72000. /**
  72001. * @hidden Loads a glTF animation channel.
  72002. * @param context The context when loading the asset
  72003. * @param animationContext The context of the animation when loading the asset
  72004. * @param animation The glTF animation property
  72005. * @param channel The glTF animation channel property
  72006. * @param babylonAnimationGroup The babylon animation group property
  72007. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  72008. * @returns A void promise when the channel load is complete
  72009. */
  72010. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  72011. private _loadAnimationSamplerAsync;
  72012. private _loadBufferAsync;
  72013. /**
  72014. * Loads a glTF buffer view.
  72015. * @param context The context when loading the asset
  72016. * @param bufferView The glTF buffer view property
  72017. * @returns A promise that resolves with the loaded data when the load is complete
  72018. */
  72019. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  72020. private _loadAccessorAsync;
  72021. private _loadFloatAccessorAsync;
  72022. private _loadIndicesAccessorAsync;
  72023. private _loadVertexBufferViewAsync;
  72024. private _loadVertexAccessorAsync;
  72025. private _loadMaterialMetallicRoughnessPropertiesAsync;
  72026. /** @hidden */
  72027. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  72028. private _createDefaultMaterial;
  72029. /**
  72030. * Creates a Babylon material from a glTF material.
  72031. * @param context The context when loading the asset
  72032. * @param material The glTF material property
  72033. * @param babylonDrawMode The draw mode for the Babylon material
  72034. * @returns The Babylon material
  72035. */
  72036. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  72037. /**
  72038. * Loads properties from a glTF material into a Babylon material.
  72039. * @param context The context when loading the asset
  72040. * @param material The glTF material property
  72041. * @param babylonMaterial The Babylon material
  72042. * @returns A promise that resolves when the load is complete
  72043. */
  72044. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72045. /**
  72046. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  72047. * @param context The context when loading the asset
  72048. * @param material The glTF material property
  72049. * @param babylonMaterial The Babylon material
  72050. * @returns A promise that resolves when the load is complete
  72051. */
  72052. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72053. /**
  72054. * Loads the alpha properties from a glTF material into a Babylon material.
  72055. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  72056. * @param context The context when loading the asset
  72057. * @param material The glTF material property
  72058. * @param babylonMaterial The Babylon material
  72059. */
  72060. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  72061. /**
  72062. * Loads a glTF texture info.
  72063. * @param context The context when loading the asset
  72064. * @param textureInfo The glTF texture info property
  72065. * @param assign A function called synchronously after parsing the glTF properties
  72066. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  72067. */
  72068. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  72069. private _loadTextureAsync;
  72070. private _loadSampler;
  72071. /**
  72072. * Loads a glTF image.
  72073. * @param context The context when loading the asset
  72074. * @param image The glTF image property
  72075. * @returns A promise that resolves with the loaded data when the load is complete
  72076. */
  72077. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  72078. /**
  72079. * Loads a glTF uri.
  72080. * @param context The context when loading the asset
  72081. * @param property The glTF property associated with the uri
  72082. * @param uri The base64 or relative uri
  72083. * @returns A promise that resolves with the loaded data when the load is complete
  72084. */
  72085. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  72086. private _onProgress;
  72087. /**
  72088. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  72089. * @param babylonObject the Babylon object with metadata
  72090. * @param pointer the JSON pointer
  72091. */
  72092. static AddPointerMetadata(babylonObject: {
  72093. metadata: any;
  72094. }, pointer: string): void;
  72095. private static _GetTextureWrapMode;
  72096. private static _GetTextureSamplingMode;
  72097. private static _GetTypedArrayConstructor;
  72098. private static _GetTypedArray;
  72099. private static _GetNumComponents;
  72100. private static _ValidateUri;
  72101. private static _GetDrawMode;
  72102. private _compileMaterialsAsync;
  72103. private _compileShadowGeneratorsAsync;
  72104. private _forEachExtensions;
  72105. private _applyExtensions;
  72106. private _extensionsOnLoading;
  72107. private _extensionsOnReady;
  72108. private _extensionsLoadSceneAsync;
  72109. private _extensionsLoadNodeAsync;
  72110. private _extensionsLoadCameraAsync;
  72111. private _extensionsLoadVertexDataAsync;
  72112. private _extensionsLoadMeshPrimitiveAsync;
  72113. private _extensionsLoadMaterialAsync;
  72114. private _extensionsCreateMaterial;
  72115. private _extensionsLoadMaterialPropertiesAsync;
  72116. private _extensionsLoadTextureInfoAsync;
  72117. private _extensionsLoadAnimationAsync;
  72118. private _extensionsLoadSkinAsync;
  72119. private _extensionsLoadUriAsync;
  72120. private _extensionsLoadBufferViewAsync;
  72121. private _extensionsLoadBufferAsync;
  72122. /**
  72123. * Helper method called by a loader extension to load an glTF extension.
  72124. * @param context The context when loading the asset
  72125. * @param property The glTF property to load the extension from
  72126. * @param extensionName The name of the extension to load
  72127. * @param actionAsync The action to run
  72128. * @returns The promise returned by actionAsync or null if the extension does not exist
  72129. */
  72130. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  72131. /**
  72132. * Helper method called by a loader extension to load a glTF extra.
  72133. * @param context The context when loading the asset
  72134. * @param property The glTF property to load the extra from
  72135. * @param extensionName The name of the extension to load
  72136. * @param actionAsync The action to run
  72137. * @returns The promise returned by actionAsync or null if the extra does not exist
  72138. */
  72139. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  72140. /**
  72141. * Checks for presence of an extension.
  72142. * @param name The name of the extension to check
  72143. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  72144. */
  72145. isExtensionUsed(name: string): boolean;
  72146. /**
  72147. * Increments the indentation level and logs a message.
  72148. * @param message The message to log
  72149. */
  72150. logOpen(message: string): void;
  72151. /**
  72152. * Decrements the indentation level.
  72153. */
  72154. logClose(): void;
  72155. /**
  72156. * Logs a message
  72157. * @param message The message to log
  72158. */
  72159. log(message: string): void;
  72160. /**
  72161. * Starts a performance counter.
  72162. * @param counterName The name of the performance counter
  72163. */
  72164. startPerformanceCounter(counterName: string): void;
  72165. /**
  72166. * Ends a performance counter.
  72167. * @param counterName The name of the performance counter
  72168. */
  72169. endPerformanceCounter(counterName: string): void;
  72170. }
  72171. }
  72172. declare module BABYLON.GLTF2.Loader.Extensions {
  72173. /**
  72174. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  72175. */
  72176. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  72177. /**
  72178. * The name of this extension.
  72179. */
  72180. readonly name: string;
  72181. /**
  72182. * Defines whether this extension is enabled.
  72183. */
  72184. enabled: boolean;
  72185. private _loader;
  72186. private _lights?;
  72187. /** @hidden */
  72188. constructor(loader: GLTFLoader);
  72189. /** @hidden */
  72190. dispose(): void;
  72191. /** @hidden */
  72192. onLoading(): void;
  72193. /** @hidden */
  72194. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  72195. private _loadLightAsync;
  72196. }
  72197. }
  72198. declare module BABYLON.GLTF2.Loader.Extensions {
  72199. /**
  72200. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  72201. */
  72202. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  72203. /**
  72204. * The name of this extension.
  72205. */
  72206. readonly name: string;
  72207. /**
  72208. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  72209. */
  72210. dracoCompression?: DracoCompression;
  72211. /**
  72212. * Defines whether this extension is enabled.
  72213. */
  72214. enabled: boolean;
  72215. private _loader;
  72216. /** @hidden */
  72217. constructor(loader: GLTFLoader);
  72218. /** @hidden */
  72219. dispose(): void;
  72220. /** @hidden */
  72221. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  72222. }
  72223. }
  72224. declare module BABYLON.GLTF2.Loader.Extensions {
  72225. /**
  72226. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  72227. */
  72228. export class KHR_lights implements IGLTFLoaderExtension {
  72229. /**
  72230. * The name of this extension.
  72231. */
  72232. readonly name: string;
  72233. /**
  72234. * Defines whether this extension is enabled.
  72235. */
  72236. enabled: boolean;
  72237. private _loader;
  72238. private _lights?;
  72239. /** @hidden */
  72240. constructor(loader: GLTFLoader);
  72241. /** @hidden */
  72242. dispose(): void;
  72243. /** @hidden */
  72244. onLoading(): void;
  72245. /** @hidden */
  72246. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72247. }
  72248. }
  72249. declare module BABYLON.GLTF2.Loader.Extensions {
  72250. /**
  72251. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  72252. */
  72253. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  72254. /**
  72255. * The name of this extension.
  72256. */
  72257. readonly name: string;
  72258. /**
  72259. * Defines whether this extension is enabled.
  72260. */
  72261. enabled: boolean;
  72262. /**
  72263. * Defines a number that determines the order the extensions are applied.
  72264. */
  72265. order: number;
  72266. private _loader;
  72267. /** @hidden */
  72268. constructor(loader: GLTFLoader);
  72269. /** @hidden */
  72270. dispose(): void;
  72271. /** @hidden */
  72272. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72273. private _loadSpecularGlossinessPropertiesAsync;
  72274. }
  72275. }
  72276. declare module BABYLON.GLTF2.Loader.Extensions {
  72277. /**
  72278. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  72279. */
  72280. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  72281. /**
  72282. * The name of this extension.
  72283. */
  72284. readonly name: string;
  72285. /**
  72286. * Defines whether this extension is enabled.
  72287. */
  72288. enabled: boolean;
  72289. /**
  72290. * Defines a number that determines the order the extensions are applied.
  72291. */
  72292. order: number;
  72293. private _loader;
  72294. /** @hidden */
  72295. constructor(loader: GLTFLoader);
  72296. /** @hidden */
  72297. dispose(): void;
  72298. /** @hidden */
  72299. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72300. private _loadUnlitPropertiesAsync;
  72301. }
  72302. }
  72303. declare module BABYLON.GLTF2.Loader.Extensions {
  72304. /**
  72305. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  72306. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  72307. * !!! Experimental Extension Subject to Changes !!!
  72308. */
  72309. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  72310. /**
  72311. * The name of this extension.
  72312. */
  72313. readonly name: string;
  72314. /**
  72315. * Defines whether this extension is enabled.
  72316. */
  72317. enabled: boolean;
  72318. /**
  72319. * Defines a number that determines the order the extensions are applied.
  72320. */
  72321. order: number;
  72322. private _loader;
  72323. /** @hidden */
  72324. constructor(loader: GLTFLoader);
  72325. /** @hidden */
  72326. dispose(): void;
  72327. /** @hidden */
  72328. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72329. private _loadClearCoatPropertiesAsync;
  72330. }
  72331. }
  72332. declare module BABYLON.GLTF2.Loader.Extensions {
  72333. /**
  72334. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  72335. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  72336. * !!! Experimental Extension Subject to Changes !!!
  72337. */
  72338. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  72339. /**
  72340. * The name of this extension.
  72341. */
  72342. readonly name: string;
  72343. /**
  72344. * Defines whether this extension is enabled.
  72345. */
  72346. enabled: boolean;
  72347. /**
  72348. * Defines a number that determines the order the extensions are applied.
  72349. */
  72350. order: number;
  72351. private _loader;
  72352. /** @hidden */
  72353. constructor(loader: GLTFLoader);
  72354. /** @hidden */
  72355. dispose(): void;
  72356. /** @hidden */
  72357. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72358. private _loadSheenPropertiesAsync;
  72359. }
  72360. }
  72361. declare module BABYLON.GLTF2.Loader.Extensions {
  72362. /**
  72363. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  72364. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  72365. * !!! Experimental Extension Subject to Changes !!!
  72366. */
  72367. export class KHR_materials_specular implements IGLTFLoaderExtension {
  72368. /**
  72369. * The name of this extension.
  72370. */
  72371. readonly name: string;
  72372. /**
  72373. * Defines whether this extension is enabled.
  72374. */
  72375. enabled: boolean;
  72376. /**
  72377. * Defines a number that determines the order the extensions are applied.
  72378. */
  72379. order: number;
  72380. private _loader;
  72381. /** @hidden */
  72382. constructor(loader: GLTFLoader);
  72383. /** @hidden */
  72384. dispose(): void;
  72385. /** @hidden */
  72386. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72387. private _loadSpecularPropertiesAsync;
  72388. }
  72389. }
  72390. declare module BABYLON.GLTF2.Loader.Extensions {
  72391. /**
  72392. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  72393. */
  72394. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  72395. /**
  72396. * The name of this extension.
  72397. */
  72398. readonly name: string;
  72399. /**
  72400. * Defines whether this extension is enabled.
  72401. */
  72402. enabled: boolean;
  72403. /** @hidden */
  72404. constructor(loader: GLTFLoader);
  72405. /** @hidden */
  72406. dispose(): void;
  72407. }
  72408. }
  72409. declare module BABYLON.GLTF2.Loader.Extensions {
  72410. /**
  72411. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  72412. */
  72413. export class KHR_texture_transform implements IGLTFLoaderExtension {
  72414. /**
  72415. * The name of this extension.
  72416. */
  72417. readonly name: string;
  72418. /**
  72419. * Defines whether this extension is enabled.
  72420. */
  72421. enabled: boolean;
  72422. private _loader;
  72423. /** @hidden */
  72424. constructor(loader: GLTFLoader);
  72425. /** @hidden */
  72426. dispose(): void;
  72427. /** @hidden */
  72428. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  72429. }
  72430. }
  72431. declare module BABYLON.GLTF2.Loader.Extensions {
  72432. /**
  72433. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  72434. */
  72435. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  72436. /**
  72437. * The name of this extension.
  72438. */
  72439. readonly name: string;
  72440. /**
  72441. * Defines whether this extension is enabled.
  72442. */
  72443. enabled: boolean;
  72444. private _loader;
  72445. private _clips;
  72446. private _emitters;
  72447. /** @hidden */
  72448. constructor(loader: GLTFLoader);
  72449. /** @hidden */
  72450. dispose(): void;
  72451. /** @hidden */
  72452. onLoading(): void;
  72453. /** @hidden */
  72454. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  72455. /** @hidden */
  72456. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72457. /** @hidden */
  72458. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  72459. private _loadClipAsync;
  72460. private _loadEmitterAsync;
  72461. private _getEventAction;
  72462. private _loadAnimationEventAsync;
  72463. }
  72464. }
  72465. declare module BABYLON.GLTF2.Loader.Extensions {
  72466. /**
  72467. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  72468. */
  72469. export class MSFT_lod implements IGLTFLoaderExtension {
  72470. /**
  72471. * The name of this extension.
  72472. */
  72473. readonly name: string;
  72474. /**
  72475. * Defines whether this extension is enabled.
  72476. */
  72477. enabled: boolean;
  72478. /**
  72479. * Defines a number that determines the order the extensions are applied.
  72480. */
  72481. order: number;
  72482. /**
  72483. * Maximum number of LODs to load, starting from the lowest LOD.
  72484. */
  72485. maxLODsToLoad: number;
  72486. /**
  72487. * Observable raised when all node LODs of one level are loaded.
  72488. * The event data is the index of the loaded LOD starting from zero.
  72489. * Dispose the loader to cancel the loading of the next level of LODs.
  72490. */
  72491. onNodeLODsLoadedObservable: Observable<number>;
  72492. /**
  72493. * Observable raised when all material LODs of one level are loaded.
  72494. * The event data is the index of the loaded LOD starting from zero.
  72495. * Dispose the loader to cancel the loading of the next level of LODs.
  72496. */
  72497. onMaterialLODsLoadedObservable: Observable<number>;
  72498. private _loader;
  72499. private _nodeIndexLOD;
  72500. private _nodeSignalLODs;
  72501. private _nodePromiseLODs;
  72502. private _materialIndexLOD;
  72503. private _materialSignalLODs;
  72504. private _materialPromiseLODs;
  72505. private _indexLOD;
  72506. private _bufferLODs;
  72507. /** @hidden */
  72508. constructor(loader: GLTFLoader);
  72509. /** @hidden */
  72510. dispose(): void;
  72511. /** @hidden */
  72512. onReady(): void;
  72513. /** @hidden */
  72514. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72515. /** @hidden */
  72516. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  72517. /** @hidden */
  72518. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  72519. /** @hidden */
  72520. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  72521. private _loadBufferLOD;
  72522. /**
  72523. * Gets an array of LOD properties from lowest to highest.
  72524. */
  72525. private _getLODs;
  72526. private _disposeUnusedMaterials;
  72527. }
  72528. }
  72529. declare module BABYLON.GLTF2.Loader.Extensions {
  72530. /** @hidden */
  72531. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  72532. readonly name: string;
  72533. enabled: boolean;
  72534. private _loader;
  72535. constructor(loader: GLTFLoader);
  72536. dispose(): void;
  72537. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72538. }
  72539. }
  72540. declare module BABYLON.GLTF2.Loader.Extensions {
  72541. /** @hidden */
  72542. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  72543. readonly name: string;
  72544. enabled: boolean;
  72545. private _loader;
  72546. constructor(loader: GLTFLoader);
  72547. dispose(): void;
  72548. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72549. }
  72550. }
  72551. declare module BABYLON.GLTF2.Loader.Extensions {
  72552. /**
  72553. * Store glTF extras (if present) in BJS objects' metadata
  72554. */
  72555. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  72556. /**
  72557. * The name of this extension.
  72558. */
  72559. readonly name: string;
  72560. /**
  72561. * Defines whether this extension is enabled.
  72562. */
  72563. enabled: boolean;
  72564. private _loader;
  72565. private _assignExtras;
  72566. /** @hidden */
  72567. constructor(loader: GLTFLoader);
  72568. /** @hidden */
  72569. dispose(): void;
  72570. /** @hidden */
  72571. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72572. /** @hidden */
  72573. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  72574. /** @hidden */
  72575. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  72576. }
  72577. }
  72578. declare module BABYLON {
  72579. /**
  72580. * Class reading and parsing the MTL file bundled with the obj file.
  72581. */
  72582. export class MTLFileLoader {
  72583. /**
  72584. * All material loaded from the mtl will be set here
  72585. */
  72586. materials: StandardMaterial[];
  72587. /**
  72588. * This function will read the mtl file and create each material described inside
  72589. * This function could be improve by adding :
  72590. * -some component missing (Ni, Tf...)
  72591. * -including the specific options available
  72592. *
  72593. * @param scene defines the scene the material will be created in
  72594. * @param data defines the mtl data to parse
  72595. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  72596. */
  72597. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  72598. /**
  72599. * Gets the texture for the material.
  72600. *
  72601. * If the material is imported from input file,
  72602. * We sanitize the url to ensure it takes the textre from aside the material.
  72603. *
  72604. * @param rootUrl The root url to load from
  72605. * @param value The value stored in the mtl
  72606. * @return The Texture
  72607. */
  72608. private static _getTexture;
  72609. }
  72610. /**
  72611. * Options for loading OBJ/MTL files
  72612. */
  72613. type MeshLoadOptions = {
  72614. /**
  72615. * Defines if UVs are optimized by default during load.
  72616. */
  72617. OptimizeWithUV: boolean;
  72618. /**
  72619. * Defines custom scaling of UV coordinates of loaded meshes.
  72620. */
  72621. UVScaling: Vector2;
  72622. /**
  72623. * Invert model on y-axis (does a model scaling inversion)
  72624. */
  72625. InvertY: boolean;
  72626. /**
  72627. * Invert Y-Axis of referenced textures on load
  72628. */
  72629. InvertTextureY: boolean;
  72630. /**
  72631. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  72632. */
  72633. ImportVertexColors: boolean;
  72634. /**
  72635. * Compute the normals for the model, even if normals are present in the file.
  72636. */
  72637. ComputeNormals: boolean;
  72638. /**
  72639. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  72640. */
  72641. SkipMaterials: boolean;
  72642. /**
  72643. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  72644. */
  72645. MaterialLoadingFailsSilently: boolean;
  72646. };
  72647. /**
  72648. * OBJ file type loader.
  72649. * This is a babylon scene loader plugin.
  72650. */
  72651. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  72652. /**
  72653. * Defines if UVs are optimized by default during load.
  72654. */
  72655. static OPTIMIZE_WITH_UV: boolean;
  72656. /**
  72657. * Invert model on y-axis (does a model scaling inversion)
  72658. */
  72659. static INVERT_Y: boolean;
  72660. /**
  72661. * Invert Y-Axis of referenced textures on load
  72662. */
  72663. static INVERT_TEXTURE_Y: boolean;
  72664. /**
  72665. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  72666. */
  72667. static IMPORT_VERTEX_COLORS: boolean;
  72668. /**
  72669. * Compute the normals for the model, even if normals are present in the file.
  72670. */
  72671. static COMPUTE_NORMALS: boolean;
  72672. /**
  72673. * Defines custom scaling of UV coordinates of loaded meshes.
  72674. */
  72675. static UV_SCALING: Vector2;
  72676. /**
  72677. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  72678. */
  72679. static SKIP_MATERIALS: boolean;
  72680. /**
  72681. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  72682. *
  72683. * Defaults to true for backwards compatibility.
  72684. */
  72685. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  72686. /**
  72687. * Defines the name of the plugin.
  72688. */
  72689. name: string;
  72690. /**
  72691. * Defines the extension the plugin is able to load.
  72692. */
  72693. extensions: string;
  72694. /** @hidden */
  72695. obj: RegExp;
  72696. /** @hidden */
  72697. group: RegExp;
  72698. /** @hidden */
  72699. mtllib: RegExp;
  72700. /** @hidden */
  72701. usemtl: RegExp;
  72702. /** @hidden */
  72703. smooth: RegExp;
  72704. /** @hidden */
  72705. vertexPattern: RegExp;
  72706. /** @hidden */
  72707. normalPattern: RegExp;
  72708. /** @hidden */
  72709. uvPattern: RegExp;
  72710. /** @hidden */
  72711. facePattern1: RegExp;
  72712. /** @hidden */
  72713. facePattern2: RegExp;
  72714. /** @hidden */
  72715. facePattern3: RegExp;
  72716. /** @hidden */
  72717. facePattern4: RegExp;
  72718. /** @hidden */
  72719. facePattern5: RegExp;
  72720. private _meshLoadOptions;
  72721. /**
  72722. * Creates loader for .OBJ files
  72723. *
  72724. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  72725. */
  72726. constructor(meshLoadOptions?: MeshLoadOptions);
  72727. private static readonly currentMeshLoadOptions;
  72728. /**
  72729. * Calls synchronously the MTL file attached to this obj.
  72730. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  72731. * Without this function materials are not displayed in the first frame (but displayed after).
  72732. * In consequence it is impossible to get material information in your HTML file
  72733. *
  72734. * @param url The URL of the MTL file
  72735. * @param rootUrl
  72736. * @param onSuccess Callback function to be called when the MTL file is loaded
  72737. * @private
  72738. */
  72739. private _loadMTL;
  72740. /**
  72741. * Instantiates a OBJ file loader plugin.
  72742. * @returns the created plugin
  72743. */
  72744. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  72745. /**
  72746. * If the data string can be loaded directly.
  72747. *
  72748. * @param data string containing the file data
  72749. * @returns if the data can be loaded directly
  72750. */
  72751. canDirectLoad(data: string): boolean;
  72752. /**
  72753. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  72754. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  72755. * @param scene the scene the meshes should be added to
  72756. * @param data the OBJ data to load
  72757. * @param rootUrl root url to load from
  72758. * @param onProgress event that fires when loading progress has occured
  72759. * @param fileName Defines the name of the file to load
  72760. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  72761. */
  72762. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  72763. meshes: AbstractMesh[];
  72764. particleSystems: IParticleSystem[];
  72765. skeletons: Skeleton[];
  72766. animationGroups: AnimationGroup[];
  72767. }>;
  72768. /**
  72769. * Imports all objects from the loaded OBJ data and adds them to the scene
  72770. * @param scene the scene the objects should be added to
  72771. * @param data the OBJ data to load
  72772. * @param rootUrl root url to load from
  72773. * @param onProgress event that fires when loading progress has occured
  72774. * @param fileName Defines the name of the file to load
  72775. * @returns a promise which completes when objects have been loaded to the scene
  72776. */
  72777. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  72778. /**
  72779. * Load into an asset container.
  72780. * @param scene The scene to load into
  72781. * @param data The data to import
  72782. * @param rootUrl The root url for scene and resources
  72783. * @param onProgress The callback when the load progresses
  72784. * @param fileName Defines the name of the file to load
  72785. * @returns The loaded asset container
  72786. */
  72787. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  72788. /**
  72789. * Read the OBJ file and create an Array of meshes.
  72790. * Each mesh contains all information given by the OBJ and the MTL file.
  72791. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  72792. *
  72793. * @param meshesNames
  72794. * @param scene Scene The scene where are displayed the data
  72795. * @param data String The content of the obj file
  72796. * @param rootUrl String The path to the folder
  72797. * @returns Array<AbstractMesh>
  72798. * @private
  72799. */
  72800. private _parseSolid;
  72801. }
  72802. }
  72803. declare module BABYLON {
  72804. /**
  72805. * STL file type loader.
  72806. * This is a babylon scene loader plugin.
  72807. */
  72808. export class STLFileLoader implements ISceneLoaderPlugin {
  72809. /** @hidden */
  72810. solidPattern: RegExp;
  72811. /** @hidden */
  72812. facetsPattern: RegExp;
  72813. /** @hidden */
  72814. normalPattern: RegExp;
  72815. /** @hidden */
  72816. vertexPattern: RegExp;
  72817. /**
  72818. * Defines the name of the plugin.
  72819. */
  72820. name: string;
  72821. /**
  72822. * Defines the extensions the stl loader is able to load.
  72823. * force data to come in as an ArrayBuffer
  72824. * we'll convert to string if it looks like it's an ASCII .stl
  72825. */
  72826. extensions: ISceneLoaderPluginExtensions;
  72827. /**
  72828. * Import meshes into a scene.
  72829. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  72830. * @param scene The scene to import into
  72831. * @param data The data to import
  72832. * @param rootUrl The root url for scene and resources
  72833. * @param meshes The meshes array to import into
  72834. * @param particleSystems The particle systems array to import into
  72835. * @param skeletons The skeletons array to import into
  72836. * @param onError The callback when import fails
  72837. * @returns True if successful or false otherwise
  72838. */
  72839. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  72840. /**
  72841. * Load into a scene.
  72842. * @param scene The scene to load into
  72843. * @param data The data to import
  72844. * @param rootUrl The root url for scene and resources
  72845. * @param onError The callback when import fails
  72846. * @returns true if successful or false otherwise
  72847. */
  72848. load(scene: Scene, data: any, rootUrl: string): boolean;
  72849. /**
  72850. * Load into an asset container.
  72851. * @param scene The scene to load into
  72852. * @param data The data to import
  72853. * @param rootUrl The root url for scene and resources
  72854. * @param onError The callback when import fails
  72855. * @returns The loaded asset container
  72856. */
  72857. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  72858. private _isBinary;
  72859. private _parseBinary;
  72860. private _parseASCII;
  72861. }
  72862. }
  72863. declare module BABYLON {
  72864. /**
  72865. * Class for generating OBJ data from a Babylon scene.
  72866. */
  72867. export class OBJExport {
  72868. /**
  72869. * Exports the geometry of a Mesh array in .OBJ file format (text)
  72870. * @param mesh defines the list of meshes to serialize
  72871. * @param materials defines if materials should be exported
  72872. * @param matlibname defines the name of the associated mtl file
  72873. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  72874. * @returns the OBJ content
  72875. */
  72876. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  72877. /**
  72878. * Exports the material(s) of a mesh in .MTL file format (text)
  72879. * @param mesh defines the mesh to extract the material from
  72880. * @returns the mtl content
  72881. */
  72882. static MTL(mesh: Mesh): string;
  72883. }
  72884. }
  72885. declare module BABYLON {
  72886. /** @hidden */
  72887. export var __IGLTFExporterExtension: number;
  72888. /**
  72889. * Interface for extending the exporter
  72890. * @hidden
  72891. */
  72892. export interface IGLTFExporterExtension {
  72893. /**
  72894. * The name of this extension
  72895. */
  72896. readonly name: string;
  72897. /**
  72898. * Defines whether this extension is enabled
  72899. */
  72900. enabled: boolean;
  72901. /**
  72902. * Defines whether this extension is required
  72903. */
  72904. required: boolean;
  72905. }
  72906. }
  72907. declare module BABYLON.GLTF2.Exporter {
  72908. /** @hidden */
  72909. export var __IGLTFExporterExtensionV2: number;
  72910. /**
  72911. * Interface for a glTF exporter extension
  72912. * @hidden
  72913. */
  72914. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  72915. /**
  72916. * Define this method to modify the default behavior before exporting a texture
  72917. * @param context The context when loading the asset
  72918. * @param babylonTexture The Babylon.js texture
  72919. * @param mimeType The mime-type of the generated image
  72920. * @returns A promise that resolves with the exported texture
  72921. */
  72922. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  72923. /**
  72924. * Define this method to get notified when a texture info is created
  72925. * @param context The context when loading the asset
  72926. * @param textureInfo The glTF texture info
  72927. * @param babylonTexture The Babylon.js texture
  72928. */
  72929. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  72930. /**
  72931. * Define this method to modify the default behavior when exporting texture info
  72932. * @param context The context when loading the asset
  72933. * @param meshPrimitive glTF mesh primitive
  72934. * @param babylonSubMesh Babylon submesh
  72935. * @param binaryWriter glTF serializer binary writer instance
  72936. * @returns nullable IMeshPrimitive promise
  72937. */
  72938. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  72939. /**
  72940. * Define this method to modify the default behavior when exporting a node
  72941. * @param context The context when exporting the node
  72942. * @param node glTF node
  72943. * @param babylonNode BabylonJS node
  72944. * @returns nullable INode promise
  72945. */
  72946. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  72947. /**
  72948. * Define this method to modify the default behavior when exporting a material
  72949. * @param material glTF material
  72950. * @param babylonMaterial BabylonJS material
  72951. * @returns nullable IMaterial promise
  72952. */
  72953. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  72954. /**
  72955. * Define this method to return additional textures to export from a material
  72956. * @param material glTF material
  72957. * @param babylonMaterial BabylonJS material
  72958. * @returns List of textures
  72959. */
  72960. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  72961. /** Gets a boolean indicating that this extension was used */
  72962. wasUsed: boolean;
  72963. /** Gets a boolean indicating that this extension is required for the file to work */
  72964. required: boolean;
  72965. /**
  72966. * Called after the exporter state changes to EXPORTING
  72967. */
  72968. onExporting?(): void;
  72969. }
  72970. }
  72971. declare module BABYLON.GLTF2.Exporter {
  72972. /**
  72973. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  72974. * @hidden
  72975. */
  72976. export class _GLTFMaterialExporter {
  72977. /**
  72978. * Represents the dielectric specular values for R, G and B
  72979. */
  72980. private static readonly _DielectricSpecular;
  72981. /**
  72982. * Allows the maximum specular power to be defined for material calculations
  72983. */
  72984. private static readonly _MaxSpecularPower;
  72985. /**
  72986. * Mapping to store textures
  72987. */
  72988. private _textureMap;
  72989. /**
  72990. * Numeric tolerance value
  72991. */
  72992. private static readonly _Epsilon;
  72993. /**
  72994. * Reference to the glTF Exporter
  72995. */
  72996. private _exporter;
  72997. constructor(exporter: _Exporter);
  72998. /**
  72999. * Specifies if two colors are approximately equal in value
  73000. * @param color1 first color to compare to
  73001. * @param color2 second color to compare to
  73002. * @param epsilon threshold value
  73003. */
  73004. private static FuzzyEquals;
  73005. /**
  73006. * Gets the materials from a Babylon scene and converts them to glTF materials
  73007. * @param scene babylonjs scene
  73008. * @param mimeType texture mime type
  73009. * @param images array of images
  73010. * @param textures array of textures
  73011. * @param materials array of materials
  73012. * @param imageData mapping of texture names to base64 textures
  73013. * @param hasTextureCoords specifies if texture coordinates are present on the material
  73014. */
  73015. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  73016. /**
  73017. * Makes a copy of the glTF material without the texture parameters
  73018. * @param originalMaterial original glTF material
  73019. * @returns glTF material without texture parameters
  73020. */
  73021. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  73022. /**
  73023. * Specifies if the material has any texture parameters present
  73024. * @param material glTF Material
  73025. * @returns boolean specifying if texture parameters are present
  73026. */
  73027. _hasTexturesPresent(material: IMaterial): boolean;
  73028. /**
  73029. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  73030. * @param babylonStandardMaterial
  73031. * @returns glTF Metallic Roughness Material representation
  73032. */
  73033. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  73034. /**
  73035. * Computes the metallic factor
  73036. * @param diffuse diffused value
  73037. * @param specular specular value
  73038. * @param oneMinusSpecularStrength one minus the specular strength
  73039. * @returns metallic value
  73040. */
  73041. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  73042. /**
  73043. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  73044. * @param glTFMaterial glTF material
  73045. * @param babylonMaterial Babylon material
  73046. */
  73047. private static _SetAlphaMode;
  73048. /**
  73049. * Converts a Babylon Standard Material to a glTF Material
  73050. * @param babylonStandardMaterial BJS Standard Material
  73051. * @param mimeType mime type to use for the textures
  73052. * @param images array of glTF image interfaces
  73053. * @param textures array of glTF texture interfaces
  73054. * @param materials array of glTF material interfaces
  73055. * @param imageData map of image file name to data
  73056. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73057. */
  73058. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73059. private _finishMaterial;
  73060. /**
  73061. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  73062. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  73063. * @param mimeType mime type to use for the textures
  73064. * @param images array of glTF image interfaces
  73065. * @param textures array of glTF texture interfaces
  73066. * @param materials array of glTF material interfaces
  73067. * @param imageData map of image file name to data
  73068. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73069. */
  73070. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73071. /**
  73072. * Converts an image typed array buffer to a base64 image
  73073. * @param buffer typed array buffer
  73074. * @param width width of the image
  73075. * @param height height of the image
  73076. * @param mimeType mimetype of the image
  73077. * @returns base64 image string
  73078. */
  73079. private _createBase64FromCanvasAsync;
  73080. /**
  73081. * Generates a white texture based on the specified width and height
  73082. * @param width width of the texture in pixels
  73083. * @param height height of the texture in pixels
  73084. * @param scene babylonjs scene
  73085. * @returns white texture
  73086. */
  73087. private _createWhiteTexture;
  73088. /**
  73089. * 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
  73090. * @param texture1 first texture to resize
  73091. * @param texture2 second texture to resize
  73092. * @param scene babylonjs scene
  73093. * @returns resized textures or null
  73094. */
  73095. private _resizeTexturesToSameDimensions;
  73096. /**
  73097. * Converts an array of pixels to a Float32Array
  73098. * Throws an error if the pixel format is not supported
  73099. * @param pixels - array buffer containing pixel values
  73100. * @returns Float32 of pixels
  73101. */
  73102. private _convertPixelArrayToFloat32;
  73103. /**
  73104. * Convert Specular Glossiness Textures to Metallic Roughness
  73105. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  73106. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  73107. * @param diffuseTexture texture used to store diffuse information
  73108. * @param specularGlossinessTexture texture used to store specular and glossiness information
  73109. * @param factors specular glossiness material factors
  73110. * @param mimeType the mime type to use for the texture
  73111. * @returns pbr metallic roughness interface or null
  73112. */
  73113. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  73114. /**
  73115. * Converts specular glossiness material properties to metallic roughness
  73116. * @param specularGlossiness interface with specular glossiness material properties
  73117. * @returns interface with metallic roughness material properties
  73118. */
  73119. private _convertSpecularGlossinessToMetallicRoughness;
  73120. /**
  73121. * Calculates the surface reflectance, independent of lighting conditions
  73122. * @param color Color source to calculate brightness from
  73123. * @returns number representing the perceived brightness, or zero if color is undefined
  73124. */
  73125. private _getPerceivedBrightness;
  73126. /**
  73127. * Returns the maximum color component value
  73128. * @param color
  73129. * @returns maximum color component value, or zero if color is null or undefined
  73130. */
  73131. private _getMaxComponent;
  73132. /**
  73133. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  73134. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73135. * @param mimeType mime type to use for the textures
  73136. * @param images array of glTF image interfaces
  73137. * @param textures array of glTF texture interfaces
  73138. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  73139. * @param imageData map of image file name to data
  73140. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73141. * @returns glTF PBR Metallic Roughness factors
  73142. */
  73143. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  73144. private _getGLTFTextureSampler;
  73145. private _getGLTFTextureWrapMode;
  73146. private _getGLTFTextureWrapModesSampler;
  73147. /**
  73148. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  73149. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73150. * @param mimeType mime type to use for the textures
  73151. * @param images array of glTF image interfaces
  73152. * @param textures array of glTF texture interfaces
  73153. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  73154. * @param imageData map of image file name to data
  73155. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73156. * @returns glTF PBR Metallic Roughness factors
  73157. */
  73158. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  73159. /**
  73160. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  73161. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73162. * @param mimeType mime type to use for the textures
  73163. * @param images array of glTF image interfaces
  73164. * @param textures array of glTF texture interfaces
  73165. * @param materials array of glTF material interfaces
  73166. * @param imageData map of image file name to data
  73167. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73168. */
  73169. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73170. private setMetallicRoughnessPbrMaterial;
  73171. private getPixelsFromTexture;
  73172. /**
  73173. * Extracts a texture from a Babylon texture into file data and glTF data
  73174. * @param babylonTexture Babylon texture to extract
  73175. * @param mimeType Mime Type of the babylonTexture
  73176. * @return glTF texture info, or null if the texture format is not supported
  73177. */
  73178. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  73179. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  73180. /**
  73181. * Builds a texture from base64 string
  73182. * @param base64Texture base64 texture string
  73183. * @param baseTextureName Name to use for the texture
  73184. * @param mimeType image mime type for the texture
  73185. * @param images array of images
  73186. * @param textures array of textures
  73187. * @param imageData map of image data
  73188. * @returns glTF texture info, or null if the texture format is not supported
  73189. */
  73190. private _getTextureInfoFromBase64;
  73191. }
  73192. }
  73193. declare module BABYLON {
  73194. /**
  73195. * Class for holding and downloading glTF file data
  73196. */
  73197. export class GLTFData {
  73198. /**
  73199. * Object which contains the file name as the key and its data as the value
  73200. */
  73201. glTFFiles: {
  73202. [fileName: string]: string | Blob;
  73203. };
  73204. /**
  73205. * Initializes the glTF file object
  73206. */
  73207. constructor();
  73208. /**
  73209. * Downloads the glTF data as files based on their names and data
  73210. */
  73211. downloadFiles(): void;
  73212. }
  73213. }
  73214. declare module BABYLON {
  73215. /**
  73216. * Holds a collection of exporter options and parameters
  73217. */
  73218. export interface IExportOptions {
  73219. /**
  73220. * Function which indicates whether a babylon node should be exported or not
  73221. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  73222. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  73223. */
  73224. shouldExportNode?(node: Node): boolean;
  73225. /**
  73226. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  73227. * @param metadata source metadata to read from
  73228. * @returns the data to store to glTF node extras
  73229. */
  73230. metadataSelector?(metadata: any): any;
  73231. /**
  73232. * The sample rate to bake animation curves
  73233. */
  73234. animationSampleRate?: number;
  73235. /**
  73236. * Begin serialization without waiting for the scene to be ready
  73237. */
  73238. exportWithoutWaitingForScene?: boolean;
  73239. }
  73240. /**
  73241. * Class for generating glTF data from a Babylon scene.
  73242. */
  73243. export class GLTF2Export {
  73244. /**
  73245. * Exports the geometry of the scene to .gltf file format asynchronously
  73246. * @param scene Babylon scene with scene hierarchy information
  73247. * @param filePrefix File prefix to use when generating the glTF file
  73248. * @param options Exporter options
  73249. * @returns Returns an object with a .gltf file and associates texture names
  73250. * as keys and their data and paths as values
  73251. */
  73252. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  73253. private static _PreExportAsync;
  73254. private static _PostExportAsync;
  73255. /**
  73256. * Exports the geometry of the scene to .glb file format asychronously
  73257. * @param scene Babylon scene with scene hierarchy information
  73258. * @param filePrefix File prefix to use when generating glb file
  73259. * @param options Exporter options
  73260. * @returns Returns an object with a .glb filename as key and data as value
  73261. */
  73262. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  73263. }
  73264. }
  73265. declare module BABYLON.GLTF2.Exporter {
  73266. /**
  73267. * @hidden
  73268. */
  73269. export class _GLTFUtilities {
  73270. /**
  73271. * Creates a buffer view based on the supplied arguments
  73272. * @param bufferIndex index value of the specified buffer
  73273. * @param byteOffset byte offset value
  73274. * @param byteLength byte length of the bufferView
  73275. * @param byteStride byte distance between conequential elements
  73276. * @param name name of the buffer view
  73277. * @returns bufferView for glTF
  73278. */
  73279. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  73280. /**
  73281. * Creates an accessor based on the supplied arguments
  73282. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  73283. * @param name The name of the accessor
  73284. * @param type The type of the accessor
  73285. * @param componentType The datatype of components in the attribute
  73286. * @param count The number of attributes referenced by this accessor
  73287. * @param byteOffset The offset relative to the start of the bufferView in bytes
  73288. * @param min Minimum value of each component in this attribute
  73289. * @param max Maximum value of each component in this attribute
  73290. * @returns accessor for glTF
  73291. */
  73292. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  73293. /**
  73294. * Calculates the minimum and maximum values of an array of position floats
  73295. * @param positions Positions array of a mesh
  73296. * @param vertexStart Starting vertex offset to calculate min and max values
  73297. * @param vertexCount Number of vertices to check for min and max values
  73298. * @returns min number array and max number array
  73299. */
  73300. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  73301. min: number[];
  73302. max: number[];
  73303. };
  73304. /**
  73305. * Converts a new right-handed Vector3
  73306. * @param vector vector3 array
  73307. * @returns right-handed Vector3
  73308. */
  73309. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  73310. /**
  73311. * Converts a Vector3 to right-handed
  73312. * @param vector Vector3 to convert to right-handed
  73313. */
  73314. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  73315. /**
  73316. * Converts a three element number array to right-handed
  73317. * @param vector number array to convert to right-handed
  73318. */
  73319. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  73320. /**
  73321. * Converts a new right-handed Vector3
  73322. * @param vector vector3 array
  73323. * @returns right-handed Vector3
  73324. */
  73325. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  73326. /**
  73327. * Converts a Vector3 to right-handed
  73328. * @param vector Vector3 to convert to right-handed
  73329. */
  73330. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  73331. /**
  73332. * Converts a three element number array to right-handed
  73333. * @param vector number array to convert to right-handed
  73334. */
  73335. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  73336. /**
  73337. * Converts a Vector4 to right-handed
  73338. * @param vector Vector4 to convert to right-handed
  73339. */
  73340. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  73341. /**
  73342. * Converts a Vector4 to right-handed
  73343. * @param vector Vector4 to convert to right-handed
  73344. */
  73345. static _GetRightHandedArray4FromRef(vector: number[]): void;
  73346. /**
  73347. * Converts a Quaternion to right-handed
  73348. * @param quaternion Source quaternion to convert to right-handed
  73349. */
  73350. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  73351. /**
  73352. * Converts a Quaternion to right-handed
  73353. * @param quaternion Source quaternion to convert to right-handed
  73354. */
  73355. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  73356. static _NormalizeTangentFromRef(tangent: Vector4): void;
  73357. }
  73358. }
  73359. declare module BABYLON.GLTF2.Exporter {
  73360. /**
  73361. * Converts Babylon Scene into glTF 2.0.
  73362. * @hidden
  73363. */
  73364. export class _Exporter {
  73365. /**
  73366. * Stores the glTF to export
  73367. */
  73368. _glTF: IGLTF;
  73369. /**
  73370. * Stores all generated buffer views, which represents views into the main glTF buffer data
  73371. */
  73372. _bufferViews: IBufferView[];
  73373. /**
  73374. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  73375. */
  73376. _accessors: IAccessor[];
  73377. /**
  73378. * Stores all the generated nodes, which contains transform and/or mesh information per node
  73379. */
  73380. private _nodes;
  73381. /**
  73382. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  73383. */
  73384. private _scenes;
  73385. /**
  73386. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  73387. */
  73388. private _meshes;
  73389. /**
  73390. * Stores all the generated material information, which represents the appearance of each primitive
  73391. */
  73392. _materials: IMaterial[];
  73393. _materialMap: {
  73394. [materialID: number]: number;
  73395. };
  73396. /**
  73397. * Stores all the generated texture information, which is referenced by glTF materials
  73398. */
  73399. _textures: ITexture[];
  73400. /**
  73401. * Stores all the generated image information, which is referenced by glTF textures
  73402. */
  73403. _images: IImage[];
  73404. /**
  73405. * Stores all the texture samplers
  73406. */
  73407. _samplers: ISampler[];
  73408. /**
  73409. * Stores all the generated animation samplers, which is referenced by glTF animations
  73410. */
  73411. /**
  73412. * Stores the animations for glTF models
  73413. */
  73414. private _animations;
  73415. /**
  73416. * Stores the total amount of bytes stored in the glTF buffer
  73417. */
  73418. private _totalByteLength;
  73419. /**
  73420. * Stores a reference to the Babylon scene containing the source geometry and material information
  73421. */
  73422. _babylonScene: Scene;
  73423. /**
  73424. * Stores a map of the image data, where the key is the file name and the value
  73425. * is the image data
  73426. */
  73427. _imageData: {
  73428. [fileName: string]: {
  73429. data: Uint8Array;
  73430. mimeType: ImageMimeType;
  73431. };
  73432. };
  73433. /**
  73434. * Stores a map of the unique id of a node to its index in the node array
  73435. */
  73436. private _nodeMap;
  73437. /**
  73438. * Specifies if the Babylon scene should be converted to right-handed on export
  73439. */
  73440. _convertToRightHandedSystem: boolean;
  73441. /**
  73442. * Baked animation sample rate
  73443. */
  73444. private _animationSampleRate;
  73445. private _options;
  73446. private _localEngine;
  73447. _glTFMaterialExporter: _GLTFMaterialExporter;
  73448. private _extensions;
  73449. private static _ExtensionNames;
  73450. private static _ExtensionFactories;
  73451. private _applyExtension;
  73452. private _applyExtensions;
  73453. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  73454. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  73455. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  73456. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  73457. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  73458. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  73459. private _forEachExtensions;
  73460. private _extensionsOnExporting;
  73461. /**
  73462. * Load glTF serializer extensions
  73463. */
  73464. private _loadExtensions;
  73465. /**
  73466. * Creates a glTF Exporter instance, which can accept optional exporter options
  73467. * @param babylonScene Babylon scene object
  73468. * @param options Options to modify the behavior of the exporter
  73469. */
  73470. constructor(babylonScene: Scene, options?: IExportOptions);
  73471. dispose(): void;
  73472. /**
  73473. * Registers a glTF exporter extension
  73474. * @param name Name of the extension to export
  73475. * @param factory The factory function that creates the exporter extension
  73476. */
  73477. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  73478. /**
  73479. * Un-registers an exporter extension
  73480. * @param name The name fo the exporter extension
  73481. * @returns A boolean indicating whether the extension has been un-registered
  73482. */
  73483. static UnregisterExtension(name: string): boolean;
  73484. /**
  73485. * Lazy load a local engine with premultiplied alpha set to false
  73486. */
  73487. _getLocalEngine(): Engine;
  73488. private reorderIndicesBasedOnPrimitiveMode;
  73489. /**
  73490. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  73491. * clock-wise during export to glTF
  73492. * @param submesh BabylonJS submesh
  73493. * @param primitiveMode Primitive mode of the mesh
  73494. * @param sideOrientation the winding order of the submesh
  73495. * @param vertexBufferKind The type of vertex attribute
  73496. * @param meshAttributeArray The vertex attribute data
  73497. * @param byteOffset The offset to the binary data
  73498. * @param binaryWriter The binary data for the glTF file
  73499. */
  73500. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  73501. /**
  73502. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  73503. * clock-wise during export to glTF
  73504. * @param submesh BabylonJS submesh
  73505. * @param primitiveMode Primitive mode of the mesh
  73506. * @param sideOrientation the winding order of the submesh
  73507. * @param vertexBufferKind The type of vertex attribute
  73508. * @param meshAttributeArray The vertex attribute data
  73509. * @param byteOffset The offset to the binary data
  73510. * @param binaryWriter The binary data for the glTF file
  73511. */
  73512. private reorderTriangleFillMode;
  73513. /**
  73514. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  73515. * clock-wise during export to glTF
  73516. * @param submesh BabylonJS submesh
  73517. * @param primitiveMode Primitive mode of the mesh
  73518. * @param sideOrientation the winding order of the submesh
  73519. * @param vertexBufferKind The type of vertex attribute
  73520. * @param meshAttributeArray The vertex attribute data
  73521. * @param byteOffset The offset to the binary data
  73522. * @param binaryWriter The binary data for the glTF file
  73523. */
  73524. private reorderTriangleStripDrawMode;
  73525. /**
  73526. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  73527. * clock-wise during export to glTF
  73528. * @param submesh BabylonJS submesh
  73529. * @param primitiveMode Primitive mode of the mesh
  73530. * @param sideOrientation the winding order of the submesh
  73531. * @param vertexBufferKind The type of vertex attribute
  73532. * @param meshAttributeArray The vertex attribute data
  73533. * @param byteOffset The offset to the binary data
  73534. * @param binaryWriter The binary data for the glTF file
  73535. */
  73536. private reorderTriangleFanMode;
  73537. /**
  73538. * Writes the vertex attribute data to binary
  73539. * @param vertices The vertices to write to the binary writer
  73540. * @param byteOffset The offset into the binary writer to overwrite binary data
  73541. * @param vertexAttributeKind The vertex attribute type
  73542. * @param meshAttributeArray The vertex attribute data
  73543. * @param binaryWriter The writer containing the binary data
  73544. */
  73545. private writeVertexAttributeData;
  73546. /**
  73547. * Writes mesh attribute data to a data buffer
  73548. * Returns the bytelength of the data
  73549. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  73550. * @param meshAttributeArray Array containing the attribute data
  73551. * @param binaryWriter The buffer to write the binary data to
  73552. * @param indices Used to specify the order of the vertex data
  73553. */
  73554. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  73555. /**
  73556. * Generates glTF json data
  73557. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  73558. * @param glTFPrefix Text to use when prefixing a glTF file
  73559. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  73560. * @returns json data as string
  73561. */
  73562. private generateJSON;
  73563. /**
  73564. * Generates data for .gltf and .bin files based on the glTF prefix string
  73565. * @param glTFPrefix Text to use when prefixing a glTF file
  73566. * @param dispose Dispose the exporter
  73567. * @returns GLTFData with glTF file data
  73568. */
  73569. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  73570. /**
  73571. * Creates a binary buffer for glTF
  73572. * @returns array buffer for binary data
  73573. */
  73574. private _generateBinaryAsync;
  73575. /**
  73576. * Pads the number to a multiple of 4
  73577. * @param num number to pad
  73578. * @returns padded number
  73579. */
  73580. private _getPadding;
  73581. /**
  73582. * @hidden
  73583. */
  73584. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  73585. /**
  73586. * Sets the TRS for each node
  73587. * @param node glTF Node for storing the transformation data
  73588. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  73589. */
  73590. private setNodeTransformation;
  73591. private getVertexBufferFromMesh;
  73592. /**
  73593. * Creates a bufferview based on the vertices type for the Babylon mesh
  73594. * @param kind Indicates the type of vertices data
  73595. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  73596. * @param binaryWriter The buffer to write the bufferview data to
  73597. */
  73598. private createBufferViewKind;
  73599. /**
  73600. * The primitive mode of the Babylon mesh
  73601. * @param babylonMesh The BabylonJS mesh
  73602. */
  73603. private getMeshPrimitiveMode;
  73604. /**
  73605. * Sets the primitive mode of the glTF mesh primitive
  73606. * @param meshPrimitive glTF mesh primitive
  73607. * @param primitiveMode The primitive mode
  73608. */
  73609. private setPrimitiveMode;
  73610. /**
  73611. * Sets the vertex attribute accessor based of the glTF mesh primitive
  73612. * @param meshPrimitive glTF mesh primitive
  73613. * @param attributeKind vertex attribute
  73614. * @returns boolean specifying if uv coordinates are present
  73615. */
  73616. private setAttributeKind;
  73617. /**
  73618. * Sets data for the primitive attributes of each submesh
  73619. * @param mesh glTF Mesh object to store the primitive attribute information
  73620. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  73621. * @param binaryWriter Buffer to write the attribute data to
  73622. */
  73623. private setPrimitiveAttributesAsync;
  73624. /**
  73625. * Creates a glTF scene based on the array of meshes
  73626. * Returns the the total byte offset
  73627. * @param babylonScene Babylon scene to get the mesh data from
  73628. * @param binaryWriter Buffer to write binary data to
  73629. */
  73630. private createSceneAsync;
  73631. /**
  73632. * Creates a mapping of Node unique id to node index and handles animations
  73633. * @param babylonScene Babylon Scene
  73634. * @param nodes Babylon transform nodes
  73635. * @param binaryWriter Buffer to write binary data to
  73636. * @returns Node mapping of unique id to index
  73637. */
  73638. private createNodeMapAndAnimationsAsync;
  73639. /**
  73640. * Creates a glTF node from a Babylon mesh
  73641. * @param babylonMesh Source Babylon mesh
  73642. * @param binaryWriter Buffer for storing geometry data
  73643. * @returns glTF node
  73644. */
  73645. private createNodeAsync;
  73646. }
  73647. /**
  73648. * @hidden
  73649. *
  73650. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  73651. */
  73652. export class _BinaryWriter {
  73653. /**
  73654. * Array buffer which stores all binary data
  73655. */
  73656. private _arrayBuffer;
  73657. /**
  73658. * View of the array buffer
  73659. */
  73660. private _dataView;
  73661. /**
  73662. * byte offset of data in array buffer
  73663. */
  73664. private _byteOffset;
  73665. /**
  73666. * Initialize binary writer with an initial byte length
  73667. * @param byteLength Initial byte length of the array buffer
  73668. */
  73669. constructor(byteLength: number);
  73670. /**
  73671. * Resize the array buffer to the specified byte length
  73672. * @param byteLength
  73673. */
  73674. private resizeBuffer;
  73675. /**
  73676. * Get an array buffer with the length of the byte offset
  73677. * @returns ArrayBuffer resized to the byte offset
  73678. */
  73679. getArrayBuffer(): ArrayBuffer;
  73680. /**
  73681. * Get the byte offset of the array buffer
  73682. * @returns byte offset
  73683. */
  73684. getByteOffset(): number;
  73685. /**
  73686. * Stores an UInt8 in the array buffer
  73687. * @param entry
  73688. * @param byteOffset If defined, specifies where to set the value as an offset.
  73689. */
  73690. setUInt8(entry: number, byteOffset?: number): void;
  73691. /**
  73692. * Gets an UInt32 in the array buffer
  73693. * @param entry
  73694. * @param byteOffset If defined, specifies where to set the value as an offset.
  73695. */
  73696. getUInt32(byteOffset: number): number;
  73697. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  73698. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  73699. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  73700. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  73701. /**
  73702. * Stores a Float32 in the array buffer
  73703. * @param entry
  73704. */
  73705. setFloat32(entry: number, byteOffset?: number): void;
  73706. /**
  73707. * Stores an UInt32 in the array buffer
  73708. * @param entry
  73709. * @param byteOffset If defined, specifies where to set the value as an offset.
  73710. */
  73711. setUInt32(entry: number, byteOffset?: number): void;
  73712. }
  73713. }
  73714. declare module BABYLON.GLTF2.Exporter {
  73715. /**
  73716. * @hidden
  73717. * Interface to store animation data.
  73718. */
  73719. export interface _IAnimationData {
  73720. /**
  73721. * Keyframe data.
  73722. */
  73723. inputs: number[];
  73724. /**
  73725. * Value data.
  73726. */
  73727. outputs: number[][];
  73728. /**
  73729. * Animation interpolation data.
  73730. */
  73731. samplerInterpolation: AnimationSamplerInterpolation;
  73732. /**
  73733. * Minimum keyframe value.
  73734. */
  73735. inputsMin: number;
  73736. /**
  73737. * Maximum keyframe value.
  73738. */
  73739. inputsMax: number;
  73740. }
  73741. /**
  73742. * @hidden
  73743. */
  73744. export interface _IAnimationInfo {
  73745. /**
  73746. * The target channel for the animation
  73747. */
  73748. animationChannelTargetPath: AnimationChannelTargetPath;
  73749. /**
  73750. * The glTF accessor type for the data.
  73751. */
  73752. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  73753. /**
  73754. * Specifies if quaternions should be used.
  73755. */
  73756. useQuaternion: boolean;
  73757. }
  73758. /**
  73759. * @hidden
  73760. * Utility class for generating glTF animation data from BabylonJS.
  73761. */
  73762. export class _GLTFAnimation {
  73763. /**
  73764. * @ignore
  73765. *
  73766. * Creates glTF channel animation from BabylonJS animation.
  73767. * @param babylonTransformNode - BabylonJS mesh.
  73768. * @param animation - animation.
  73769. * @param animationChannelTargetPath - The target animation channel.
  73770. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  73771. * @param useQuaternion - Specifies if quaternions are used.
  73772. * @returns nullable IAnimationData
  73773. */
  73774. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  73775. private static _DeduceAnimationInfo;
  73776. /**
  73777. * @ignore
  73778. * Create node animations from the transform node animations
  73779. * @param babylonNode
  73780. * @param runtimeGLTFAnimation
  73781. * @param idleGLTFAnimations
  73782. * @param nodeMap
  73783. * @param nodes
  73784. * @param binaryWriter
  73785. * @param bufferViews
  73786. * @param accessors
  73787. * @param convertToRightHandedSystem
  73788. */
  73789. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  73790. [key: number]: number;
  73791. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  73792. /**
  73793. * @ignore
  73794. * Create node animations from the animation groups
  73795. * @param babylonScene
  73796. * @param glTFAnimations
  73797. * @param nodeMap
  73798. * @param nodes
  73799. * @param binaryWriter
  73800. * @param bufferViews
  73801. * @param accessors
  73802. * @param convertToRightHandedSystem
  73803. */
  73804. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  73805. [key: number]: number;
  73806. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  73807. private static AddAnimation;
  73808. /**
  73809. * Create a baked animation
  73810. * @param babylonTransformNode BabylonJS mesh
  73811. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  73812. * @param animationChannelTargetPath animation target channel
  73813. * @param minFrame minimum animation frame
  73814. * @param maxFrame maximum animation frame
  73815. * @param fps frames per second of the animation
  73816. * @param inputs input key frames of the animation
  73817. * @param outputs output key frame data of the animation
  73818. * @param convertToRightHandedSystem converts the values to right-handed
  73819. * @param useQuaternion specifies if quaternions should be used
  73820. */
  73821. private static _CreateBakedAnimation;
  73822. private static _ConvertFactorToVector3OrQuaternion;
  73823. private static _SetInterpolatedValue;
  73824. /**
  73825. * Creates linear animation from the animation key frames
  73826. * @param babylonTransformNode BabylonJS mesh
  73827. * @param animation BabylonJS animation
  73828. * @param animationChannelTargetPath The target animation channel
  73829. * @param frameDelta The difference between the last and first frame of the animation
  73830. * @param inputs Array to store the key frame times
  73831. * @param outputs Array to store the key frame data
  73832. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  73833. * @param useQuaternion Specifies if quaternions are used in the animation
  73834. */
  73835. private static _CreateLinearOrStepAnimation;
  73836. /**
  73837. * Creates cubic spline animation from the animation key frames
  73838. * @param babylonTransformNode BabylonJS mesh
  73839. * @param animation BabylonJS animation
  73840. * @param animationChannelTargetPath The target animation channel
  73841. * @param frameDelta The difference between the last and first frame of the animation
  73842. * @param inputs Array to store the key frame times
  73843. * @param outputs Array to store the key frame data
  73844. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  73845. * @param useQuaternion Specifies if quaternions are used in the animation
  73846. */
  73847. private static _CreateCubicSplineAnimation;
  73848. private static _GetBasePositionRotationOrScale;
  73849. /**
  73850. * Adds a key frame value
  73851. * @param keyFrame
  73852. * @param animation
  73853. * @param outputs
  73854. * @param animationChannelTargetPath
  73855. * @param basePositionRotationOrScale
  73856. * @param convertToRightHandedSystem
  73857. * @param useQuaternion
  73858. */
  73859. private static _AddKeyframeValue;
  73860. /**
  73861. * Determine the interpolation based on the key frames
  73862. * @param keyFrames
  73863. * @param animationChannelTargetPath
  73864. * @param useQuaternion
  73865. */
  73866. private static _DeduceInterpolation;
  73867. /**
  73868. * Adds an input tangent or output tangent to the output data
  73869. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  73870. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  73871. * @param outputs The animation data by keyframe
  73872. * @param animationChannelTargetPath The target animation channel
  73873. * @param interpolation The interpolation type
  73874. * @param keyFrame The key frame with the animation data
  73875. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  73876. * @param useQuaternion Specifies if quaternions are used
  73877. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  73878. */
  73879. private static AddSplineTangent;
  73880. /**
  73881. * Get the minimum and maximum key frames' frame values
  73882. * @param keyFrames animation key frames
  73883. * @returns the minimum and maximum key frame value
  73884. */
  73885. private static calculateMinMaxKeyFrames;
  73886. }
  73887. }
  73888. declare module BABYLON.GLTF2.Exporter {
  73889. /** @hidden */
  73890. export var textureTransformPixelShader: {
  73891. name: string;
  73892. shader: string;
  73893. };
  73894. }
  73895. declare module BABYLON.GLTF2.Exporter.Extensions {
  73896. /**
  73897. * @hidden
  73898. */
  73899. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  73900. private _recordedTextures;
  73901. /** Name of this extension */
  73902. readonly name: string;
  73903. /** Defines whether this extension is enabled */
  73904. enabled: boolean;
  73905. /** Defines whether this extension is required */
  73906. required: boolean;
  73907. /** Reference to the glTF exporter */
  73908. private _wasUsed;
  73909. constructor(exporter: _Exporter);
  73910. dispose(): void;
  73911. /** @hidden */
  73912. readonly wasUsed: boolean;
  73913. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  73914. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  73915. /**
  73916. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  73917. * @param babylonTexture
  73918. * @param offset
  73919. * @param rotation
  73920. * @param scale
  73921. * @param scene
  73922. */
  73923. private _textureTransformTextureAsync;
  73924. }
  73925. }
  73926. declare module BABYLON.GLTF2.Exporter.Extensions {
  73927. /**
  73928. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  73929. */
  73930. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  73931. /** The name of this extension. */
  73932. readonly name: string;
  73933. /** Defines whether this extension is enabled. */
  73934. enabled: boolean;
  73935. /** Defines whether this extension is required */
  73936. required: boolean;
  73937. /** Reference to the glTF exporter */
  73938. private _exporter;
  73939. private _lights;
  73940. /** @hidden */
  73941. constructor(exporter: _Exporter);
  73942. /** @hidden */
  73943. dispose(): void;
  73944. /** @hidden */
  73945. readonly wasUsed: boolean;
  73946. /** @hidden */
  73947. onExporting(): void;
  73948. /**
  73949. * Define this method to modify the default behavior when exporting a node
  73950. * @param context The context when exporting the node
  73951. * @param node glTF node
  73952. * @param babylonNode BabylonJS node
  73953. * @returns nullable INode promise
  73954. */
  73955. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  73956. }
  73957. }
  73958. declare module BABYLON.GLTF2.Exporter.Extensions {
  73959. /**
  73960. * @hidden
  73961. */
  73962. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  73963. /** Name of this extension */
  73964. readonly name: string;
  73965. /** Defines whether this extension is enabled */
  73966. enabled: boolean;
  73967. /** Defines whether this extension is required */
  73968. required: boolean;
  73969. /** Reference to the glTF exporter */
  73970. private _textureInfos;
  73971. private _exportedTextures;
  73972. private _wasUsed;
  73973. constructor(exporter: _Exporter);
  73974. dispose(): void;
  73975. /** @hidden */
  73976. readonly wasUsed: boolean;
  73977. private _getTextureIndex;
  73978. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  73979. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  73980. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  73981. }
  73982. }
  73983. declare module BABYLON {
  73984. /**
  73985. * Class for generating STL data from a Babylon scene.
  73986. */
  73987. export class STLExport {
  73988. /**
  73989. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  73990. * @param meshes list defines the mesh to serialize
  73991. * @param download triggers the automatic download of the file.
  73992. * @param fileName changes the downloads fileName.
  73993. * @param binary changes the STL to a binary type.
  73994. * @param isLittleEndian toggle for binary type exporter.
  73995. * @returns the STL as UTF8 string
  73996. */
  73997. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  73998. }
  73999. }
  74000. declare module "babylonjs-gltf2interface" {
  74001. export = BABYLON.GLTF2;
  74002. }
  74003. /**
  74004. * Module for glTF 2.0 Interface
  74005. */
  74006. declare module BABYLON.GLTF2 {
  74007. /**
  74008. * The datatype of the components in the attribute
  74009. */
  74010. const enum AccessorComponentType {
  74011. /**
  74012. * Byte
  74013. */
  74014. BYTE = 5120,
  74015. /**
  74016. * Unsigned Byte
  74017. */
  74018. UNSIGNED_BYTE = 5121,
  74019. /**
  74020. * Short
  74021. */
  74022. SHORT = 5122,
  74023. /**
  74024. * Unsigned Short
  74025. */
  74026. UNSIGNED_SHORT = 5123,
  74027. /**
  74028. * Unsigned Int
  74029. */
  74030. UNSIGNED_INT = 5125,
  74031. /**
  74032. * Float
  74033. */
  74034. FLOAT = 5126,
  74035. }
  74036. /**
  74037. * Specifies if the attirbute is a scalar, vector, or matrix
  74038. */
  74039. const enum AccessorType {
  74040. /**
  74041. * Scalar
  74042. */
  74043. SCALAR = "SCALAR",
  74044. /**
  74045. * Vector2
  74046. */
  74047. VEC2 = "VEC2",
  74048. /**
  74049. * Vector3
  74050. */
  74051. VEC3 = "VEC3",
  74052. /**
  74053. * Vector4
  74054. */
  74055. VEC4 = "VEC4",
  74056. /**
  74057. * Matrix2x2
  74058. */
  74059. MAT2 = "MAT2",
  74060. /**
  74061. * Matrix3x3
  74062. */
  74063. MAT3 = "MAT3",
  74064. /**
  74065. * Matrix4x4
  74066. */
  74067. MAT4 = "MAT4",
  74068. }
  74069. /**
  74070. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  74071. */
  74072. const enum AnimationChannelTargetPath {
  74073. /**
  74074. * Translation
  74075. */
  74076. TRANSLATION = "translation",
  74077. /**
  74078. * Rotation
  74079. */
  74080. ROTATION = "rotation",
  74081. /**
  74082. * Scale
  74083. */
  74084. SCALE = "scale",
  74085. /**
  74086. * Weights
  74087. */
  74088. WEIGHTS = "weights",
  74089. }
  74090. /**
  74091. * Interpolation algorithm
  74092. */
  74093. const enum AnimationSamplerInterpolation {
  74094. /**
  74095. * The animated values are linearly interpolated between keyframes
  74096. */
  74097. LINEAR = "LINEAR",
  74098. /**
  74099. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  74100. */
  74101. STEP = "STEP",
  74102. /**
  74103. * The animation's interpolation is computed using a cubic spline with specified tangents
  74104. */
  74105. CUBICSPLINE = "CUBICSPLINE",
  74106. }
  74107. /**
  74108. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  74109. */
  74110. const enum CameraType {
  74111. /**
  74112. * A perspective camera containing properties to create a perspective projection matrix
  74113. */
  74114. PERSPECTIVE = "perspective",
  74115. /**
  74116. * An orthographic camera containing properties to create an orthographic projection matrix
  74117. */
  74118. ORTHOGRAPHIC = "orthographic",
  74119. }
  74120. /**
  74121. * The mime-type of the image
  74122. */
  74123. const enum ImageMimeType {
  74124. /**
  74125. * JPEG Mime-type
  74126. */
  74127. JPEG = "image/jpeg",
  74128. /**
  74129. * PNG Mime-type
  74130. */
  74131. PNG = "image/png",
  74132. }
  74133. /**
  74134. * The alpha rendering mode of the material
  74135. */
  74136. const enum MaterialAlphaMode {
  74137. /**
  74138. * The alpha value is ignored and the rendered output is fully opaque
  74139. */
  74140. OPAQUE = "OPAQUE",
  74141. /**
  74142. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  74143. */
  74144. MASK = "MASK",
  74145. /**
  74146. * 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)
  74147. */
  74148. BLEND = "BLEND",
  74149. }
  74150. /**
  74151. * The type of the primitives to render
  74152. */
  74153. const enum MeshPrimitiveMode {
  74154. /**
  74155. * Points
  74156. */
  74157. POINTS = 0,
  74158. /**
  74159. * Lines
  74160. */
  74161. LINES = 1,
  74162. /**
  74163. * Line Loop
  74164. */
  74165. LINE_LOOP = 2,
  74166. /**
  74167. * Line Strip
  74168. */
  74169. LINE_STRIP = 3,
  74170. /**
  74171. * Triangles
  74172. */
  74173. TRIANGLES = 4,
  74174. /**
  74175. * Triangle Strip
  74176. */
  74177. TRIANGLE_STRIP = 5,
  74178. /**
  74179. * Triangle Fan
  74180. */
  74181. TRIANGLE_FAN = 6,
  74182. }
  74183. /**
  74184. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  74185. */
  74186. const enum TextureMagFilter {
  74187. /**
  74188. * Nearest
  74189. */
  74190. NEAREST = 9728,
  74191. /**
  74192. * Linear
  74193. */
  74194. LINEAR = 9729,
  74195. }
  74196. /**
  74197. * Minification filter. All valid values correspond to WebGL enums
  74198. */
  74199. const enum TextureMinFilter {
  74200. /**
  74201. * Nearest
  74202. */
  74203. NEAREST = 9728,
  74204. /**
  74205. * Linear
  74206. */
  74207. LINEAR = 9729,
  74208. /**
  74209. * Nearest Mip-Map Nearest
  74210. */
  74211. NEAREST_MIPMAP_NEAREST = 9984,
  74212. /**
  74213. * Linear Mipmap Nearest
  74214. */
  74215. LINEAR_MIPMAP_NEAREST = 9985,
  74216. /**
  74217. * Nearest Mipmap Linear
  74218. */
  74219. NEAREST_MIPMAP_LINEAR = 9986,
  74220. /**
  74221. * Linear Mipmap Linear
  74222. */
  74223. LINEAR_MIPMAP_LINEAR = 9987,
  74224. }
  74225. /**
  74226. * S (U) wrapping mode. All valid values correspond to WebGL enums
  74227. */
  74228. const enum TextureWrapMode {
  74229. /**
  74230. * Clamp to Edge
  74231. */
  74232. CLAMP_TO_EDGE = 33071,
  74233. /**
  74234. * Mirrored Repeat
  74235. */
  74236. MIRRORED_REPEAT = 33648,
  74237. /**
  74238. * Repeat
  74239. */
  74240. REPEAT = 10497,
  74241. }
  74242. /**
  74243. * glTF Property
  74244. */
  74245. interface IProperty {
  74246. /**
  74247. * Dictionary object with extension-specific objects
  74248. */
  74249. extensions?: {
  74250. [key: string]: any;
  74251. };
  74252. /**
  74253. * Application-Specific data
  74254. */
  74255. extras?: any;
  74256. }
  74257. /**
  74258. * glTF Child of Root Property
  74259. */
  74260. interface IChildRootProperty extends IProperty {
  74261. /**
  74262. * The user-defined name of this object
  74263. */
  74264. name?: string;
  74265. }
  74266. /**
  74267. * Indices of those attributes that deviate from their initialization value
  74268. */
  74269. interface IAccessorSparseIndices extends IProperty {
  74270. /**
  74271. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  74272. */
  74273. bufferView: number;
  74274. /**
  74275. * The offset relative to the start of the bufferView in bytes. Must be aligned
  74276. */
  74277. byteOffset?: number;
  74278. /**
  74279. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  74280. */
  74281. componentType: AccessorComponentType;
  74282. }
  74283. /**
  74284. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  74285. */
  74286. interface IAccessorSparseValues extends IProperty {
  74287. /**
  74288. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  74289. */
  74290. bufferView: number;
  74291. /**
  74292. * The offset relative to the start of the bufferView in bytes. Must be aligned
  74293. */
  74294. byteOffset?: number;
  74295. }
  74296. /**
  74297. * Sparse storage of attributes that deviate from their initialization value
  74298. */
  74299. interface IAccessorSparse extends IProperty {
  74300. /**
  74301. * The number of attributes encoded in this sparse accessor
  74302. */
  74303. count: number;
  74304. /**
  74305. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  74306. */
  74307. indices: IAccessorSparseIndices;
  74308. /**
  74309. * 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
  74310. */
  74311. values: IAccessorSparseValues;
  74312. }
  74313. /**
  74314. * 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
  74315. */
  74316. interface IAccessor extends IChildRootProperty {
  74317. /**
  74318. * The index of the bufferview
  74319. */
  74320. bufferView?: number;
  74321. /**
  74322. * The offset relative to the start of the bufferView in bytes
  74323. */
  74324. byteOffset?: number;
  74325. /**
  74326. * The datatype of components in the attribute
  74327. */
  74328. componentType: AccessorComponentType;
  74329. /**
  74330. * Specifies whether integer data values should be normalized
  74331. */
  74332. normalized?: boolean;
  74333. /**
  74334. * The number of attributes referenced by this accessor
  74335. */
  74336. count: number;
  74337. /**
  74338. * Specifies if the attribute is a scalar, vector, or matrix
  74339. */
  74340. type: AccessorType;
  74341. /**
  74342. * Maximum value of each component in this attribute
  74343. */
  74344. max?: number[];
  74345. /**
  74346. * Minimum value of each component in this attribute
  74347. */
  74348. min?: number[];
  74349. /**
  74350. * Sparse storage of attributes that deviate from their initialization value
  74351. */
  74352. sparse?: IAccessorSparse;
  74353. }
  74354. /**
  74355. * Targets an animation's sampler at a node's property
  74356. */
  74357. interface IAnimationChannel extends IProperty {
  74358. /**
  74359. * The index of a sampler in this animation used to compute the value for the target
  74360. */
  74361. sampler: number;
  74362. /**
  74363. * The index of the node and TRS property to target
  74364. */
  74365. target: IAnimationChannelTarget;
  74366. }
  74367. /**
  74368. * The index of the node and TRS property that an animation channel targets
  74369. */
  74370. interface IAnimationChannelTarget extends IProperty {
  74371. /**
  74372. * The index of the node to target
  74373. */
  74374. node: number;
  74375. /**
  74376. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  74377. */
  74378. path: AnimationChannelTargetPath;
  74379. }
  74380. /**
  74381. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  74382. */
  74383. interface IAnimationSampler extends IProperty {
  74384. /**
  74385. * The index of an accessor containing keyframe input values, e.g., time
  74386. */
  74387. input: number;
  74388. /**
  74389. * Interpolation algorithm
  74390. */
  74391. interpolation?: AnimationSamplerInterpolation;
  74392. /**
  74393. * The index of an accessor, containing keyframe output values
  74394. */
  74395. output: number;
  74396. }
  74397. /**
  74398. * A keyframe animation
  74399. */
  74400. interface IAnimation extends IChildRootProperty {
  74401. /**
  74402. * An array of channels, each of which targets an animation's sampler at a node's property
  74403. */
  74404. channels: IAnimationChannel[];
  74405. /**
  74406. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  74407. */
  74408. samplers: IAnimationSampler[];
  74409. }
  74410. /**
  74411. * Metadata about the glTF asset
  74412. */
  74413. interface IAsset extends IChildRootProperty {
  74414. /**
  74415. * A copyright message suitable for display to credit the content creator
  74416. */
  74417. copyright?: string;
  74418. /**
  74419. * Tool that generated this glTF model. Useful for debugging
  74420. */
  74421. generator?: string;
  74422. /**
  74423. * The glTF version that this asset targets
  74424. */
  74425. version: string;
  74426. /**
  74427. * The minimum glTF version that this asset targets
  74428. */
  74429. minVersion?: string;
  74430. }
  74431. /**
  74432. * A buffer points to binary geometry, animation, or skins
  74433. */
  74434. interface IBuffer extends IChildRootProperty {
  74435. /**
  74436. * 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
  74437. */
  74438. uri?: string;
  74439. /**
  74440. * The length of the buffer in bytes
  74441. */
  74442. byteLength: number;
  74443. }
  74444. /**
  74445. * A view into a buffer generally representing a subset of the buffer
  74446. */
  74447. interface IBufferView extends IChildRootProperty {
  74448. /**
  74449. * The index of the buffer
  74450. */
  74451. buffer: number;
  74452. /**
  74453. * The offset into the buffer in bytes
  74454. */
  74455. byteOffset?: number;
  74456. /**
  74457. * The lenth of the bufferView in bytes
  74458. */
  74459. byteLength: number;
  74460. /**
  74461. * The stride, in bytes
  74462. */
  74463. byteStride?: number;
  74464. }
  74465. /**
  74466. * An orthographic camera containing properties to create an orthographic projection matrix
  74467. */
  74468. interface ICameraOrthographic extends IProperty {
  74469. /**
  74470. * The floating-point horizontal magnification of the view. Must not be zero
  74471. */
  74472. xmag: number;
  74473. /**
  74474. * The floating-point vertical magnification of the view. Must not be zero
  74475. */
  74476. ymag: number;
  74477. /**
  74478. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  74479. */
  74480. zfar: number;
  74481. /**
  74482. * The floating-point distance to the near clipping plane
  74483. */
  74484. znear: number;
  74485. }
  74486. /**
  74487. * A perspective camera containing properties to create a perspective projection matrix
  74488. */
  74489. interface ICameraPerspective extends IProperty {
  74490. /**
  74491. * The floating-point aspect ratio of the field of view
  74492. */
  74493. aspectRatio?: number;
  74494. /**
  74495. * The floating-point vertical field of view in radians
  74496. */
  74497. yfov: number;
  74498. /**
  74499. * The floating-point distance to the far clipping plane
  74500. */
  74501. zfar?: number;
  74502. /**
  74503. * The floating-point distance to the near clipping plane
  74504. */
  74505. znear: number;
  74506. }
  74507. /**
  74508. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  74509. */
  74510. interface ICamera extends IChildRootProperty {
  74511. /**
  74512. * An orthographic camera containing properties to create an orthographic projection matrix
  74513. */
  74514. orthographic?: ICameraOrthographic;
  74515. /**
  74516. * A perspective camera containing properties to create a perspective projection matrix
  74517. */
  74518. perspective?: ICameraPerspective;
  74519. /**
  74520. * Specifies if the camera uses a perspective or orthographic projection
  74521. */
  74522. type: CameraType;
  74523. }
  74524. /**
  74525. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  74526. */
  74527. interface IImage extends IChildRootProperty {
  74528. /**
  74529. * 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
  74530. */
  74531. uri?: string;
  74532. /**
  74533. * The image's MIME type
  74534. */
  74535. mimeType?: ImageMimeType;
  74536. /**
  74537. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  74538. */
  74539. bufferView?: number;
  74540. }
  74541. /**
  74542. * Material Normal Texture Info
  74543. */
  74544. interface IMaterialNormalTextureInfo extends ITextureInfo {
  74545. /**
  74546. * The scalar multiplier applied to each normal vector of the normal texture
  74547. */
  74548. scale?: number;
  74549. }
  74550. /**
  74551. * Material Occlusion Texture Info
  74552. */
  74553. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  74554. /**
  74555. * A scalar multiplier controlling the amount of occlusion applied
  74556. */
  74557. strength?: number;
  74558. }
  74559. /**
  74560. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  74561. */
  74562. interface IMaterialPbrMetallicRoughness {
  74563. /**
  74564. * The material's base color factor
  74565. */
  74566. baseColorFactor?: number[];
  74567. /**
  74568. * The base color texture
  74569. */
  74570. baseColorTexture?: ITextureInfo;
  74571. /**
  74572. * The metalness of the material
  74573. */
  74574. metallicFactor?: number;
  74575. /**
  74576. * The roughness of the material
  74577. */
  74578. roughnessFactor?: number;
  74579. /**
  74580. * The metallic-roughness texture
  74581. */
  74582. metallicRoughnessTexture?: ITextureInfo;
  74583. }
  74584. /**
  74585. * The material appearance of a primitive
  74586. */
  74587. interface IMaterial extends IChildRootProperty {
  74588. /**
  74589. * 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
  74590. */
  74591. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  74592. /**
  74593. * The normal map texture
  74594. */
  74595. normalTexture?: IMaterialNormalTextureInfo;
  74596. /**
  74597. * The occlusion map texture
  74598. */
  74599. occlusionTexture?: IMaterialOcclusionTextureInfo;
  74600. /**
  74601. * The emissive map texture
  74602. */
  74603. emissiveTexture?: ITextureInfo;
  74604. /**
  74605. * 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
  74606. */
  74607. emissiveFactor?: number[];
  74608. /**
  74609. * The alpha rendering mode of the material
  74610. */
  74611. alphaMode?: MaterialAlphaMode;
  74612. /**
  74613. * The alpha cutoff value of the material
  74614. */
  74615. alphaCutoff?: number;
  74616. /**
  74617. * Specifies whether the material is double sided
  74618. */
  74619. doubleSided?: boolean;
  74620. }
  74621. /**
  74622. * Geometry to be rendered with the given material
  74623. */
  74624. interface IMeshPrimitive extends IProperty {
  74625. /**
  74626. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  74627. */
  74628. attributes: {
  74629. [name: string]: number;
  74630. };
  74631. /**
  74632. * The index of the accessor that contains the indices
  74633. */
  74634. indices?: number;
  74635. /**
  74636. * The index of the material to apply to this primitive when rendering
  74637. */
  74638. material?: number;
  74639. /**
  74640. * The type of primitives to render. All valid values correspond to WebGL enums
  74641. */
  74642. mode?: MeshPrimitiveMode;
  74643. /**
  74644. * 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
  74645. */
  74646. targets?: {
  74647. [name: string]: number;
  74648. }[];
  74649. }
  74650. /**
  74651. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  74652. */
  74653. interface IMesh extends IChildRootProperty {
  74654. /**
  74655. * An array of primitives, each defining geometry to be rendered with a material
  74656. */
  74657. primitives: IMeshPrimitive[];
  74658. /**
  74659. * Array of weights to be applied to the Morph Targets
  74660. */
  74661. weights?: number[];
  74662. }
  74663. /**
  74664. * A node in the node hierarchy
  74665. */
  74666. interface INode extends IChildRootProperty {
  74667. /**
  74668. * The index of the camera referenced by this node
  74669. */
  74670. camera?: number;
  74671. /**
  74672. * The indices of this node's children
  74673. */
  74674. children?: number[];
  74675. /**
  74676. * The index of the skin referenced by this node
  74677. */
  74678. skin?: number;
  74679. /**
  74680. * A floating-point 4x4 transformation matrix stored in column-major order
  74681. */
  74682. matrix?: number[];
  74683. /**
  74684. * The index of the mesh in this node
  74685. */
  74686. mesh?: number;
  74687. /**
  74688. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  74689. */
  74690. rotation?: number[];
  74691. /**
  74692. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  74693. */
  74694. scale?: number[];
  74695. /**
  74696. * The node's translation along the x, y, and z axes
  74697. */
  74698. translation?: number[];
  74699. /**
  74700. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  74701. */
  74702. weights?: number[];
  74703. }
  74704. /**
  74705. * Texture sampler properties for filtering and wrapping modes
  74706. */
  74707. interface ISampler extends IChildRootProperty {
  74708. /**
  74709. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  74710. */
  74711. magFilter?: TextureMagFilter;
  74712. /**
  74713. * Minification filter. All valid values correspond to WebGL enums
  74714. */
  74715. minFilter?: TextureMinFilter;
  74716. /**
  74717. * S (U) wrapping mode. All valid values correspond to WebGL enums
  74718. */
  74719. wrapS?: TextureWrapMode;
  74720. /**
  74721. * T (V) wrapping mode. All valid values correspond to WebGL enums
  74722. */
  74723. wrapT?: TextureWrapMode;
  74724. }
  74725. /**
  74726. * The root nodes of a scene
  74727. */
  74728. interface IScene extends IChildRootProperty {
  74729. /**
  74730. * The indices of each root node
  74731. */
  74732. nodes: number[];
  74733. }
  74734. /**
  74735. * Joints and matrices defining a skin
  74736. */
  74737. interface ISkin extends IChildRootProperty {
  74738. /**
  74739. * 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
  74740. */
  74741. inverseBindMatrices?: number;
  74742. /**
  74743. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  74744. */
  74745. skeleton?: number;
  74746. /**
  74747. * 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)
  74748. */
  74749. joints: number[];
  74750. }
  74751. /**
  74752. * A texture and its sampler
  74753. */
  74754. interface ITexture extends IChildRootProperty {
  74755. /**
  74756. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  74757. */
  74758. sampler?: number;
  74759. /**
  74760. * The index of the image used by this texture
  74761. */
  74762. source: number;
  74763. }
  74764. /**
  74765. * Reference to a texture
  74766. */
  74767. interface ITextureInfo extends IProperty {
  74768. /**
  74769. * The index of the texture
  74770. */
  74771. index: number;
  74772. /**
  74773. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  74774. */
  74775. texCoord?: number;
  74776. }
  74777. /**
  74778. * The root object for a glTF asset
  74779. */
  74780. interface IGLTF extends IProperty {
  74781. /**
  74782. * An array of accessors. An accessor is a typed view into a bufferView
  74783. */
  74784. accessors?: IAccessor[];
  74785. /**
  74786. * An array of keyframe animations
  74787. */
  74788. animations?: IAnimation[];
  74789. /**
  74790. * Metadata about the glTF asset
  74791. */
  74792. asset: IAsset;
  74793. /**
  74794. * An array of buffers. A buffer points to binary geometry, animation, or skins
  74795. */
  74796. buffers?: IBuffer[];
  74797. /**
  74798. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  74799. */
  74800. bufferViews?: IBufferView[];
  74801. /**
  74802. * An array of cameras
  74803. */
  74804. cameras?: ICamera[];
  74805. /**
  74806. * Names of glTF extensions used somewhere in this asset
  74807. */
  74808. extensionsUsed?: string[];
  74809. /**
  74810. * Names of glTF extensions required to properly load this asset
  74811. */
  74812. extensionsRequired?: string[];
  74813. /**
  74814. * An array of images. An image defines data used to create a texture
  74815. */
  74816. images?: IImage[];
  74817. /**
  74818. * An array of materials. A material defines the appearance of a primitive
  74819. */
  74820. materials?: IMaterial[];
  74821. /**
  74822. * An array of meshes. A mesh is a set of primitives to be rendered
  74823. */
  74824. meshes?: IMesh[];
  74825. /**
  74826. * An array of nodes
  74827. */
  74828. nodes?: INode[];
  74829. /**
  74830. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  74831. */
  74832. samplers?: ISampler[];
  74833. /**
  74834. * The index of the default scene
  74835. */
  74836. scene?: number;
  74837. /**
  74838. * An array of scenes
  74839. */
  74840. scenes?: IScene[];
  74841. /**
  74842. * An array of skins. A skin is defined by joints and matrices
  74843. */
  74844. skins?: ISkin[];
  74845. /**
  74846. * An array of textures
  74847. */
  74848. textures?: ITexture[];
  74849. }
  74850. /**
  74851. * The glTF validation results
  74852. * @ignore
  74853. */
  74854. interface IGLTFValidationResults {
  74855. info: {
  74856. generator: string;
  74857. hasAnimations: boolean;
  74858. hasDefaultScene: boolean;
  74859. hasMaterials: boolean;
  74860. hasMorphTargets: boolean;
  74861. hasSkins: boolean;
  74862. hasTextures: boolean;
  74863. maxAttributesUsed: number;
  74864. primitivesCount: number
  74865. };
  74866. issues: {
  74867. messages: Array<string>;
  74868. numErrors: number;
  74869. numHints: number;
  74870. numInfos: number;
  74871. numWarnings: number;
  74872. truncated: boolean
  74873. };
  74874. mimeType: string;
  74875. uri: string;
  74876. validatedAt: string;
  74877. validatorVersion: string;
  74878. }
  74879. /**
  74880. * The glTF validation options
  74881. */
  74882. interface IGLTFValidationOptions {
  74883. /** Uri to use */
  74884. uri?: string;
  74885. /** Function used to load external resources */
  74886. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  74887. /** Boolean indicating that we need to validate accessor data */
  74888. validateAccessorData?: boolean;
  74889. /** max number of issues allowed */
  74890. maxIssues?: number;
  74891. /** Ignored issues */
  74892. ignoredIssues?: Array<string>;
  74893. /** Value to override severy settings */
  74894. severityOverrides?: Object;
  74895. }
  74896. /**
  74897. * The glTF validator object
  74898. * @ignore
  74899. */
  74900. interface IGLTFValidator {
  74901. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  74902. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  74903. }
  74904. }
  74905. declare module BABYLON {
  74906. /** @hidden */
  74907. export var cellPixelShader: {
  74908. name: string;
  74909. shader: string;
  74910. };
  74911. }
  74912. declare module BABYLON {
  74913. /** @hidden */
  74914. export var cellVertexShader: {
  74915. name: string;
  74916. shader: string;
  74917. };
  74918. }
  74919. declare module BABYLON {
  74920. export class CellMaterial extends BABYLON.PushMaterial {
  74921. private _diffuseTexture;
  74922. diffuseTexture: BABYLON.BaseTexture;
  74923. diffuseColor: BABYLON.Color3;
  74924. _computeHighLevel: boolean;
  74925. computeHighLevel: boolean;
  74926. private _disableLighting;
  74927. disableLighting: boolean;
  74928. private _maxSimultaneousLights;
  74929. maxSimultaneousLights: number;
  74930. private _renderId;
  74931. constructor(name: string, scene: BABYLON.Scene);
  74932. needAlphaBlending(): boolean;
  74933. needAlphaTesting(): boolean;
  74934. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74935. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74936. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74937. getAnimatables(): BABYLON.IAnimatable[];
  74938. getActiveTextures(): BABYLON.BaseTexture[];
  74939. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74940. dispose(forceDisposeEffect?: boolean): void;
  74941. getClassName(): string;
  74942. clone(name: string): CellMaterial;
  74943. serialize(): any;
  74944. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  74945. }
  74946. }
  74947. declare module BABYLON {
  74948. export class CustomShaderStructure {
  74949. FragmentStore: string;
  74950. VertexStore: string;
  74951. constructor();
  74952. }
  74953. export class ShaderSpecialParts {
  74954. constructor();
  74955. Fragment_Begin: string;
  74956. Fragment_Definitions: string;
  74957. Fragment_MainBegin: string;
  74958. Fragment_Custom_Diffuse: string;
  74959. Fragment_Before_Lights: string;
  74960. Fragment_Before_Fog: string;
  74961. Fragment_Custom_Alpha: string;
  74962. Fragment_Before_FragColor: string;
  74963. Vertex_Begin: string;
  74964. Vertex_Definitions: string;
  74965. Vertex_MainBegin: string;
  74966. Vertex_Before_PositionUpdated: string;
  74967. Vertex_Before_NormalUpdated: string;
  74968. Vertex_MainEnd: string;
  74969. }
  74970. export class CustomMaterial extends BABYLON.StandardMaterial {
  74971. static ShaderIndexer: number;
  74972. CustomParts: ShaderSpecialParts;
  74973. _isCreatedShader: boolean;
  74974. _createdShaderName: string;
  74975. _customUniform: string[];
  74976. _newUniforms: string[];
  74977. _newUniformInstances: any[];
  74978. _newSamplerInstances: BABYLON.Texture[];
  74979. FragmentShader: string;
  74980. VertexShader: string;
  74981. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  74982. ReviewUniform(name: string, arr: string[]): string[];
  74983. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  74984. constructor(name: string, scene: BABYLON.Scene);
  74985. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  74986. Fragment_Begin(shaderPart: string): CustomMaterial;
  74987. Fragment_Definitions(shaderPart: string): CustomMaterial;
  74988. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  74989. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  74990. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  74991. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  74992. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  74993. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  74994. Vertex_Begin(shaderPart: string): CustomMaterial;
  74995. Vertex_Definitions(shaderPart: string): CustomMaterial;
  74996. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  74997. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  74998. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  74999. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  75000. }
  75001. }
  75002. declare module BABYLON {
  75003. export class ShaderAlebdoParts {
  75004. constructor();
  75005. Fragment_Begin: string;
  75006. Fragment_Definitions: string;
  75007. Fragment_MainBegin: string;
  75008. Fragment_Custom_Albedo: string;
  75009. Fragment_Before_Lights: string;
  75010. Fragment_Custom_MetallicRoughness: string;
  75011. Fragment_Custom_MicroSurface: string;
  75012. Fragment_Before_Fog: string;
  75013. Fragment_Custom_Alpha: string;
  75014. Fragment_Before_FragColor: string;
  75015. Vertex_Begin: string;
  75016. Vertex_Definitions: string;
  75017. Vertex_MainBegin: string;
  75018. Vertex_Before_PositionUpdated: string;
  75019. Vertex_Before_NormalUpdated: string;
  75020. Vertex_MainEnd: string;
  75021. }
  75022. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  75023. static ShaderIndexer: number;
  75024. CustomParts: ShaderAlebdoParts;
  75025. _isCreatedShader: boolean;
  75026. _createdShaderName: string;
  75027. _customUniform: string[];
  75028. _newUniforms: string[];
  75029. _newUniformInstances: any[];
  75030. _newSamplerInstances: BABYLON.Texture[];
  75031. FragmentShader: string;
  75032. VertexShader: string;
  75033. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75034. ReviewUniform(name: string, arr: string[]): string[];
  75035. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  75036. constructor(name: string, scene: BABYLON.Scene);
  75037. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  75038. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  75039. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  75040. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  75041. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  75042. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  75043. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  75044. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  75045. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  75046. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  75047. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  75048. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  75049. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  75050. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  75051. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  75052. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  75053. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  75054. }
  75055. }
  75056. declare module BABYLON {
  75057. /** @hidden */
  75058. export var firePixelShader: {
  75059. name: string;
  75060. shader: string;
  75061. };
  75062. }
  75063. declare module BABYLON {
  75064. /** @hidden */
  75065. export var fireVertexShader: {
  75066. name: string;
  75067. shader: string;
  75068. };
  75069. }
  75070. declare module BABYLON {
  75071. export class FireMaterial extends BABYLON.PushMaterial {
  75072. private _diffuseTexture;
  75073. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75074. private _distortionTexture;
  75075. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75076. private _opacityTexture;
  75077. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75078. diffuseColor: BABYLON.Color3;
  75079. speed: number;
  75080. private _scaledDiffuse;
  75081. private _renderId;
  75082. private _lastTime;
  75083. constructor(name: string, scene: BABYLON.Scene);
  75084. needAlphaBlending(): boolean;
  75085. needAlphaTesting(): boolean;
  75086. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75087. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75088. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75089. getAnimatables(): BABYLON.IAnimatable[];
  75090. getActiveTextures(): BABYLON.BaseTexture[];
  75091. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75092. getClassName(): string;
  75093. dispose(forceDisposeEffect?: boolean): void;
  75094. clone(name: string): FireMaterial;
  75095. serialize(): any;
  75096. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  75097. }
  75098. }
  75099. declare module BABYLON {
  75100. /** @hidden */
  75101. export var furPixelShader: {
  75102. name: string;
  75103. shader: string;
  75104. };
  75105. }
  75106. declare module BABYLON {
  75107. /** @hidden */
  75108. export var furVertexShader: {
  75109. name: string;
  75110. shader: string;
  75111. };
  75112. }
  75113. declare module BABYLON {
  75114. export class FurMaterial extends BABYLON.PushMaterial {
  75115. private _diffuseTexture;
  75116. diffuseTexture: BABYLON.BaseTexture;
  75117. private _heightTexture;
  75118. heightTexture: BABYLON.BaseTexture;
  75119. diffuseColor: BABYLON.Color3;
  75120. furLength: number;
  75121. furAngle: number;
  75122. furColor: BABYLON.Color3;
  75123. furOffset: number;
  75124. furSpacing: number;
  75125. furGravity: BABYLON.Vector3;
  75126. furSpeed: number;
  75127. furDensity: number;
  75128. furOcclusion: number;
  75129. furTexture: BABYLON.DynamicTexture;
  75130. private _disableLighting;
  75131. disableLighting: boolean;
  75132. private _maxSimultaneousLights;
  75133. maxSimultaneousLights: number;
  75134. highLevelFur: boolean;
  75135. _meshes: BABYLON.AbstractMesh[];
  75136. private _renderId;
  75137. private _furTime;
  75138. constructor(name: string, scene: BABYLON.Scene);
  75139. furTime: number;
  75140. needAlphaBlending(): boolean;
  75141. needAlphaTesting(): boolean;
  75142. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75143. updateFur(): void;
  75144. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75145. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75146. getAnimatables(): BABYLON.IAnimatable[];
  75147. getActiveTextures(): BABYLON.BaseTexture[];
  75148. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75149. dispose(forceDisposeEffect?: boolean): void;
  75150. clone(name: string): FurMaterial;
  75151. serialize(): any;
  75152. getClassName(): string;
  75153. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  75154. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  75155. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  75156. }
  75157. }
  75158. declare module BABYLON {
  75159. /** @hidden */
  75160. export var gradientPixelShader: {
  75161. name: string;
  75162. shader: string;
  75163. };
  75164. }
  75165. declare module BABYLON {
  75166. /** @hidden */
  75167. export var gradientVertexShader: {
  75168. name: string;
  75169. shader: string;
  75170. };
  75171. }
  75172. declare module BABYLON {
  75173. export class GradientMaterial extends BABYLON.PushMaterial {
  75174. private _maxSimultaneousLights;
  75175. maxSimultaneousLights: number;
  75176. topColor: BABYLON.Color3;
  75177. topColorAlpha: number;
  75178. bottomColor: BABYLON.Color3;
  75179. bottomColorAlpha: number;
  75180. offset: number;
  75181. scale: number;
  75182. smoothness: number;
  75183. private _disableLighting;
  75184. disableLighting: boolean;
  75185. private _renderId;
  75186. constructor(name: string, scene: BABYLON.Scene);
  75187. needAlphaBlending(): boolean;
  75188. needAlphaTesting(): boolean;
  75189. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75190. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75191. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75192. getAnimatables(): BABYLON.IAnimatable[];
  75193. dispose(forceDisposeEffect?: boolean): void;
  75194. clone(name: string): GradientMaterial;
  75195. serialize(): any;
  75196. getClassName(): string;
  75197. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  75198. }
  75199. }
  75200. declare module BABYLON {
  75201. /** @hidden */
  75202. export var gridPixelShader: {
  75203. name: string;
  75204. shader: string;
  75205. };
  75206. }
  75207. declare module BABYLON {
  75208. /** @hidden */
  75209. export var gridVertexShader: {
  75210. name: string;
  75211. shader: string;
  75212. };
  75213. }
  75214. declare module BABYLON {
  75215. /**
  75216. * The grid materials allows you to wrap any shape with a grid.
  75217. * Colors are customizable.
  75218. */
  75219. export class GridMaterial extends BABYLON.PushMaterial {
  75220. /**
  75221. * Main color of the grid (e.g. between lines)
  75222. */
  75223. mainColor: BABYLON.Color3;
  75224. /**
  75225. * Color of the grid lines.
  75226. */
  75227. lineColor: BABYLON.Color3;
  75228. /**
  75229. * The scale of the grid compared to unit.
  75230. */
  75231. gridRatio: number;
  75232. /**
  75233. * Allows setting an offset for the grid lines.
  75234. */
  75235. gridOffset: BABYLON.Vector3;
  75236. /**
  75237. * The frequency of thicker lines.
  75238. */
  75239. majorUnitFrequency: number;
  75240. /**
  75241. * The visibility of minor units in the grid.
  75242. */
  75243. minorUnitVisibility: number;
  75244. /**
  75245. * The grid opacity outside of the lines.
  75246. */
  75247. opacity: number;
  75248. /**
  75249. * Determine RBG output is premultiplied by alpha value.
  75250. */
  75251. preMultiplyAlpha: boolean;
  75252. private _opacityTexture;
  75253. opacityTexture: BABYLON.BaseTexture;
  75254. private _gridControl;
  75255. private _renderId;
  75256. /**
  75257. * constructor
  75258. * @param name The name given to the material in order to identify it afterwards.
  75259. * @param scene The scene the material is used in.
  75260. */
  75261. constructor(name: string, scene: BABYLON.Scene);
  75262. /**
  75263. * Returns wehter or not the grid requires alpha blending.
  75264. */
  75265. needAlphaBlending(): boolean;
  75266. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  75267. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75268. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75269. /**
  75270. * Dispose the material and its associated resources.
  75271. * @param forceDisposeEffect will also dispose the used effect when true
  75272. */
  75273. dispose(forceDisposeEffect?: boolean): void;
  75274. clone(name: string): GridMaterial;
  75275. serialize(): any;
  75276. getClassName(): string;
  75277. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  75278. }
  75279. }
  75280. declare module BABYLON {
  75281. /** @hidden */
  75282. export var lavaPixelShader: {
  75283. name: string;
  75284. shader: string;
  75285. };
  75286. }
  75287. declare module BABYLON {
  75288. /** @hidden */
  75289. export var lavaVertexShader: {
  75290. name: string;
  75291. shader: string;
  75292. };
  75293. }
  75294. declare module BABYLON {
  75295. export class LavaMaterial extends BABYLON.PushMaterial {
  75296. private _diffuseTexture;
  75297. diffuseTexture: BABYLON.BaseTexture;
  75298. noiseTexture: BABYLON.BaseTexture;
  75299. fogColor: BABYLON.Color3;
  75300. speed: number;
  75301. movingSpeed: number;
  75302. lowFrequencySpeed: number;
  75303. fogDensity: number;
  75304. private _lastTime;
  75305. diffuseColor: BABYLON.Color3;
  75306. private _disableLighting;
  75307. disableLighting: boolean;
  75308. private _unlit;
  75309. unlit: boolean;
  75310. private _maxSimultaneousLights;
  75311. maxSimultaneousLights: number;
  75312. private _scaledDiffuse;
  75313. private _renderId;
  75314. constructor(name: string, scene: BABYLON.Scene);
  75315. needAlphaBlending(): boolean;
  75316. needAlphaTesting(): boolean;
  75317. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75318. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75319. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75320. getAnimatables(): BABYLON.IAnimatable[];
  75321. getActiveTextures(): BABYLON.BaseTexture[];
  75322. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75323. dispose(forceDisposeEffect?: boolean): void;
  75324. clone(name: string): LavaMaterial;
  75325. serialize(): any;
  75326. getClassName(): string;
  75327. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  75328. }
  75329. }
  75330. declare module BABYLON {
  75331. /** @hidden */
  75332. export var mixPixelShader: {
  75333. name: string;
  75334. shader: string;
  75335. };
  75336. }
  75337. declare module BABYLON {
  75338. /** @hidden */
  75339. export var mixVertexShader: {
  75340. name: string;
  75341. shader: string;
  75342. };
  75343. }
  75344. declare module BABYLON {
  75345. export class MixMaterial extends BABYLON.PushMaterial {
  75346. /**
  75347. * Mix textures
  75348. */
  75349. private _mixTexture1;
  75350. mixTexture1: BABYLON.BaseTexture;
  75351. private _mixTexture2;
  75352. mixTexture2: BABYLON.BaseTexture;
  75353. /**
  75354. * Diffuse textures
  75355. */
  75356. private _diffuseTexture1;
  75357. diffuseTexture1: BABYLON.Texture;
  75358. private _diffuseTexture2;
  75359. diffuseTexture2: BABYLON.Texture;
  75360. private _diffuseTexture3;
  75361. diffuseTexture3: BABYLON.Texture;
  75362. private _diffuseTexture4;
  75363. diffuseTexture4: BABYLON.Texture;
  75364. private _diffuseTexture5;
  75365. diffuseTexture5: BABYLON.Texture;
  75366. private _diffuseTexture6;
  75367. diffuseTexture6: BABYLON.Texture;
  75368. private _diffuseTexture7;
  75369. diffuseTexture7: BABYLON.Texture;
  75370. private _diffuseTexture8;
  75371. diffuseTexture8: BABYLON.Texture;
  75372. /**
  75373. * Uniforms
  75374. */
  75375. diffuseColor: BABYLON.Color3;
  75376. specularColor: BABYLON.Color3;
  75377. specularPower: number;
  75378. private _disableLighting;
  75379. disableLighting: boolean;
  75380. private _maxSimultaneousLights;
  75381. maxSimultaneousLights: number;
  75382. private _renderId;
  75383. constructor(name: string, scene: BABYLON.Scene);
  75384. needAlphaBlending(): boolean;
  75385. needAlphaTesting(): boolean;
  75386. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75387. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75388. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75389. getAnimatables(): BABYLON.IAnimatable[];
  75390. getActiveTextures(): BABYLON.BaseTexture[];
  75391. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75392. dispose(forceDisposeEffect?: boolean): void;
  75393. clone(name: string): MixMaterial;
  75394. serialize(): any;
  75395. getClassName(): string;
  75396. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  75397. }
  75398. }
  75399. declare module BABYLON {
  75400. /** @hidden */
  75401. export var normalPixelShader: {
  75402. name: string;
  75403. shader: string;
  75404. };
  75405. }
  75406. declare module BABYLON {
  75407. /** @hidden */
  75408. export var normalVertexShader: {
  75409. name: string;
  75410. shader: string;
  75411. };
  75412. }
  75413. declare module BABYLON {
  75414. export class NormalMaterial extends BABYLON.PushMaterial {
  75415. private _diffuseTexture;
  75416. diffuseTexture: BABYLON.BaseTexture;
  75417. diffuseColor: BABYLON.Color3;
  75418. private _disableLighting;
  75419. disableLighting: boolean;
  75420. private _maxSimultaneousLights;
  75421. maxSimultaneousLights: number;
  75422. private _renderId;
  75423. constructor(name: string, scene: BABYLON.Scene);
  75424. needAlphaBlending(): boolean;
  75425. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  75426. needAlphaTesting(): boolean;
  75427. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75428. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75429. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75430. getAnimatables(): BABYLON.IAnimatable[];
  75431. getActiveTextures(): BABYLON.BaseTexture[];
  75432. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75433. dispose(forceDisposeEffect?: boolean): void;
  75434. clone(name: string): NormalMaterial;
  75435. serialize(): any;
  75436. getClassName(): string;
  75437. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  75438. }
  75439. }
  75440. declare module BABYLON {
  75441. /** @hidden */
  75442. export var shadowOnlyPixelShader: {
  75443. name: string;
  75444. shader: string;
  75445. };
  75446. }
  75447. declare module BABYLON {
  75448. /** @hidden */
  75449. export var shadowOnlyVertexShader: {
  75450. name: string;
  75451. shader: string;
  75452. };
  75453. }
  75454. declare module BABYLON {
  75455. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  75456. private _renderId;
  75457. private _activeLight;
  75458. constructor(name: string, scene: BABYLON.Scene);
  75459. shadowColor: BABYLON.Color3;
  75460. needAlphaBlending(): boolean;
  75461. needAlphaTesting(): boolean;
  75462. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75463. activeLight: BABYLON.IShadowLight;
  75464. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75465. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75466. clone(name: string): ShadowOnlyMaterial;
  75467. serialize(): any;
  75468. getClassName(): string;
  75469. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  75470. }
  75471. }
  75472. declare module BABYLON {
  75473. /** @hidden */
  75474. export var simplePixelShader: {
  75475. name: string;
  75476. shader: string;
  75477. };
  75478. }
  75479. declare module BABYLON {
  75480. /** @hidden */
  75481. export var simpleVertexShader: {
  75482. name: string;
  75483. shader: string;
  75484. };
  75485. }
  75486. declare module BABYLON {
  75487. export class SimpleMaterial extends BABYLON.PushMaterial {
  75488. private _diffuseTexture;
  75489. diffuseTexture: BABYLON.BaseTexture;
  75490. diffuseColor: BABYLON.Color3;
  75491. private _disableLighting;
  75492. disableLighting: boolean;
  75493. private _maxSimultaneousLights;
  75494. maxSimultaneousLights: number;
  75495. private _renderId;
  75496. constructor(name: string, scene: BABYLON.Scene);
  75497. needAlphaBlending(): boolean;
  75498. needAlphaTesting(): boolean;
  75499. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75500. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75501. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75502. getAnimatables(): BABYLON.IAnimatable[];
  75503. getActiveTextures(): BABYLON.BaseTexture[];
  75504. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75505. dispose(forceDisposeEffect?: boolean): void;
  75506. clone(name: string): SimpleMaterial;
  75507. serialize(): any;
  75508. getClassName(): string;
  75509. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  75510. }
  75511. }
  75512. declare module BABYLON {
  75513. /** @hidden */
  75514. export var skyPixelShader: {
  75515. name: string;
  75516. shader: string;
  75517. };
  75518. }
  75519. declare module BABYLON {
  75520. /** @hidden */
  75521. export var skyVertexShader: {
  75522. name: string;
  75523. shader: string;
  75524. };
  75525. }
  75526. declare module BABYLON {
  75527. /**
  75528. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  75529. * @see https://doc.babylonjs.com/extensions/sky
  75530. */
  75531. export class SkyMaterial extends BABYLON.PushMaterial {
  75532. /**
  75533. * Defines the overall luminance of sky in interval ]0, 1[.
  75534. */
  75535. luminance: number;
  75536. /**
  75537. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  75538. */
  75539. turbidity: number;
  75540. /**
  75541. * Defines the sky appearance (light intensity).
  75542. */
  75543. rayleigh: number;
  75544. /**
  75545. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  75546. */
  75547. mieCoefficient: number;
  75548. /**
  75549. * Defines the amount of haze particles following the Mie scattering theory.
  75550. */
  75551. mieDirectionalG: number;
  75552. /**
  75553. * Defines the distance of the sun according to the active scene camera.
  75554. */
  75555. distance: number;
  75556. /**
  75557. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  75558. * "inclined".
  75559. */
  75560. inclination: number;
  75561. /**
  75562. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  75563. * an object direction and a reference direction.
  75564. */
  75565. azimuth: number;
  75566. /**
  75567. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  75568. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  75569. */
  75570. sunPosition: BABYLON.Vector3;
  75571. /**
  75572. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  75573. * .sunPosition property.
  75574. */
  75575. useSunPosition: boolean;
  75576. /**
  75577. * Defines an offset vector used to get a horizon offset.
  75578. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  75579. */
  75580. cameraOffset: BABYLON.Vector3;
  75581. private _cameraPosition;
  75582. private _renderId;
  75583. /**
  75584. * Instantiates a new sky material.
  75585. * This material allows to create dynamic and texture free
  75586. * effects for skyboxes by taking care of the atmosphere state.
  75587. * @see https://doc.babylonjs.com/extensions/sky
  75588. * @param name Define the name of the material in the scene
  75589. * @param scene Define the scene the material belong to
  75590. */
  75591. constructor(name: string, scene: BABYLON.Scene);
  75592. /**
  75593. * Specifies if the material will require alpha blending
  75594. * @returns a boolean specifying if alpha blending is needed
  75595. */
  75596. needAlphaBlending(): boolean;
  75597. /**
  75598. * Specifies if this material should be rendered in alpha test mode
  75599. * @returns false as the sky material doesn't need alpha testing.
  75600. */
  75601. needAlphaTesting(): boolean;
  75602. /**
  75603. * Get the texture used for alpha test purpose.
  75604. * @returns null as the sky material has no texture.
  75605. */
  75606. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75607. /**
  75608. * Get if the submesh is ready to be used and all its information available.
  75609. * Child classes can use it to update shaders
  75610. * @param mesh defines the mesh to check
  75611. * @param subMesh defines which submesh to check
  75612. * @param useInstances specifies that instances should be used
  75613. * @returns a boolean indicating that the submesh is ready or not
  75614. */
  75615. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75616. /**
  75617. * Binds the submesh to this material by preparing the effect and shader to draw
  75618. * @param world defines the world transformation matrix
  75619. * @param mesh defines the mesh containing the submesh
  75620. * @param subMesh defines the submesh to bind the material to
  75621. */
  75622. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75623. /**
  75624. * Get the list of animatables in the material.
  75625. * @returns the list of animatables object used in the material
  75626. */
  75627. getAnimatables(): BABYLON.IAnimatable[];
  75628. /**
  75629. * Disposes the material
  75630. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75631. */
  75632. dispose(forceDisposeEffect?: boolean): void;
  75633. /**
  75634. * Makes a duplicate of the material, and gives it a new name
  75635. * @param name defines the new name for the duplicated material
  75636. * @returns the cloned material
  75637. */
  75638. clone(name: string): SkyMaterial;
  75639. /**
  75640. * Serializes this material in a JSON representation
  75641. * @returns the serialized material object
  75642. */
  75643. serialize(): any;
  75644. /**
  75645. * Gets the current class name of the material e.g. "SkyMaterial"
  75646. * Mainly use in serialization.
  75647. * @returns the class name
  75648. */
  75649. getClassName(): string;
  75650. /**
  75651. * Creates a sky material from parsed material data
  75652. * @param source defines the JSON representation of the material
  75653. * @param scene defines the hosting scene
  75654. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75655. * @returns a new sky material
  75656. */
  75657. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  75658. }
  75659. }
  75660. declare module BABYLON {
  75661. /** @hidden */
  75662. export var terrainPixelShader: {
  75663. name: string;
  75664. shader: string;
  75665. };
  75666. }
  75667. declare module BABYLON {
  75668. /** @hidden */
  75669. export var terrainVertexShader: {
  75670. name: string;
  75671. shader: string;
  75672. };
  75673. }
  75674. declare module BABYLON {
  75675. export class TerrainMaterial extends BABYLON.PushMaterial {
  75676. private _mixTexture;
  75677. mixTexture: BABYLON.BaseTexture;
  75678. private _diffuseTexture1;
  75679. diffuseTexture1: BABYLON.Texture;
  75680. private _diffuseTexture2;
  75681. diffuseTexture2: BABYLON.Texture;
  75682. private _diffuseTexture3;
  75683. diffuseTexture3: BABYLON.Texture;
  75684. private _bumpTexture1;
  75685. bumpTexture1: BABYLON.Texture;
  75686. private _bumpTexture2;
  75687. bumpTexture2: BABYLON.Texture;
  75688. private _bumpTexture3;
  75689. bumpTexture3: BABYLON.Texture;
  75690. diffuseColor: BABYLON.Color3;
  75691. specularColor: BABYLON.Color3;
  75692. specularPower: number;
  75693. private _disableLighting;
  75694. disableLighting: boolean;
  75695. private _maxSimultaneousLights;
  75696. maxSimultaneousLights: number;
  75697. private _renderId;
  75698. constructor(name: string, scene: BABYLON.Scene);
  75699. needAlphaBlending(): boolean;
  75700. needAlphaTesting(): boolean;
  75701. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75702. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75703. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75704. getAnimatables(): BABYLON.IAnimatable[];
  75705. getActiveTextures(): BABYLON.BaseTexture[];
  75706. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75707. dispose(forceDisposeEffect?: boolean): void;
  75708. clone(name: string): TerrainMaterial;
  75709. serialize(): any;
  75710. getClassName(): string;
  75711. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  75712. }
  75713. }
  75714. declare module BABYLON {
  75715. /** @hidden */
  75716. export var triplanarPixelShader: {
  75717. name: string;
  75718. shader: string;
  75719. };
  75720. }
  75721. declare module BABYLON {
  75722. /** @hidden */
  75723. export var triplanarVertexShader: {
  75724. name: string;
  75725. shader: string;
  75726. };
  75727. }
  75728. declare module BABYLON {
  75729. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  75730. mixTexture: BABYLON.BaseTexture;
  75731. private _diffuseTextureX;
  75732. diffuseTextureX: BABYLON.BaseTexture;
  75733. private _diffuseTextureY;
  75734. diffuseTextureY: BABYLON.BaseTexture;
  75735. private _diffuseTextureZ;
  75736. diffuseTextureZ: BABYLON.BaseTexture;
  75737. private _normalTextureX;
  75738. normalTextureX: BABYLON.BaseTexture;
  75739. private _normalTextureY;
  75740. normalTextureY: BABYLON.BaseTexture;
  75741. private _normalTextureZ;
  75742. normalTextureZ: BABYLON.BaseTexture;
  75743. tileSize: number;
  75744. diffuseColor: BABYLON.Color3;
  75745. specularColor: BABYLON.Color3;
  75746. specularPower: number;
  75747. private _disableLighting;
  75748. disableLighting: boolean;
  75749. private _maxSimultaneousLights;
  75750. maxSimultaneousLights: number;
  75751. private _renderId;
  75752. constructor(name: string, scene: BABYLON.Scene);
  75753. needAlphaBlending(): boolean;
  75754. needAlphaTesting(): boolean;
  75755. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75756. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75757. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75758. getAnimatables(): BABYLON.IAnimatable[];
  75759. getActiveTextures(): BABYLON.BaseTexture[];
  75760. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75761. dispose(forceDisposeEffect?: boolean): void;
  75762. clone(name: string): TriPlanarMaterial;
  75763. serialize(): any;
  75764. getClassName(): string;
  75765. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  75766. }
  75767. }
  75768. declare module BABYLON {
  75769. /** @hidden */
  75770. export var waterPixelShader: {
  75771. name: string;
  75772. shader: string;
  75773. };
  75774. }
  75775. declare module BABYLON {
  75776. /** @hidden */
  75777. export var waterVertexShader: {
  75778. name: string;
  75779. shader: string;
  75780. };
  75781. }
  75782. declare module BABYLON {
  75783. export class WaterMaterial extends BABYLON.PushMaterial {
  75784. renderTargetSize: BABYLON.Vector2;
  75785. private _bumpTexture;
  75786. bumpTexture: BABYLON.BaseTexture;
  75787. diffuseColor: BABYLON.Color3;
  75788. specularColor: BABYLON.Color3;
  75789. specularPower: number;
  75790. private _disableLighting;
  75791. disableLighting: boolean;
  75792. private _maxSimultaneousLights;
  75793. maxSimultaneousLights: number;
  75794. /**
  75795. * @param {number}: Represents the wind force
  75796. */
  75797. windForce: number;
  75798. /**
  75799. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  75800. */
  75801. windDirection: BABYLON.Vector2;
  75802. /**
  75803. * @param {number}: Wave height, represents the height of the waves
  75804. */
  75805. waveHeight: number;
  75806. /**
  75807. * @param {number}: Bump height, represents the bump height related to the bump map
  75808. */
  75809. bumpHeight: number;
  75810. /**
  75811. * @param {boolean}: Add a smaller moving bump to less steady waves.
  75812. */
  75813. private _bumpSuperimpose;
  75814. bumpSuperimpose: boolean;
  75815. /**
  75816. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  75817. */
  75818. private _fresnelSeparate;
  75819. fresnelSeparate: boolean;
  75820. /**
  75821. * @param {boolean}: bump Waves modify the reflection.
  75822. */
  75823. private _bumpAffectsReflection;
  75824. bumpAffectsReflection: boolean;
  75825. /**
  75826. * @param {number}: The water color blended with the refraction (near)
  75827. */
  75828. waterColor: BABYLON.Color3;
  75829. /**
  75830. * @param {number}: The blend factor related to the water color
  75831. */
  75832. colorBlendFactor: number;
  75833. /**
  75834. * @param {number}: The water color blended with the reflection (far)
  75835. */
  75836. waterColor2: BABYLON.Color3;
  75837. /**
  75838. * @param {number}: The blend factor related to the water color (reflection, far)
  75839. */
  75840. colorBlendFactor2: number;
  75841. /**
  75842. * @param {number}: Represents the maximum length of a wave
  75843. */
  75844. waveLength: number;
  75845. /**
  75846. * @param {number}: Defines the waves speed
  75847. */
  75848. waveSpeed: number;
  75849. /**
  75850. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  75851. * will avoid calculating useless pixels in the pixel shader of the water material.
  75852. */
  75853. disableClipPlane: boolean;
  75854. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  75855. private _mesh;
  75856. private _refractionRTT;
  75857. private _reflectionRTT;
  75858. private _reflectionTransform;
  75859. private _lastTime;
  75860. private _lastDeltaTime;
  75861. private _renderId;
  75862. private _useLogarithmicDepth;
  75863. private _waitingRenderList;
  75864. private _imageProcessingConfiguration;
  75865. private _imageProcessingObserver;
  75866. /**
  75867. * Gets a boolean indicating that current material needs to register RTT
  75868. */
  75869. readonly hasRenderTargetTextures: boolean;
  75870. /**
  75871. * Constructor
  75872. */
  75873. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  75874. useLogarithmicDepth: boolean;
  75875. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  75876. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  75877. addToRenderList(node: any): void;
  75878. enableRenderTargets(enable: boolean): void;
  75879. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  75880. readonly renderTargetsEnabled: boolean;
  75881. needAlphaBlending(): boolean;
  75882. needAlphaTesting(): boolean;
  75883. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75884. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75885. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75886. private _createRenderTargets;
  75887. getAnimatables(): BABYLON.IAnimatable[];
  75888. getActiveTextures(): BABYLON.BaseTexture[];
  75889. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75890. dispose(forceDisposeEffect?: boolean): void;
  75891. clone(name: string): WaterMaterial;
  75892. serialize(): any;
  75893. getClassName(): string;
  75894. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  75895. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  75896. }
  75897. }
  75898. declare module BABYLON {
  75899. /** @hidden */
  75900. export var asciiartPixelShader: {
  75901. name: string;
  75902. shader: string;
  75903. };
  75904. }
  75905. declare module BABYLON {
  75906. /**
  75907. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  75908. *
  75909. * It basically takes care rendering the font front the given font size to a texture.
  75910. * This is used later on in the postprocess.
  75911. */
  75912. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  75913. private _font;
  75914. private _text;
  75915. private _charSize;
  75916. /**
  75917. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  75918. */
  75919. readonly charSize: number;
  75920. /**
  75921. * Create a new instance of the Ascii Art FontTexture class
  75922. * @param name the name of the texture
  75923. * @param font the font to use, use the W3C CSS notation
  75924. * @param text the caracter set to use in the rendering.
  75925. * @param scene the scene that owns the texture
  75926. */
  75927. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  75928. /**
  75929. * Gets the max char width of a font.
  75930. * @param font the font to use, use the W3C CSS notation
  75931. * @return the max char width
  75932. */
  75933. private getFontWidth;
  75934. /**
  75935. * Gets the max char height of a font.
  75936. * @param font the font to use, use the W3C CSS notation
  75937. * @return the max char height
  75938. */
  75939. private getFontHeight;
  75940. /**
  75941. * Clones the current AsciiArtTexture.
  75942. * @return the clone of the texture.
  75943. */
  75944. clone(): AsciiArtFontTexture;
  75945. /**
  75946. * Parses a json object representing the texture and returns an instance of it.
  75947. * @param source the source JSON representation
  75948. * @param scene the scene to create the texture for
  75949. * @return the parsed texture
  75950. */
  75951. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  75952. }
  75953. /**
  75954. * Option available in the Ascii Art Post Process.
  75955. */
  75956. export interface IAsciiArtPostProcessOptions {
  75957. /**
  75958. * The font to use following the w3c font definition.
  75959. */
  75960. font?: string;
  75961. /**
  75962. * The character set to use in the postprocess.
  75963. */
  75964. characterSet?: string;
  75965. /**
  75966. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  75967. * This number is defined between 0 and 1;
  75968. */
  75969. mixToTile?: number;
  75970. /**
  75971. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  75972. * This number is defined between 0 and 1;
  75973. */
  75974. mixToNormal?: number;
  75975. }
  75976. /**
  75977. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  75978. *
  75979. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75980. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  75981. */
  75982. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  75983. /**
  75984. * The font texture used to render the char in the post process.
  75985. */
  75986. private _asciiArtFontTexture;
  75987. /**
  75988. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  75989. * This number is defined between 0 and 1;
  75990. */
  75991. mixToTile: number;
  75992. /**
  75993. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  75994. * This number is defined between 0 and 1;
  75995. */
  75996. mixToNormal: number;
  75997. /**
  75998. * Instantiates a new Ascii Art Post Process.
  75999. * @param name the name to give to the postprocess
  76000. * @camera the camera to apply the post process to.
  76001. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  76002. */
  76003. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  76004. }
  76005. }
  76006. declare module BABYLON {
  76007. /** @hidden */
  76008. export var digitalrainPixelShader: {
  76009. name: string;
  76010. shader: string;
  76011. };
  76012. }
  76013. declare module BABYLON {
  76014. /**
  76015. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  76016. *
  76017. * It basically takes care rendering the font front the given font size to a texture.
  76018. * This is used later on in the postprocess.
  76019. */
  76020. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  76021. private _font;
  76022. private _text;
  76023. private _charSize;
  76024. /**
  76025. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76026. */
  76027. readonly charSize: number;
  76028. /**
  76029. * Create a new instance of the Digital Rain FontTexture class
  76030. * @param name the name of the texture
  76031. * @param font the font to use, use the W3C CSS notation
  76032. * @param text the caracter set to use in the rendering.
  76033. * @param scene the scene that owns the texture
  76034. */
  76035. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76036. /**
  76037. * Gets the max char width of a font.
  76038. * @param font the font to use, use the W3C CSS notation
  76039. * @return the max char width
  76040. */
  76041. private getFontWidth;
  76042. /**
  76043. * Gets the max char height of a font.
  76044. * @param font the font to use, use the W3C CSS notation
  76045. * @return the max char height
  76046. */
  76047. private getFontHeight;
  76048. /**
  76049. * Clones the current DigitalRainFontTexture.
  76050. * @return the clone of the texture.
  76051. */
  76052. clone(): DigitalRainFontTexture;
  76053. /**
  76054. * Parses a json object representing the texture and returns an instance of it.
  76055. * @param source the source JSON representation
  76056. * @param scene the scene to create the texture for
  76057. * @return the parsed texture
  76058. */
  76059. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  76060. }
  76061. /**
  76062. * Option available in the Digital Rain Post Process.
  76063. */
  76064. export interface IDigitalRainPostProcessOptions {
  76065. /**
  76066. * The font to use following the w3c font definition.
  76067. */
  76068. font?: string;
  76069. /**
  76070. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  76071. * This number is defined between 0 and 1;
  76072. */
  76073. mixToTile?: number;
  76074. /**
  76075. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  76076. * This number is defined between 0 and 1;
  76077. */
  76078. mixToNormal?: number;
  76079. }
  76080. /**
  76081. * DigitalRainPostProcess helps rendering everithing in digital rain.
  76082. *
  76083. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76084. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  76085. */
  76086. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  76087. /**
  76088. * The font texture used to render the char in the post process.
  76089. */
  76090. private _digitalRainFontTexture;
  76091. /**
  76092. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  76093. * This number is defined between 0 and 1;
  76094. */
  76095. mixToTile: number;
  76096. /**
  76097. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  76098. * This number is defined between 0 and 1;
  76099. */
  76100. mixToNormal: number;
  76101. /**
  76102. * Instantiates a new Digital Rain Post Process.
  76103. * @param name the name to give to the postprocess
  76104. * @camera the camera to apply the post process to.
  76105. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  76106. */
  76107. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  76108. }
  76109. }
  76110. declare module BABYLON {
  76111. /** @hidden */
  76112. export var oceanPostProcessPixelShader: {
  76113. name: string;
  76114. shader: string;
  76115. };
  76116. }
  76117. declare module BABYLON {
  76118. /**
  76119. * Option available in the Ocean Post Process.
  76120. */
  76121. export interface IOceanPostProcessOptions {
  76122. /**
  76123. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  76124. */
  76125. reflectionSize?: number | {
  76126. width: number;
  76127. height: number;
  76128. } | {
  76129. ratio: number;
  76130. };
  76131. /**
  76132. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  76133. */
  76134. refractionSize?: number | {
  76135. width: number;
  76136. height: number;
  76137. } | {
  76138. ratio: number;
  76139. };
  76140. }
  76141. /**
  76142. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  76143. *
  76144. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76145. * Example usage:
  76146. * var pp = new OceanPostProcess("myOcean", camera);
  76147. * pp.reflectionEnabled = true;
  76148. * pp.refractionEnabled = true;
  76149. */
  76150. export class OceanPostProcess extends BABYLON.PostProcess {
  76151. /**
  76152. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  76153. */
  76154. /**
  76155. * Sets weither or not the real-time reflection is enabled on the ocean.
  76156. * Is set to true, the reflection mirror texture will be used as reflection texture.
  76157. */
  76158. reflectionEnabled: boolean;
  76159. /**
  76160. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  76161. */
  76162. /**
  76163. * Sets weither or not the real-time refraction is enabled on the ocean.
  76164. * Is set to true, the refraction render target texture will be used as refraction texture.
  76165. */
  76166. refractionEnabled: boolean;
  76167. /**
  76168. * Gets wether or not the post-processes is supported by the running hardware.
  76169. * This requires draw buffer supports.
  76170. */
  76171. readonly isSupported: boolean;
  76172. /**
  76173. * This is the reflection mirror texture used to display reflections on the ocean.
  76174. * By default, render list is empty.
  76175. */
  76176. reflectionTexture: BABYLON.MirrorTexture;
  76177. /**
  76178. * This is the refraction render target texture used to display refraction on the ocean.
  76179. * By default, render list is empty.
  76180. */
  76181. refractionTexture: BABYLON.RenderTargetTexture;
  76182. private _time;
  76183. private _cameraRotation;
  76184. private _cameraViewMatrix;
  76185. private _reflectionEnabled;
  76186. private _refractionEnabled;
  76187. private _geometryRenderer;
  76188. /**
  76189. * Instantiates a new Ocean Post Process.
  76190. * @param name the name to give to the postprocess.
  76191. * @camera the camera to apply the post process to.
  76192. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  76193. */
  76194. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  76195. /**
  76196. * Returns the appropriate defines according to the current configuration.
  76197. */
  76198. private _getDefines;
  76199. /**
  76200. * Computes the current camera rotation as the shader requires a camera rotation.
  76201. */
  76202. private _computeCameraRotation;
  76203. }
  76204. }
  76205. declare module BABYLON {
  76206. /** @hidden */
  76207. export var brickProceduralTexturePixelShader: {
  76208. name: string;
  76209. shader: string;
  76210. };
  76211. }
  76212. declare module BABYLON {
  76213. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  76214. private _numberOfBricksHeight;
  76215. private _numberOfBricksWidth;
  76216. private _jointColor;
  76217. private _brickColor;
  76218. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76219. updateShaderUniforms(): void;
  76220. numberOfBricksHeight: number;
  76221. numberOfBricksWidth: number;
  76222. jointColor: BABYLON.Color3;
  76223. brickColor: BABYLON.Color3;
  76224. /**
  76225. * Serializes this brick procedural texture
  76226. * @returns a serialized brick procedural texture object
  76227. */
  76228. serialize(): any;
  76229. /**
  76230. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  76231. * @param parsedTexture defines parsed texture data
  76232. * @param scene defines the current scene
  76233. * @param rootUrl defines the root URL containing brick procedural texture information
  76234. * @returns a parsed Brick Procedural BABYLON.Texture
  76235. */
  76236. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  76237. }
  76238. }
  76239. declare module BABYLON {
  76240. /** @hidden */
  76241. export var cloudProceduralTexturePixelShader: {
  76242. name: string;
  76243. shader: string;
  76244. };
  76245. }
  76246. declare module BABYLON {
  76247. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  76248. private _skyColor;
  76249. private _cloudColor;
  76250. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76251. updateShaderUniforms(): void;
  76252. skyColor: BABYLON.Color4;
  76253. cloudColor: BABYLON.Color4;
  76254. /**
  76255. * Serializes this cloud procedural texture
  76256. * @returns a serialized cloud procedural texture object
  76257. */
  76258. serialize(): any;
  76259. /**
  76260. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  76261. * @param parsedTexture defines parsed texture data
  76262. * @param scene defines the current scene
  76263. * @param rootUrl defines the root URL containing cloud procedural texture information
  76264. * @returns a parsed Cloud Procedural BABYLON.Texture
  76265. */
  76266. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  76267. }
  76268. }
  76269. declare module BABYLON {
  76270. /** @hidden */
  76271. export var fireProceduralTexturePixelShader: {
  76272. name: string;
  76273. shader: string;
  76274. };
  76275. }
  76276. declare module BABYLON {
  76277. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  76278. private _time;
  76279. private _speed;
  76280. private _autoGenerateTime;
  76281. private _fireColors;
  76282. private _alphaThreshold;
  76283. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76284. updateShaderUniforms(): void;
  76285. render(useCameraPostProcess?: boolean): void;
  76286. static readonly PurpleFireColors: BABYLON.Color3[];
  76287. static readonly GreenFireColors: BABYLON.Color3[];
  76288. static readonly RedFireColors: BABYLON.Color3[];
  76289. static readonly BlueFireColors: BABYLON.Color3[];
  76290. autoGenerateTime: boolean;
  76291. fireColors: BABYLON.Color3[];
  76292. time: number;
  76293. speed: BABYLON.Vector2;
  76294. alphaThreshold: number;
  76295. /**
  76296. * Serializes this fire procedural texture
  76297. * @returns a serialized fire procedural texture object
  76298. */
  76299. serialize(): any;
  76300. /**
  76301. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  76302. * @param parsedTexture defines parsed texture data
  76303. * @param scene defines the current scene
  76304. * @param rootUrl defines the root URL containing fire procedural texture information
  76305. * @returns a parsed Fire Procedural BABYLON.Texture
  76306. */
  76307. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  76308. }
  76309. }
  76310. declare module BABYLON {
  76311. /** @hidden */
  76312. export var grassProceduralTexturePixelShader: {
  76313. name: string;
  76314. shader: string;
  76315. };
  76316. }
  76317. declare module BABYLON {
  76318. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  76319. private _grassColors;
  76320. private _groundColor;
  76321. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76322. updateShaderUniforms(): void;
  76323. grassColors: BABYLON.Color3[];
  76324. groundColor: BABYLON.Color3;
  76325. /**
  76326. * Serializes this grass procedural texture
  76327. * @returns a serialized grass procedural texture object
  76328. */
  76329. serialize(): any;
  76330. /**
  76331. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  76332. * @param parsedTexture defines parsed texture data
  76333. * @param scene defines the current scene
  76334. * @param rootUrl defines the root URL containing grass procedural texture information
  76335. * @returns a parsed Grass Procedural BABYLON.Texture
  76336. */
  76337. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  76338. }
  76339. }
  76340. declare module BABYLON {
  76341. /** @hidden */
  76342. export var marbleProceduralTexturePixelShader: {
  76343. name: string;
  76344. shader: string;
  76345. };
  76346. }
  76347. declare module BABYLON {
  76348. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  76349. private _numberOfTilesHeight;
  76350. private _numberOfTilesWidth;
  76351. private _amplitude;
  76352. private _jointColor;
  76353. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76354. updateShaderUniforms(): void;
  76355. numberOfTilesHeight: number;
  76356. amplitude: number;
  76357. numberOfTilesWidth: number;
  76358. jointColor: BABYLON.Color3;
  76359. /**
  76360. * Serializes this marble procedural texture
  76361. * @returns a serialized marble procedural texture object
  76362. */
  76363. serialize(): any;
  76364. /**
  76365. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  76366. * @param parsedTexture defines parsed texture data
  76367. * @param scene defines the current scene
  76368. * @param rootUrl defines the root URL containing marble procedural texture information
  76369. * @returns a parsed Marble Procedural BABYLON.Texture
  76370. */
  76371. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  76372. }
  76373. }
  76374. declare module BABYLON {
  76375. /** @hidden */
  76376. export var normalMapProceduralTexturePixelShader: {
  76377. name: string;
  76378. shader: string;
  76379. };
  76380. }
  76381. declare module BABYLON {
  76382. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  76383. private _baseTexture;
  76384. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76385. updateShaderUniforms(): void;
  76386. render(useCameraPostProcess?: boolean): void;
  76387. resize(size: any, generateMipMaps: any): void;
  76388. baseTexture: BABYLON.Texture;
  76389. /**
  76390. * Serializes this normal map procedural texture
  76391. * @returns a serialized normal map procedural texture object
  76392. */
  76393. serialize(): any;
  76394. /**
  76395. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  76396. * @param parsedTexture defines parsed texture data
  76397. * @param scene defines the current scene
  76398. * @param rootUrl defines the root URL containing normal map procedural texture information
  76399. * @returns a parsed Normal Map Procedural BABYLON.Texture
  76400. */
  76401. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  76402. }
  76403. }
  76404. declare module BABYLON {
  76405. /** @hidden */
  76406. export var perlinNoiseProceduralTexturePixelShader: {
  76407. name: string;
  76408. shader: string;
  76409. };
  76410. }
  76411. declare module BABYLON {
  76412. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  76413. time: number;
  76414. timeScale: number;
  76415. translationSpeed: number;
  76416. private _currentTranslation;
  76417. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76418. updateShaderUniforms(): void;
  76419. render(useCameraPostProcess?: boolean): void;
  76420. resize(size: any, generateMipMaps: any): void;
  76421. /**
  76422. * Serializes this perlin noise procedural texture
  76423. * @returns a serialized perlin noise procedural texture object
  76424. */
  76425. serialize(): any;
  76426. /**
  76427. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  76428. * @param parsedTexture defines parsed texture data
  76429. * @param scene defines the current scene
  76430. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  76431. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  76432. */
  76433. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  76434. }
  76435. }
  76436. declare module BABYLON {
  76437. /** @hidden */
  76438. export var roadProceduralTexturePixelShader: {
  76439. name: string;
  76440. shader: string;
  76441. };
  76442. }
  76443. declare module BABYLON {
  76444. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  76445. private _roadColor;
  76446. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76447. updateShaderUniforms(): void;
  76448. roadColor: BABYLON.Color3;
  76449. /**
  76450. * Serializes this road procedural texture
  76451. * @returns a serialized road procedural texture object
  76452. */
  76453. serialize(): any;
  76454. /**
  76455. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  76456. * @param parsedTexture defines parsed texture data
  76457. * @param scene defines the current scene
  76458. * @param rootUrl defines the root URL containing road procedural texture information
  76459. * @returns a parsed Road Procedural BABYLON.Texture
  76460. */
  76461. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  76462. }
  76463. }
  76464. declare module BABYLON {
  76465. /** @hidden */
  76466. export var starfieldProceduralTexturePixelShader: {
  76467. name: string;
  76468. shader: string;
  76469. };
  76470. }
  76471. declare module BABYLON {
  76472. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  76473. private _time;
  76474. private _alpha;
  76475. private _beta;
  76476. private _zoom;
  76477. private _formuparam;
  76478. private _stepsize;
  76479. private _tile;
  76480. private _brightness;
  76481. private _darkmatter;
  76482. private _distfading;
  76483. private _saturation;
  76484. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76485. updateShaderUniforms(): void;
  76486. time: number;
  76487. alpha: number;
  76488. beta: number;
  76489. formuparam: number;
  76490. stepsize: number;
  76491. zoom: number;
  76492. tile: number;
  76493. brightness: number;
  76494. darkmatter: number;
  76495. distfading: number;
  76496. saturation: number;
  76497. /**
  76498. * Serializes this starfield procedural texture
  76499. * @returns a serialized starfield procedural texture object
  76500. */
  76501. serialize(): any;
  76502. /**
  76503. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  76504. * @param parsedTexture defines parsed texture data
  76505. * @param scene defines the current scene
  76506. * @param rootUrl defines the root URL containing startfield procedural texture information
  76507. * @returns a parsed Starfield Procedural BABYLON.Texture
  76508. */
  76509. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  76510. }
  76511. }
  76512. declare module BABYLON {
  76513. /** @hidden */
  76514. export var woodProceduralTexturePixelShader: {
  76515. name: string;
  76516. shader: string;
  76517. };
  76518. }
  76519. declare module BABYLON {
  76520. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  76521. private _ampScale;
  76522. private _woodColor;
  76523. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76524. updateShaderUniforms(): void;
  76525. ampScale: number;
  76526. woodColor: BABYLON.Color3;
  76527. /**
  76528. * Serializes this wood procedural texture
  76529. * @returns a serialized wood procedural texture object
  76530. */
  76531. serialize(): any;
  76532. /**
  76533. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  76534. * @param parsedTexture defines parsed texture data
  76535. * @param scene defines the current scene
  76536. * @param rootUrl defines the root URL containing wood procedural texture information
  76537. * @returns a parsed Wood Procedural BABYLON.Texture
  76538. */
  76539. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  76540. }
  76541. }