documentation.d.ts 3.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644
  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. /**
  31438. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31439. * @returns true if the engine can be created
  31440. * @ignorenaming
  31441. */
  31442. static isSupported(): boolean;
  31443. /**
  31444. * Find the next highest power of two.
  31445. * @param x Number to start search from.
  31446. * @return Next highest power of two.
  31447. */
  31448. static CeilingPOT(x: number): number;
  31449. /**
  31450. * Find the next lowest power of two.
  31451. * @param x Number to start search from.
  31452. * @return Next lowest power of two.
  31453. */
  31454. static FloorPOT(x: number): number;
  31455. /**
  31456. * Find the nearest power of two.
  31457. * @param x Number to start search from.
  31458. * @return Next nearest power of two.
  31459. */
  31460. static NearestPOT(x: number): number;
  31461. /**
  31462. * Get the closest exponent of two
  31463. * @param value defines the value to approximate
  31464. * @param max defines the maximum value to return
  31465. * @param mode defines how to define the closest value
  31466. * @returns closest exponent of two of the given value
  31467. */
  31468. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31469. /**
  31470. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31471. * @param func - the function to be called
  31472. * @param requester - the object that will request the next frame. Falls back to window.
  31473. * @returns frame number
  31474. */
  31475. static QueueNewFrame(func: () => void, requester?: any): number;
  31476. /**
  31477. * Gets host document
  31478. * @returns the host document object
  31479. */
  31480. getHostDocument(): Nullable<Document>;
  31481. }
  31482. }
  31483. declare module BABYLON {
  31484. /**
  31485. * Class representing spherical harmonics coefficients to the 3rd degree
  31486. */
  31487. export class SphericalHarmonics {
  31488. /**
  31489. * Defines whether or not the harmonics have been prescaled for rendering.
  31490. */
  31491. preScaled: boolean;
  31492. /**
  31493. * The l0,0 coefficients of the spherical harmonics
  31494. */
  31495. l00: Vector3;
  31496. /**
  31497. * The l1,-1 coefficients of the spherical harmonics
  31498. */
  31499. l1_1: Vector3;
  31500. /**
  31501. * The l1,0 coefficients of the spherical harmonics
  31502. */
  31503. l10: Vector3;
  31504. /**
  31505. * The l1,1 coefficients of the spherical harmonics
  31506. */
  31507. l11: Vector3;
  31508. /**
  31509. * The l2,-2 coefficients of the spherical harmonics
  31510. */
  31511. l2_2: Vector3;
  31512. /**
  31513. * The l2,-1 coefficients of the spherical harmonics
  31514. */
  31515. l2_1: Vector3;
  31516. /**
  31517. * The l2,0 coefficients of the spherical harmonics
  31518. */
  31519. l20: Vector3;
  31520. /**
  31521. * The l2,1 coefficients of the spherical harmonics
  31522. */
  31523. l21: Vector3;
  31524. /**
  31525. * The l2,2 coefficients of the spherical harmonics
  31526. */
  31527. l22: Vector3;
  31528. /**
  31529. * Adds a light to the spherical harmonics
  31530. * @param direction the direction of the light
  31531. * @param color the color of the light
  31532. * @param deltaSolidAngle the delta solid angle of the light
  31533. */
  31534. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31535. /**
  31536. * Scales the spherical harmonics by the given amount
  31537. * @param scale the amount to scale
  31538. */
  31539. scaleInPlace(scale: number): void;
  31540. /**
  31541. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31542. *
  31543. * ```
  31544. * E_lm = A_l * L_lm
  31545. * ```
  31546. *
  31547. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31548. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31549. * the scaling factors are given in equation 9.
  31550. */
  31551. convertIncidentRadianceToIrradiance(): void;
  31552. /**
  31553. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31554. *
  31555. * ```
  31556. * L = (1/pi) * E * rho
  31557. * ```
  31558. *
  31559. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31560. */
  31561. convertIrradianceToLambertianRadiance(): void;
  31562. /**
  31563. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31564. * required operations at run time.
  31565. *
  31566. * This is simply done by scaling back the SH with Ylm constants parameter.
  31567. * The trigonometric part being applied by the shader at run time.
  31568. */
  31569. preScaleForRendering(): void;
  31570. /**
  31571. * Constructs a spherical harmonics from an array.
  31572. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31573. * @returns the spherical harmonics
  31574. */
  31575. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31576. /**
  31577. * Gets the spherical harmonics from polynomial
  31578. * @param polynomial the spherical polynomial
  31579. * @returns the spherical harmonics
  31580. */
  31581. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31582. }
  31583. /**
  31584. * Class representing spherical polynomial coefficients to the 3rd degree
  31585. */
  31586. export class SphericalPolynomial {
  31587. private _harmonics;
  31588. /**
  31589. * The spherical harmonics used to create the polynomials.
  31590. */
  31591. readonly preScaledHarmonics: SphericalHarmonics;
  31592. /**
  31593. * The x coefficients of the spherical polynomial
  31594. */
  31595. x: Vector3;
  31596. /**
  31597. * The y coefficients of the spherical polynomial
  31598. */
  31599. y: Vector3;
  31600. /**
  31601. * The z coefficients of the spherical polynomial
  31602. */
  31603. z: Vector3;
  31604. /**
  31605. * The xx coefficients of the spherical polynomial
  31606. */
  31607. xx: Vector3;
  31608. /**
  31609. * The yy coefficients of the spherical polynomial
  31610. */
  31611. yy: Vector3;
  31612. /**
  31613. * The zz coefficients of the spherical polynomial
  31614. */
  31615. zz: Vector3;
  31616. /**
  31617. * The xy coefficients of the spherical polynomial
  31618. */
  31619. xy: Vector3;
  31620. /**
  31621. * The yz coefficients of the spherical polynomial
  31622. */
  31623. yz: Vector3;
  31624. /**
  31625. * The zx coefficients of the spherical polynomial
  31626. */
  31627. zx: Vector3;
  31628. /**
  31629. * Adds an ambient color to the spherical polynomial
  31630. * @param color the color to add
  31631. */
  31632. addAmbient(color: Color3): void;
  31633. /**
  31634. * Scales the spherical polynomial by the given amount
  31635. * @param scale the amount to scale
  31636. */
  31637. scaleInPlace(scale: number): void;
  31638. /**
  31639. * Gets the spherical polynomial from harmonics
  31640. * @param harmonics the spherical harmonics
  31641. * @returns the spherical polynomial
  31642. */
  31643. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31644. /**
  31645. * Constructs a spherical polynomial from an array.
  31646. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31647. * @returns the spherical polynomial
  31648. */
  31649. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31650. }
  31651. }
  31652. declare module BABYLON {
  31653. /**
  31654. * Defines the source of the internal texture
  31655. */
  31656. export enum InternalTextureSource {
  31657. /**
  31658. * The source of the texture data is unknown
  31659. */
  31660. Unknown = 0,
  31661. /**
  31662. * Texture data comes from an URL
  31663. */
  31664. Url = 1,
  31665. /**
  31666. * Texture data is only used for temporary storage
  31667. */
  31668. Temp = 2,
  31669. /**
  31670. * Texture data comes from raw data (ArrayBuffer)
  31671. */
  31672. Raw = 3,
  31673. /**
  31674. * Texture content is dynamic (video or dynamic texture)
  31675. */
  31676. Dynamic = 4,
  31677. /**
  31678. * Texture content is generated by rendering to it
  31679. */
  31680. RenderTarget = 5,
  31681. /**
  31682. * Texture content is part of a multi render target process
  31683. */
  31684. MultiRenderTarget = 6,
  31685. /**
  31686. * Texture data comes from a cube data file
  31687. */
  31688. Cube = 7,
  31689. /**
  31690. * Texture data comes from a raw cube data
  31691. */
  31692. CubeRaw = 8,
  31693. /**
  31694. * Texture data come from a prefiltered cube data file
  31695. */
  31696. CubePrefiltered = 9,
  31697. /**
  31698. * Texture content is raw 3D data
  31699. */
  31700. Raw3D = 10,
  31701. /**
  31702. * Texture content is raw 2D array data
  31703. */
  31704. Raw2DArray = 11,
  31705. /**
  31706. * Texture content is a depth texture
  31707. */
  31708. Depth = 12,
  31709. /**
  31710. * Texture data comes from a raw cube data encoded with RGBD
  31711. */
  31712. CubeRawRGBD = 13
  31713. }
  31714. /**
  31715. * Class used to store data associated with WebGL texture data for the engine
  31716. * This class should not be used directly
  31717. */
  31718. export class InternalTexture {
  31719. /** @hidden */
  31720. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31721. /**
  31722. * Defines if the texture is ready
  31723. */
  31724. isReady: boolean;
  31725. /**
  31726. * Defines if the texture is a cube texture
  31727. */
  31728. isCube: boolean;
  31729. /**
  31730. * Defines if the texture contains 3D data
  31731. */
  31732. is3D: boolean;
  31733. /**
  31734. * Defines if the texture contains 2D array data
  31735. */
  31736. is2DArray: boolean;
  31737. /**
  31738. * Defines if the texture contains multiview data
  31739. */
  31740. isMultiview: boolean;
  31741. /**
  31742. * Gets the URL used to load this texture
  31743. */
  31744. url: string;
  31745. /**
  31746. * Gets the sampling mode of the texture
  31747. */
  31748. samplingMode: number;
  31749. /**
  31750. * Gets a boolean indicating if the texture needs mipmaps generation
  31751. */
  31752. generateMipMaps: boolean;
  31753. /**
  31754. * Gets the number of samples used by the texture (WebGL2+ only)
  31755. */
  31756. samples: number;
  31757. /**
  31758. * Gets the type of the texture (int, float...)
  31759. */
  31760. type: number;
  31761. /**
  31762. * Gets the format of the texture (RGB, RGBA...)
  31763. */
  31764. format: number;
  31765. /**
  31766. * Observable called when the texture is loaded
  31767. */
  31768. onLoadedObservable: Observable<InternalTexture>;
  31769. /**
  31770. * Gets the width of the texture
  31771. */
  31772. width: number;
  31773. /**
  31774. * Gets the height of the texture
  31775. */
  31776. height: number;
  31777. /**
  31778. * Gets the depth of the texture
  31779. */
  31780. depth: number;
  31781. /**
  31782. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31783. */
  31784. baseWidth: number;
  31785. /**
  31786. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31787. */
  31788. baseHeight: number;
  31789. /**
  31790. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31791. */
  31792. baseDepth: number;
  31793. /**
  31794. * Gets a boolean indicating if the texture is inverted on Y axis
  31795. */
  31796. invertY: boolean;
  31797. /** @hidden */
  31798. _invertVScale: boolean;
  31799. /** @hidden */
  31800. _associatedChannel: number;
  31801. /** @hidden */
  31802. _source: InternalTextureSource;
  31803. /** @hidden */
  31804. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31805. /** @hidden */
  31806. _bufferView: Nullable<ArrayBufferView>;
  31807. /** @hidden */
  31808. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31809. /** @hidden */
  31810. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31811. /** @hidden */
  31812. _size: number;
  31813. /** @hidden */
  31814. _extension: string;
  31815. /** @hidden */
  31816. _files: Nullable<string[]>;
  31817. /** @hidden */
  31818. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31819. /** @hidden */
  31820. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31821. /** @hidden */
  31822. _framebuffer: Nullable<WebGLFramebuffer>;
  31823. /** @hidden */
  31824. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31825. /** @hidden */
  31826. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31827. /** @hidden */
  31828. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31829. /** @hidden */
  31830. _attachments: Nullable<number[]>;
  31831. /** @hidden */
  31832. _cachedCoordinatesMode: Nullable<number>;
  31833. /** @hidden */
  31834. _cachedWrapU: Nullable<number>;
  31835. /** @hidden */
  31836. _cachedWrapV: Nullable<number>;
  31837. /** @hidden */
  31838. _cachedWrapR: Nullable<number>;
  31839. /** @hidden */
  31840. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31841. /** @hidden */
  31842. _isDisabled: boolean;
  31843. /** @hidden */
  31844. _compression: Nullable<string>;
  31845. /** @hidden */
  31846. _generateStencilBuffer: boolean;
  31847. /** @hidden */
  31848. _generateDepthBuffer: boolean;
  31849. /** @hidden */
  31850. _comparisonFunction: number;
  31851. /** @hidden */
  31852. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31853. /** @hidden */
  31854. _lodGenerationScale: number;
  31855. /** @hidden */
  31856. _lodGenerationOffset: number;
  31857. /** @hidden */
  31858. _colorTextureArray: Nullable<WebGLTexture>;
  31859. /** @hidden */
  31860. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31861. /** @hidden */
  31862. _lodTextureHigh: Nullable<BaseTexture>;
  31863. /** @hidden */
  31864. _lodTextureMid: Nullable<BaseTexture>;
  31865. /** @hidden */
  31866. _lodTextureLow: Nullable<BaseTexture>;
  31867. /** @hidden */
  31868. _isRGBD: boolean;
  31869. /** @hidden */
  31870. _linearSpecularLOD: boolean;
  31871. /** @hidden */
  31872. _irradianceTexture: Nullable<BaseTexture>;
  31873. /** @hidden */
  31874. _webGLTexture: Nullable<WebGLTexture>;
  31875. /** @hidden */
  31876. _references: number;
  31877. private _engine;
  31878. /**
  31879. * Gets the Engine the texture belongs to.
  31880. * @returns The babylon engine
  31881. */
  31882. getEngine(): ThinEngine;
  31883. /**
  31884. * Gets the data source type of the texture
  31885. */
  31886. readonly source: InternalTextureSource;
  31887. /**
  31888. * Creates a new InternalTexture
  31889. * @param engine defines the engine to use
  31890. * @param source defines the type of data that will be used
  31891. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31892. */
  31893. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31894. /**
  31895. * Increments the number of references (ie. the number of Texture that point to it)
  31896. */
  31897. incrementReferences(): void;
  31898. /**
  31899. * Change the size of the texture (not the size of the content)
  31900. * @param width defines the new width
  31901. * @param height defines the new height
  31902. * @param depth defines the new depth (1 by default)
  31903. */
  31904. updateSize(width: int, height: int, depth?: int): void;
  31905. /** @hidden */
  31906. _rebuild(): void;
  31907. /** @hidden */
  31908. _swapAndDie(target: InternalTexture): void;
  31909. /**
  31910. * Dispose the current allocated resources
  31911. */
  31912. dispose(): void;
  31913. }
  31914. }
  31915. declare module BABYLON {
  31916. /**
  31917. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31919. */
  31920. export class Analyser {
  31921. /**
  31922. * Gets or sets the smoothing
  31923. * @ignorenaming
  31924. */
  31925. SMOOTHING: number;
  31926. /**
  31927. * Gets or sets the FFT table size
  31928. * @ignorenaming
  31929. */
  31930. FFT_SIZE: number;
  31931. /**
  31932. * Gets or sets the bar graph amplitude
  31933. * @ignorenaming
  31934. */
  31935. BARGRAPHAMPLITUDE: number;
  31936. /**
  31937. * Gets or sets the position of the debug canvas
  31938. * @ignorenaming
  31939. */
  31940. DEBUGCANVASPOS: {
  31941. x: number;
  31942. y: number;
  31943. };
  31944. /**
  31945. * Gets or sets the debug canvas size
  31946. * @ignorenaming
  31947. */
  31948. DEBUGCANVASSIZE: {
  31949. width: number;
  31950. height: number;
  31951. };
  31952. private _byteFreqs;
  31953. private _byteTime;
  31954. private _floatFreqs;
  31955. private _webAudioAnalyser;
  31956. private _debugCanvas;
  31957. private _debugCanvasContext;
  31958. private _scene;
  31959. private _registerFunc;
  31960. private _audioEngine;
  31961. /**
  31962. * Creates a new analyser
  31963. * @param scene defines hosting scene
  31964. */
  31965. constructor(scene: Scene);
  31966. /**
  31967. * Get the number of data values you will have to play with for the visualization
  31968. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31969. * @returns a number
  31970. */
  31971. getFrequencyBinCount(): number;
  31972. /**
  31973. * Gets the current frequency data as a byte array
  31974. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31975. * @returns a Uint8Array
  31976. */
  31977. getByteFrequencyData(): Uint8Array;
  31978. /**
  31979. * Gets the current waveform as a byte array
  31980. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31981. * @returns a Uint8Array
  31982. */
  31983. getByteTimeDomainData(): Uint8Array;
  31984. /**
  31985. * Gets the current frequency data as a float array
  31986. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31987. * @returns a Float32Array
  31988. */
  31989. getFloatFrequencyData(): Float32Array;
  31990. /**
  31991. * Renders the debug canvas
  31992. */
  31993. drawDebugCanvas(): void;
  31994. /**
  31995. * Stops rendering the debug canvas and removes it
  31996. */
  31997. stopDebugCanvas(): void;
  31998. /**
  31999. * Connects two audio nodes
  32000. * @param inputAudioNode defines first node to connect
  32001. * @param outputAudioNode defines second node to connect
  32002. */
  32003. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32004. /**
  32005. * Releases all associated resources
  32006. */
  32007. dispose(): void;
  32008. }
  32009. }
  32010. declare module BABYLON {
  32011. /**
  32012. * This represents an audio engine and it is responsible
  32013. * to play, synchronize and analyse sounds throughout the application.
  32014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32015. */
  32016. export interface IAudioEngine extends IDisposable {
  32017. /**
  32018. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32019. */
  32020. readonly canUseWebAudio: boolean;
  32021. /**
  32022. * Gets the current AudioContext if available.
  32023. */
  32024. readonly audioContext: Nullable<AudioContext>;
  32025. /**
  32026. * The master gain node defines the global audio volume of your audio engine.
  32027. */
  32028. readonly masterGain: GainNode;
  32029. /**
  32030. * Gets whether or not mp3 are supported by your browser.
  32031. */
  32032. readonly isMP3supported: boolean;
  32033. /**
  32034. * Gets whether or not ogg are supported by your browser.
  32035. */
  32036. readonly isOGGsupported: boolean;
  32037. /**
  32038. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32039. * @ignoreNaming
  32040. */
  32041. WarnedWebAudioUnsupported: boolean;
  32042. /**
  32043. * Defines if the audio engine relies on a custom unlocked button.
  32044. * In this case, the embedded button will not be displayed.
  32045. */
  32046. useCustomUnlockedButton: boolean;
  32047. /**
  32048. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32049. */
  32050. readonly unlocked: boolean;
  32051. /**
  32052. * Event raised when audio has been unlocked on the browser.
  32053. */
  32054. onAudioUnlockedObservable: Observable<AudioEngine>;
  32055. /**
  32056. * Event raised when audio has been locked on the browser.
  32057. */
  32058. onAudioLockedObservable: Observable<AudioEngine>;
  32059. /**
  32060. * Flags the audio engine in Locked state.
  32061. * This happens due to new browser policies preventing audio to autoplay.
  32062. */
  32063. lock(): void;
  32064. /**
  32065. * Unlocks the audio engine once a user action has been done on the dom.
  32066. * This is helpful to resume play once browser policies have been satisfied.
  32067. */
  32068. unlock(): void;
  32069. }
  32070. /**
  32071. * This represents the default audio engine used in babylon.
  32072. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32074. */
  32075. export class AudioEngine implements IAudioEngine {
  32076. private _audioContext;
  32077. private _audioContextInitialized;
  32078. private _muteButton;
  32079. private _hostElement;
  32080. /**
  32081. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32082. */
  32083. canUseWebAudio: boolean;
  32084. /**
  32085. * The master gain node defines the global audio volume of your audio engine.
  32086. */
  32087. masterGain: GainNode;
  32088. /**
  32089. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32090. * @ignoreNaming
  32091. */
  32092. WarnedWebAudioUnsupported: boolean;
  32093. /**
  32094. * Gets whether or not mp3 are supported by your browser.
  32095. */
  32096. isMP3supported: boolean;
  32097. /**
  32098. * Gets whether or not ogg are supported by your browser.
  32099. */
  32100. isOGGsupported: boolean;
  32101. /**
  32102. * Gets whether audio has been unlocked on the device.
  32103. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32104. * a user interaction has happened.
  32105. */
  32106. unlocked: boolean;
  32107. /**
  32108. * Defines if the audio engine relies on a custom unlocked button.
  32109. * In this case, the embedded button will not be displayed.
  32110. */
  32111. useCustomUnlockedButton: boolean;
  32112. /**
  32113. * Event raised when audio has been unlocked on the browser.
  32114. */
  32115. onAudioUnlockedObservable: Observable<AudioEngine>;
  32116. /**
  32117. * Event raised when audio has been locked on the browser.
  32118. */
  32119. onAudioLockedObservable: Observable<AudioEngine>;
  32120. /**
  32121. * Gets the current AudioContext if available.
  32122. */
  32123. readonly audioContext: Nullable<AudioContext>;
  32124. private _connectedAnalyser;
  32125. /**
  32126. * Instantiates a new audio engine.
  32127. *
  32128. * There should be only one per page as some browsers restrict the number
  32129. * of audio contexts you can create.
  32130. * @param hostElement defines the host element where to display the mute icon if necessary
  32131. */
  32132. constructor(hostElement?: Nullable<HTMLElement>);
  32133. /**
  32134. * Flags the audio engine in Locked state.
  32135. * This happens due to new browser policies preventing audio to autoplay.
  32136. */
  32137. lock(): void;
  32138. /**
  32139. * Unlocks the audio engine once a user action has been done on the dom.
  32140. * This is helpful to resume play once browser policies have been satisfied.
  32141. */
  32142. unlock(): void;
  32143. private _resumeAudioContext;
  32144. private _initializeAudioContext;
  32145. private _tryToRun;
  32146. private _triggerRunningState;
  32147. private _triggerSuspendedState;
  32148. private _displayMuteButton;
  32149. private _moveButtonToTopLeft;
  32150. private _onResize;
  32151. private _hideMuteButton;
  32152. /**
  32153. * Destroy and release the resources associated with the audio ccontext.
  32154. */
  32155. dispose(): void;
  32156. /**
  32157. * Gets the global volume sets on the master gain.
  32158. * @returns the global volume if set or -1 otherwise
  32159. */
  32160. getGlobalVolume(): number;
  32161. /**
  32162. * Sets the global volume of your experience (sets on the master gain).
  32163. * @param newVolume Defines the new global volume of the application
  32164. */
  32165. setGlobalVolume(newVolume: number): void;
  32166. /**
  32167. * Connect the audio engine to an audio analyser allowing some amazing
  32168. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32170. * @param analyser The analyser to connect to the engine
  32171. */
  32172. connectToAnalyser(analyser: Analyser): void;
  32173. }
  32174. }
  32175. declare module BABYLON {
  32176. /**
  32177. * Interface used to present a loading screen while loading a scene
  32178. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32179. */
  32180. export interface ILoadingScreen {
  32181. /**
  32182. * Function called to display the loading screen
  32183. */
  32184. displayLoadingUI: () => void;
  32185. /**
  32186. * Function called to hide the loading screen
  32187. */
  32188. hideLoadingUI: () => void;
  32189. /**
  32190. * Gets or sets the color to use for the background
  32191. */
  32192. loadingUIBackgroundColor: string;
  32193. /**
  32194. * Gets or sets the text to display while loading
  32195. */
  32196. loadingUIText: string;
  32197. }
  32198. /**
  32199. * Class used for the default loading screen
  32200. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32201. */
  32202. export class DefaultLoadingScreen implements ILoadingScreen {
  32203. private _renderingCanvas;
  32204. private _loadingText;
  32205. private _loadingDivBackgroundColor;
  32206. private _loadingDiv;
  32207. private _loadingTextDiv;
  32208. /** Gets or sets the logo url to use for the default loading screen */
  32209. static DefaultLogoUrl: string;
  32210. /** Gets or sets the spinner url to use for the default loading screen */
  32211. static DefaultSpinnerUrl: string;
  32212. /**
  32213. * Creates a new default loading screen
  32214. * @param _renderingCanvas defines the canvas used to render the scene
  32215. * @param _loadingText defines the default text to display
  32216. * @param _loadingDivBackgroundColor defines the default background color
  32217. */
  32218. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32219. /**
  32220. * Function called to display the loading screen
  32221. */
  32222. displayLoadingUI(): void;
  32223. /**
  32224. * Function called to hide the loading screen
  32225. */
  32226. hideLoadingUI(): void;
  32227. /**
  32228. * Gets or sets the text to display while loading
  32229. */
  32230. loadingUIText: string;
  32231. /**
  32232. * Gets or sets the color to use for the background
  32233. */
  32234. loadingUIBackgroundColor: string;
  32235. private _resizeLoadingUI;
  32236. }
  32237. }
  32238. declare module BABYLON {
  32239. /**
  32240. * Interface for any object that can request an animation frame
  32241. */
  32242. export interface ICustomAnimationFrameRequester {
  32243. /**
  32244. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32245. */
  32246. renderFunction?: Function;
  32247. /**
  32248. * Called to request the next frame to render to
  32249. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32250. */
  32251. requestAnimationFrame: Function;
  32252. /**
  32253. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32254. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32255. */
  32256. requestID?: number;
  32257. }
  32258. }
  32259. declare module BABYLON {
  32260. /**
  32261. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32262. */
  32263. export class PerformanceMonitor {
  32264. private _enabled;
  32265. private _rollingFrameTime;
  32266. private _lastFrameTimeMs;
  32267. /**
  32268. * constructor
  32269. * @param frameSampleSize The number of samples required to saturate the sliding window
  32270. */
  32271. constructor(frameSampleSize?: number);
  32272. /**
  32273. * Samples current frame
  32274. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32275. */
  32276. sampleFrame(timeMs?: number): void;
  32277. /**
  32278. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32279. */
  32280. readonly averageFrameTime: number;
  32281. /**
  32282. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32283. */
  32284. readonly averageFrameTimeVariance: number;
  32285. /**
  32286. * Returns the frame time of the most recent frame
  32287. */
  32288. readonly instantaneousFrameTime: number;
  32289. /**
  32290. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32291. */
  32292. readonly averageFPS: number;
  32293. /**
  32294. * Returns the average framerate in frames per second using the most recent frame time
  32295. */
  32296. readonly instantaneousFPS: number;
  32297. /**
  32298. * Returns true if enough samples have been taken to completely fill the sliding window
  32299. */
  32300. readonly isSaturated: boolean;
  32301. /**
  32302. * Enables contributions to the sliding window sample set
  32303. */
  32304. enable(): void;
  32305. /**
  32306. * Disables contributions to the sliding window sample set
  32307. * Samples will not be interpolated over the disabled period
  32308. */
  32309. disable(): void;
  32310. /**
  32311. * Returns true if sampling is enabled
  32312. */
  32313. readonly isEnabled: boolean;
  32314. /**
  32315. * Resets performance monitor
  32316. */
  32317. reset(): void;
  32318. }
  32319. /**
  32320. * RollingAverage
  32321. *
  32322. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32323. */
  32324. export class RollingAverage {
  32325. /**
  32326. * Current average
  32327. */
  32328. average: number;
  32329. /**
  32330. * Current variance
  32331. */
  32332. variance: number;
  32333. protected _samples: Array<number>;
  32334. protected _sampleCount: number;
  32335. protected _pos: number;
  32336. protected _m2: number;
  32337. /**
  32338. * constructor
  32339. * @param length The number of samples required to saturate the sliding window
  32340. */
  32341. constructor(length: number);
  32342. /**
  32343. * Adds a sample to the sample set
  32344. * @param v The sample value
  32345. */
  32346. add(v: number): void;
  32347. /**
  32348. * Returns previously added values or null if outside of history or outside the sliding window domain
  32349. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32350. * @return Value previously recorded with add() or null if outside of range
  32351. */
  32352. history(i: number): number;
  32353. /**
  32354. * Returns true if enough samples have been taken to completely fill the sliding window
  32355. * @return true if sample-set saturated
  32356. */
  32357. isSaturated(): boolean;
  32358. /**
  32359. * Resets the rolling average (equivalent to 0 samples taken so far)
  32360. */
  32361. reset(): void;
  32362. /**
  32363. * Wraps a value around the sample range boundaries
  32364. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32365. * @return Wrapped position in sample range
  32366. */
  32367. protected _wrapPosition(i: number): number;
  32368. }
  32369. }
  32370. declare module BABYLON {
  32371. /**
  32372. * This class is used to track a performance counter which is number based.
  32373. * The user has access to many properties which give statistics of different nature.
  32374. *
  32375. * The implementer can track two kinds of Performance Counter: time and count.
  32376. * 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.
  32377. * 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.
  32378. */
  32379. export class PerfCounter {
  32380. /**
  32381. * Gets or sets a global boolean to turn on and off all the counters
  32382. */
  32383. static Enabled: boolean;
  32384. /**
  32385. * Returns the smallest value ever
  32386. */
  32387. readonly min: number;
  32388. /**
  32389. * Returns the biggest value ever
  32390. */
  32391. readonly max: number;
  32392. /**
  32393. * Returns the average value since the performance counter is running
  32394. */
  32395. readonly average: number;
  32396. /**
  32397. * Returns the average value of the last second the counter was monitored
  32398. */
  32399. readonly lastSecAverage: number;
  32400. /**
  32401. * Returns the current value
  32402. */
  32403. readonly current: number;
  32404. /**
  32405. * Gets the accumulated total
  32406. */
  32407. readonly total: number;
  32408. /**
  32409. * Gets the total value count
  32410. */
  32411. readonly count: number;
  32412. /**
  32413. * Creates a new counter
  32414. */
  32415. constructor();
  32416. /**
  32417. * Call this method to start monitoring a new frame.
  32418. * 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.
  32419. */
  32420. fetchNewFrame(): void;
  32421. /**
  32422. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32423. * @param newCount the count value to add to the monitored count
  32424. * @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.
  32425. */
  32426. addCount(newCount: number, fetchResult: boolean): void;
  32427. /**
  32428. * Start monitoring this performance counter
  32429. */
  32430. beginMonitoring(): void;
  32431. /**
  32432. * Compute the time lapsed since the previous beginMonitoring() call.
  32433. * @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
  32434. */
  32435. endMonitoring(newFrame?: boolean): void;
  32436. private _fetchResult;
  32437. private _startMonitoringTime;
  32438. private _min;
  32439. private _max;
  32440. private _average;
  32441. private _current;
  32442. private _totalValueCount;
  32443. private _totalAccumulated;
  32444. private _lastSecAverage;
  32445. private _lastSecAccumulated;
  32446. private _lastSecTime;
  32447. private _lastSecValueCount;
  32448. }
  32449. }
  32450. declare module BABYLON {
  32451. interface ThinEngine {
  32452. /**
  32453. * Sets alpha constants used by some alpha blending modes
  32454. * @param r defines the red component
  32455. * @param g defines the green component
  32456. * @param b defines the blue component
  32457. * @param a defines the alpha component
  32458. */
  32459. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32460. /**
  32461. * Sets the current alpha mode
  32462. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32463. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32464. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32465. */
  32466. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32467. /**
  32468. * Gets the current alpha mode
  32469. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32470. * @returns the current alpha mode
  32471. */
  32472. getAlphaMode(): number;
  32473. /**
  32474. * Sets the current alpha equation
  32475. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32476. */
  32477. setAlphaEquation(equation: number): void;
  32478. /**
  32479. * Gets the current alpha equation.
  32480. * @returns the current alpha equation
  32481. */
  32482. getAlphaEquation(): number;
  32483. }
  32484. }
  32485. declare module BABYLON {
  32486. /**
  32487. * Defines the interface used by display changed events
  32488. */
  32489. export interface IDisplayChangedEventArgs {
  32490. /** Gets the vrDisplay object (if any) */
  32491. vrDisplay: Nullable<any>;
  32492. /** Gets a boolean indicating if webVR is supported */
  32493. vrSupported: boolean;
  32494. }
  32495. /**
  32496. * Defines the interface used by objects containing a viewport (like a camera)
  32497. */
  32498. interface IViewportOwnerLike {
  32499. /**
  32500. * Gets or sets the viewport
  32501. */
  32502. viewport: IViewportLike;
  32503. }
  32504. /**
  32505. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32506. */
  32507. export class Engine extends ThinEngine {
  32508. /** Defines that alpha blending is disabled */
  32509. static readonly ALPHA_DISABLE: number;
  32510. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32511. static readonly ALPHA_ADD: number;
  32512. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32513. static readonly ALPHA_COMBINE: number;
  32514. /** Defines that alpha blending to DEST - SRC * DEST */
  32515. static readonly ALPHA_SUBTRACT: number;
  32516. /** Defines that alpha blending to SRC * DEST */
  32517. static readonly ALPHA_MULTIPLY: number;
  32518. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32519. static readonly ALPHA_MAXIMIZED: number;
  32520. /** Defines that alpha blending to SRC + DEST */
  32521. static readonly ALPHA_ONEONE: number;
  32522. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32523. static readonly ALPHA_PREMULTIPLIED: number;
  32524. /**
  32525. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32526. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32527. */
  32528. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32529. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32530. static readonly ALPHA_INTERPOLATE: number;
  32531. /**
  32532. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32533. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32534. */
  32535. static readonly ALPHA_SCREENMODE: number;
  32536. /** Defines that the ressource is not delayed*/
  32537. static readonly DELAYLOADSTATE_NONE: number;
  32538. /** Defines that the ressource was successfully delay loaded */
  32539. static readonly DELAYLOADSTATE_LOADED: number;
  32540. /** Defines that the ressource is currently delay loading */
  32541. static readonly DELAYLOADSTATE_LOADING: number;
  32542. /** Defines that the ressource is delayed and has not started loading */
  32543. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32544. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32545. static readonly NEVER: number;
  32546. /** 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 */
  32547. static readonly ALWAYS: number;
  32548. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32549. static readonly LESS: number;
  32550. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32551. static readonly EQUAL: number;
  32552. /** 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 */
  32553. static readonly LEQUAL: number;
  32554. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32555. static readonly GREATER: number;
  32556. /** 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 */
  32557. static readonly GEQUAL: number;
  32558. /** 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 */
  32559. static readonly NOTEQUAL: number;
  32560. /** Passed to stencilOperation to specify that stencil value must be kept */
  32561. static readonly KEEP: number;
  32562. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32563. static readonly REPLACE: number;
  32564. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32565. static readonly INCR: number;
  32566. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32567. static readonly DECR: number;
  32568. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32569. static readonly INVERT: number;
  32570. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32571. static readonly INCR_WRAP: number;
  32572. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32573. static readonly DECR_WRAP: number;
  32574. /** Texture is not repeating outside of 0..1 UVs */
  32575. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32576. /** Texture is repeating outside of 0..1 UVs */
  32577. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32578. /** Texture is repeating and mirrored */
  32579. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32580. /** ALPHA */
  32581. static readonly TEXTUREFORMAT_ALPHA: number;
  32582. /** LUMINANCE */
  32583. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32584. /** LUMINANCE_ALPHA */
  32585. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32586. /** RGB */
  32587. static readonly TEXTUREFORMAT_RGB: number;
  32588. /** RGBA */
  32589. static readonly TEXTUREFORMAT_RGBA: number;
  32590. /** RED */
  32591. static readonly TEXTUREFORMAT_RED: number;
  32592. /** RED (2nd reference) */
  32593. static readonly TEXTUREFORMAT_R: number;
  32594. /** RG */
  32595. static readonly TEXTUREFORMAT_RG: number;
  32596. /** RED_INTEGER */
  32597. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32598. /** RED_INTEGER (2nd reference) */
  32599. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32600. /** RG_INTEGER */
  32601. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32602. /** RGB_INTEGER */
  32603. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32604. /** RGBA_INTEGER */
  32605. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32606. /** UNSIGNED_BYTE */
  32607. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32608. /** UNSIGNED_BYTE (2nd reference) */
  32609. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32610. /** FLOAT */
  32611. static readonly TEXTURETYPE_FLOAT: number;
  32612. /** HALF_FLOAT */
  32613. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32614. /** BYTE */
  32615. static readonly TEXTURETYPE_BYTE: number;
  32616. /** SHORT */
  32617. static readonly TEXTURETYPE_SHORT: number;
  32618. /** UNSIGNED_SHORT */
  32619. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32620. /** INT */
  32621. static readonly TEXTURETYPE_INT: number;
  32622. /** UNSIGNED_INT */
  32623. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32624. /** UNSIGNED_SHORT_4_4_4_4 */
  32625. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32626. /** UNSIGNED_SHORT_5_5_5_1 */
  32627. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32628. /** UNSIGNED_SHORT_5_6_5 */
  32629. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32630. /** UNSIGNED_INT_2_10_10_10_REV */
  32631. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32632. /** UNSIGNED_INT_24_8 */
  32633. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32634. /** UNSIGNED_INT_10F_11F_11F_REV */
  32635. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32636. /** UNSIGNED_INT_5_9_9_9_REV */
  32637. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32638. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32639. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32640. /** nearest is mag = nearest and min = nearest and mip = linear */
  32641. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32642. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32643. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32644. /** Trilinear is mag = linear and min = linear and mip = linear */
  32645. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32646. /** nearest is mag = nearest and min = nearest and mip = linear */
  32647. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32648. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32649. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32650. /** Trilinear is mag = linear and min = linear and mip = linear */
  32651. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32652. /** mag = nearest and min = nearest and mip = nearest */
  32653. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32654. /** mag = nearest and min = linear and mip = nearest */
  32655. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32656. /** mag = nearest and min = linear and mip = linear */
  32657. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32658. /** mag = nearest and min = linear and mip = none */
  32659. static readonly TEXTURE_NEAREST_LINEAR: number;
  32660. /** mag = nearest and min = nearest and mip = none */
  32661. static readonly TEXTURE_NEAREST_NEAREST: number;
  32662. /** mag = linear and min = nearest and mip = nearest */
  32663. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32664. /** mag = linear and min = nearest and mip = linear */
  32665. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32666. /** mag = linear and min = linear and mip = none */
  32667. static readonly TEXTURE_LINEAR_LINEAR: number;
  32668. /** mag = linear and min = nearest and mip = none */
  32669. static readonly TEXTURE_LINEAR_NEAREST: number;
  32670. /** Explicit coordinates mode */
  32671. static readonly TEXTURE_EXPLICIT_MODE: number;
  32672. /** Spherical coordinates mode */
  32673. static readonly TEXTURE_SPHERICAL_MODE: number;
  32674. /** Planar coordinates mode */
  32675. static readonly TEXTURE_PLANAR_MODE: number;
  32676. /** Cubic coordinates mode */
  32677. static readonly TEXTURE_CUBIC_MODE: number;
  32678. /** Projection coordinates mode */
  32679. static readonly TEXTURE_PROJECTION_MODE: number;
  32680. /** Skybox coordinates mode */
  32681. static readonly TEXTURE_SKYBOX_MODE: number;
  32682. /** Inverse Cubic coordinates mode */
  32683. static readonly TEXTURE_INVCUBIC_MODE: number;
  32684. /** Equirectangular coordinates mode */
  32685. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32686. /** Equirectangular Fixed coordinates mode */
  32687. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32688. /** Equirectangular Fixed Mirrored coordinates mode */
  32689. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32690. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32691. static readonly SCALEMODE_FLOOR: number;
  32692. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32693. static readonly SCALEMODE_NEAREST: number;
  32694. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32695. static readonly SCALEMODE_CEILING: number;
  32696. /**
  32697. * Returns the current npm package of the sdk
  32698. */
  32699. static readonly NpmPackage: string;
  32700. /**
  32701. * Returns the current version of the framework
  32702. */
  32703. static readonly Version: string;
  32704. /** Gets the list of created engines */
  32705. static readonly Instances: Engine[];
  32706. /**
  32707. * Gets the latest created engine
  32708. */
  32709. static readonly LastCreatedEngine: Nullable<Engine>;
  32710. /**
  32711. * Gets the latest created scene
  32712. */
  32713. static readonly LastCreatedScene: Nullable<Scene>;
  32714. /**
  32715. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32716. * @param flag defines which part of the materials must be marked as dirty
  32717. * @param predicate defines a predicate used to filter which materials should be affected
  32718. */
  32719. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32720. /**
  32721. * Method called to create the default loading screen.
  32722. * This can be overriden in your own app.
  32723. * @param canvas The rendering canvas element
  32724. * @returns The loading screen
  32725. */
  32726. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32727. /**
  32728. * Method called to create the default rescale post process on each engine.
  32729. */
  32730. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32731. /**
  32732. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32733. **/
  32734. enableOfflineSupport: boolean;
  32735. /**
  32736. * 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)
  32737. **/
  32738. disableManifestCheck: boolean;
  32739. /**
  32740. * Gets the list of created scenes
  32741. */
  32742. scenes: Scene[];
  32743. /**
  32744. * Event raised when a new scene is created
  32745. */
  32746. onNewSceneAddedObservable: Observable<Scene>;
  32747. /**
  32748. * Gets the list of created postprocesses
  32749. */
  32750. postProcesses: PostProcess[];
  32751. /**
  32752. * Gets a boolean indicating if the pointer is currently locked
  32753. */
  32754. isPointerLock: boolean;
  32755. /**
  32756. * Observable event triggered each time the rendering canvas is resized
  32757. */
  32758. onResizeObservable: Observable<Engine>;
  32759. /**
  32760. * Observable event triggered each time the canvas loses focus
  32761. */
  32762. onCanvasBlurObservable: Observable<Engine>;
  32763. /**
  32764. * Observable event triggered each time the canvas gains focus
  32765. */
  32766. onCanvasFocusObservable: Observable<Engine>;
  32767. /**
  32768. * Observable event triggered each time the canvas receives pointerout event
  32769. */
  32770. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32771. /**
  32772. * Observable raised when the engine begins a new frame
  32773. */
  32774. onBeginFrameObservable: Observable<Engine>;
  32775. /**
  32776. * If set, will be used to request the next animation frame for the render loop
  32777. */
  32778. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32779. /**
  32780. * Observable raised when the engine ends the current frame
  32781. */
  32782. onEndFrameObservable: Observable<Engine>;
  32783. /**
  32784. * Observable raised when the engine is about to compile a shader
  32785. */
  32786. onBeforeShaderCompilationObservable: Observable<Engine>;
  32787. /**
  32788. * Observable raised when the engine has jsut compiled a shader
  32789. */
  32790. onAfterShaderCompilationObservable: Observable<Engine>;
  32791. /**
  32792. * Gets the audio engine
  32793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32794. * @ignorenaming
  32795. */
  32796. static audioEngine: IAudioEngine;
  32797. /**
  32798. * Default AudioEngine factory responsible of creating the Audio Engine.
  32799. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32800. */
  32801. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32802. /**
  32803. * Default offline support factory responsible of creating a tool used to store data locally.
  32804. * By default, this will create a Database object if the workload has been embedded.
  32805. */
  32806. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32807. private _loadingScreen;
  32808. private _pointerLockRequested;
  32809. private _dummyFramebuffer;
  32810. private _rescalePostProcess;
  32811. private _deterministicLockstep;
  32812. private _lockstepMaxSteps;
  32813. private _timeStep;
  32814. protected readonly _supportsHardwareTextureRescaling: boolean;
  32815. private _fps;
  32816. private _deltaTime;
  32817. /** @hidden */
  32818. _drawCalls: PerfCounter;
  32819. /**
  32820. * Turn this value on if you want to pause FPS computation when in background
  32821. */
  32822. disablePerformanceMonitorInBackground: boolean;
  32823. private _performanceMonitor;
  32824. /**
  32825. * Gets the performance monitor attached to this engine
  32826. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32827. */
  32828. readonly performanceMonitor: PerformanceMonitor;
  32829. private _onFocus;
  32830. private _onBlur;
  32831. private _onCanvasPointerOut;
  32832. private _onCanvasBlur;
  32833. private _onCanvasFocus;
  32834. private _onFullscreenChange;
  32835. private _onPointerLockChange;
  32836. /**
  32837. * Gets the HTML element used to attach event listeners
  32838. * @returns a HTML element
  32839. */
  32840. getInputElement(): Nullable<HTMLElement>;
  32841. /**
  32842. * Creates a new engine
  32843. * @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
  32844. * @param antialias defines enable antialiasing (default: false)
  32845. * @param options defines further options to be sent to the getContext() function
  32846. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32847. */
  32848. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32849. /**
  32850. * Gets current aspect ratio
  32851. * @param viewportOwner defines the camera to use to get the aspect ratio
  32852. * @param useScreen defines if screen size must be used (or the current render target if any)
  32853. * @returns a number defining the aspect ratio
  32854. */
  32855. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32856. /**
  32857. * Gets current screen aspect ratio
  32858. * @returns a number defining the aspect ratio
  32859. */
  32860. getScreenAspectRatio(): number;
  32861. /**
  32862. * Gets the client rect of the HTML canvas attached with the current webGL context
  32863. * @returns a client rectanglee
  32864. */
  32865. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32866. /**
  32867. * Gets the client rect of the HTML element used for events
  32868. * @returns a client rectanglee
  32869. */
  32870. getInputElementClientRect(): Nullable<ClientRect>;
  32871. /**
  32872. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32873. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32874. * @returns true if engine is in deterministic lock step mode
  32875. */
  32876. isDeterministicLockStep(): boolean;
  32877. /**
  32878. * Gets the max steps when engine is running in deterministic lock step
  32879. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32880. * @returns the max steps
  32881. */
  32882. getLockstepMaxSteps(): number;
  32883. /**
  32884. * Returns the time in ms between steps when using deterministic lock step.
  32885. * @returns time step in (ms)
  32886. */
  32887. getTimeStep(): number;
  32888. /**
  32889. * Force the mipmap generation for the given render target texture
  32890. * @param texture defines the render target texture to use
  32891. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  32892. */
  32893. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  32894. /** States */
  32895. /**
  32896. * Set various states to the webGL context
  32897. * @param culling defines backface culling state
  32898. * @param zOffset defines the value to apply to zOffset (0 by default)
  32899. * @param force defines if states must be applied even if cache is up to date
  32900. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32901. */
  32902. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32903. /**
  32904. * Set the z offset to apply to current rendering
  32905. * @param value defines the offset to apply
  32906. */
  32907. setZOffset(value: number): void;
  32908. /**
  32909. * Gets the current value of the zOffset
  32910. * @returns the current zOffset state
  32911. */
  32912. getZOffset(): number;
  32913. /**
  32914. * Enable or disable depth buffering
  32915. * @param enable defines the state to set
  32916. */
  32917. setDepthBuffer(enable: boolean): void;
  32918. /**
  32919. * Gets a boolean indicating if depth writing is enabled
  32920. * @returns the current depth writing state
  32921. */
  32922. getDepthWrite(): boolean;
  32923. /**
  32924. * Enable or disable depth writing
  32925. * @param enable defines the state to set
  32926. */
  32927. setDepthWrite(enable: boolean): void;
  32928. /**
  32929. * Gets a boolean indicating if stencil buffer is enabled
  32930. * @returns the current stencil buffer state
  32931. */
  32932. getStencilBuffer(): boolean;
  32933. /**
  32934. * Enable or disable the stencil buffer
  32935. * @param enable defines if the stencil buffer must be enabled or disabled
  32936. */
  32937. setStencilBuffer(enable: boolean): void;
  32938. /**
  32939. * Gets the current stencil mask
  32940. * @returns a number defining the new stencil mask to use
  32941. */
  32942. getStencilMask(): number;
  32943. /**
  32944. * Sets the current stencil mask
  32945. * @param mask defines the new stencil mask to use
  32946. */
  32947. setStencilMask(mask: number): void;
  32948. /**
  32949. * Gets the current stencil function
  32950. * @returns a number defining the stencil function to use
  32951. */
  32952. getStencilFunction(): number;
  32953. /**
  32954. * Gets the current stencil reference value
  32955. * @returns a number defining the stencil reference value to use
  32956. */
  32957. getStencilFunctionReference(): number;
  32958. /**
  32959. * Gets the current stencil mask
  32960. * @returns a number defining the stencil mask to use
  32961. */
  32962. getStencilFunctionMask(): number;
  32963. /**
  32964. * Sets the current stencil function
  32965. * @param stencilFunc defines the new stencil function to use
  32966. */
  32967. setStencilFunction(stencilFunc: number): void;
  32968. /**
  32969. * Sets the current stencil reference
  32970. * @param reference defines the new stencil reference to use
  32971. */
  32972. setStencilFunctionReference(reference: number): void;
  32973. /**
  32974. * Sets the current stencil mask
  32975. * @param mask defines the new stencil mask to use
  32976. */
  32977. setStencilFunctionMask(mask: number): void;
  32978. /**
  32979. * Gets the current stencil operation when stencil fails
  32980. * @returns a number defining stencil operation to use when stencil fails
  32981. */
  32982. getStencilOperationFail(): number;
  32983. /**
  32984. * Gets the current stencil operation when depth fails
  32985. * @returns a number defining stencil operation to use when depth fails
  32986. */
  32987. getStencilOperationDepthFail(): number;
  32988. /**
  32989. * Gets the current stencil operation when stencil passes
  32990. * @returns a number defining stencil operation to use when stencil passes
  32991. */
  32992. getStencilOperationPass(): number;
  32993. /**
  32994. * Sets the stencil operation to use when stencil fails
  32995. * @param operation defines the stencil operation to use when stencil fails
  32996. */
  32997. setStencilOperationFail(operation: number): void;
  32998. /**
  32999. * Sets the stencil operation to use when depth fails
  33000. * @param operation defines the stencil operation to use when depth fails
  33001. */
  33002. setStencilOperationDepthFail(operation: number): void;
  33003. /**
  33004. * Sets the stencil operation to use when stencil passes
  33005. * @param operation defines the stencil operation to use when stencil passes
  33006. */
  33007. setStencilOperationPass(operation: number): void;
  33008. /**
  33009. * Sets a boolean indicating if the dithering state is enabled or disabled
  33010. * @param value defines the dithering state
  33011. */
  33012. setDitheringState(value: boolean): void;
  33013. /**
  33014. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33015. * @param value defines the rasterizer state
  33016. */
  33017. setRasterizerState(value: boolean): void;
  33018. /**
  33019. * Gets the current depth function
  33020. * @returns a number defining the depth function
  33021. */
  33022. getDepthFunction(): Nullable<number>;
  33023. /**
  33024. * Sets the current depth function
  33025. * @param depthFunc defines the function to use
  33026. */
  33027. setDepthFunction(depthFunc: number): void;
  33028. /**
  33029. * Sets the current depth function to GREATER
  33030. */
  33031. setDepthFunctionToGreater(): void;
  33032. /**
  33033. * Sets the current depth function to GEQUAL
  33034. */
  33035. setDepthFunctionToGreaterOrEqual(): void;
  33036. /**
  33037. * Sets the current depth function to LESS
  33038. */
  33039. setDepthFunctionToLess(): void;
  33040. /**
  33041. * Sets the current depth function to LEQUAL
  33042. */
  33043. setDepthFunctionToLessOrEqual(): void;
  33044. private _cachedStencilBuffer;
  33045. private _cachedStencilFunction;
  33046. private _cachedStencilMask;
  33047. private _cachedStencilOperationPass;
  33048. private _cachedStencilOperationFail;
  33049. private _cachedStencilOperationDepthFail;
  33050. private _cachedStencilReference;
  33051. /**
  33052. * Caches the the state of the stencil buffer
  33053. */
  33054. cacheStencilState(): void;
  33055. /**
  33056. * Restores the state of the stencil buffer
  33057. */
  33058. restoreStencilState(): void;
  33059. /**
  33060. * Directly set the WebGL Viewport
  33061. * @param x defines the x coordinate of the viewport (in screen space)
  33062. * @param y defines the y coordinate of the viewport (in screen space)
  33063. * @param width defines the width of the viewport (in screen space)
  33064. * @param height defines the height of the viewport (in screen space)
  33065. * @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
  33066. */
  33067. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33068. /**
  33069. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33070. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33071. * @param y defines the y-coordinate of the corner of the clear rectangle
  33072. * @param width defines the width of the clear rectangle
  33073. * @param height defines the height of the clear rectangle
  33074. * @param clearColor defines the clear color
  33075. */
  33076. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33077. /**
  33078. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33079. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33080. * @param y defines the y-coordinate of the corner of the clear rectangle
  33081. * @param width defines the width of the clear rectangle
  33082. * @param height defines the height of the clear rectangle
  33083. */
  33084. enableScissor(x: number, y: number, width: number, height: number): void;
  33085. /**
  33086. * Disable previously set scissor test rectangle
  33087. */
  33088. disableScissor(): void;
  33089. protected _reportDrawCall(): void;
  33090. /**
  33091. * Initializes a webVR display and starts listening to display change events
  33092. * The onVRDisplayChangedObservable will be notified upon these changes
  33093. * @returns The onVRDisplayChangedObservable
  33094. */
  33095. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33096. /** @hidden */
  33097. _prepareVRComponent(): void;
  33098. /** @hidden */
  33099. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33100. /** @hidden */
  33101. _submitVRFrame(): void;
  33102. /**
  33103. * Call this function to leave webVR mode
  33104. * Will do nothing if webVR is not supported or if there is no webVR device
  33105. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33106. */
  33107. disableVR(): void;
  33108. /**
  33109. * Gets a boolean indicating that the system is in VR mode and is presenting
  33110. * @returns true if VR mode is engaged
  33111. */
  33112. isVRPresenting(): boolean;
  33113. /** @hidden */
  33114. _requestVRFrame(): void;
  33115. /** @hidden */
  33116. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33117. /**
  33118. * Gets the source code of the vertex shader associated with a specific webGL program
  33119. * @param program defines the program to use
  33120. * @returns a string containing the source code of the vertex shader associated with the program
  33121. */
  33122. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33123. /**
  33124. * Gets the source code of the fragment shader associated with a specific webGL program
  33125. * @param program defines the program to use
  33126. * @returns a string containing the source code of the fragment shader associated with the program
  33127. */
  33128. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33129. /**
  33130. * Sets a depth stencil texture from a render target to the according uniform.
  33131. * @param channel The texture channel
  33132. * @param uniform The uniform to set
  33133. * @param texture The render target texture containing the depth stencil texture to apply
  33134. */
  33135. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33136. /**
  33137. * Sets a texture to the webGL context from a postprocess
  33138. * @param channel defines the channel to use
  33139. * @param postProcess defines the source postprocess
  33140. */
  33141. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33142. /**
  33143. * Binds the output of the passed in post process to the texture channel specified
  33144. * @param channel The channel the texture should be bound to
  33145. * @param postProcess The post process which's output should be bound
  33146. */
  33147. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33148. /** @hidden */
  33149. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33150. protected _rebuildBuffers(): void;
  33151. /** @hidden */
  33152. _renderFrame(): void;
  33153. _renderLoop(): void;
  33154. /** @hidden */
  33155. _renderViews(): boolean;
  33156. /**
  33157. * Toggle full screen mode
  33158. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33159. */
  33160. switchFullscreen(requestPointerLock: boolean): void;
  33161. /**
  33162. * Enters full screen mode
  33163. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33164. */
  33165. enterFullscreen(requestPointerLock: boolean): void;
  33166. /**
  33167. * Exits full screen mode
  33168. */
  33169. exitFullscreen(): void;
  33170. /**
  33171. * Enters Pointerlock mode
  33172. */
  33173. enterPointerlock(): void;
  33174. /**
  33175. * Exits Pointerlock mode
  33176. */
  33177. exitPointerlock(): void;
  33178. /**
  33179. * Begin a new frame
  33180. */
  33181. beginFrame(): void;
  33182. /**
  33183. * Enf the current frame
  33184. */
  33185. endFrame(): void;
  33186. resize(): void;
  33187. /**
  33188. * Set the compressed texture format to use, based on the formats you have, and the formats
  33189. * supported by the hardware / browser.
  33190. *
  33191. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33192. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33193. * to API arguments needed to compressed textures. This puts the burden on the container
  33194. * generator to house the arcane code for determining these for current & future formats.
  33195. *
  33196. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33197. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33198. *
  33199. * Note: The result of this call is not taken into account when a texture is base64.
  33200. *
  33201. * @param formatsAvailable defines the list of those format families you have created
  33202. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33203. *
  33204. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33205. * @returns The extension selected.
  33206. */
  33207. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33208. /**
  33209. * Set the compressed texture extensions or file names to skip.
  33210. *
  33211. * @param skippedFiles defines the list of those texture files you want to skip
  33212. * Example: [".dds", ".env", "myfile.png"]
  33213. */
  33214. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33215. /**
  33216. * Force a specific size of the canvas
  33217. * @param width defines the new canvas' width
  33218. * @param height defines the new canvas' height
  33219. */
  33220. setSize(width: number, height: number): void;
  33221. /**
  33222. * Updates a dynamic vertex buffer.
  33223. * @param vertexBuffer the vertex buffer to update
  33224. * @param data the data used to update the vertex buffer
  33225. * @param byteOffset the byte offset of the data
  33226. * @param byteLength the byte length of the data
  33227. */
  33228. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33229. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33230. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33231. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33232. _releaseTexture(texture: InternalTexture): void;
  33233. /**
  33234. * @hidden
  33235. * Rescales a texture
  33236. * @param source input texutre
  33237. * @param destination destination texture
  33238. * @param scene scene to use to render the resize
  33239. * @param internalFormat format to use when resizing
  33240. * @param onComplete callback to be called when resize has completed
  33241. */
  33242. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33243. /**
  33244. * Gets the current framerate
  33245. * @returns a number representing the framerate
  33246. */
  33247. getFps(): number;
  33248. /**
  33249. * Gets the time spent between current and previous frame
  33250. * @returns a number representing the delta time in ms
  33251. */
  33252. getDeltaTime(): number;
  33253. private _measureFps;
  33254. /** @hidden */
  33255. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33256. /**
  33257. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33258. * @param renderTarget The render target to set the frame buffer for
  33259. */
  33260. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33261. /**
  33262. * Update a dynamic index buffer
  33263. * @param indexBuffer defines the target index buffer
  33264. * @param indices defines the data to update
  33265. * @param offset defines the offset in the target index buffer where update should start
  33266. */
  33267. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33268. /**
  33269. * Updates the sample count of a render target texture
  33270. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33271. * @param texture defines the texture to update
  33272. * @param samples defines the sample count to set
  33273. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33274. */
  33275. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33276. /**
  33277. * Updates a depth texture Comparison Mode and Function.
  33278. * If the comparison Function is equal to 0, the mode will be set to none.
  33279. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33280. * @param texture The texture to set the comparison function for
  33281. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33282. */
  33283. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33284. /**
  33285. * Creates a webGL buffer to use with instanciation
  33286. * @param capacity defines the size of the buffer
  33287. * @returns the webGL buffer
  33288. */
  33289. createInstancesBuffer(capacity: number): DataBuffer;
  33290. /**
  33291. * Delete a webGL buffer used with instanciation
  33292. * @param buffer defines the webGL buffer to delete
  33293. */
  33294. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33295. /** @hidden */
  33296. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33297. dispose(): void;
  33298. private _disableTouchAction;
  33299. /**
  33300. * Display the loading screen
  33301. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33302. */
  33303. displayLoadingUI(): void;
  33304. /**
  33305. * Hide the loading screen
  33306. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33307. */
  33308. hideLoadingUI(): void;
  33309. /**
  33310. * Gets the current loading screen object
  33311. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33312. */
  33313. /**
  33314. * Sets the current loading screen object
  33315. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33316. */
  33317. loadingScreen: ILoadingScreen;
  33318. /**
  33319. * Sets the current loading screen text
  33320. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33321. */
  33322. loadingUIText: string;
  33323. /**
  33324. * Sets the current loading screen background color
  33325. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33326. */
  33327. loadingUIBackgroundColor: string;
  33328. /** Pointerlock and fullscreen */
  33329. /**
  33330. * Ask the browser to promote the current element to pointerlock mode
  33331. * @param element defines the DOM element to promote
  33332. */
  33333. static _RequestPointerlock(element: HTMLElement): void;
  33334. /**
  33335. * Asks the browser to exit pointerlock mode
  33336. */
  33337. static _ExitPointerlock(): void;
  33338. /**
  33339. * Ask the browser to promote the current element to fullscreen rendering mode
  33340. * @param element defines the DOM element to promote
  33341. */
  33342. static _RequestFullscreen(element: HTMLElement): void;
  33343. /**
  33344. * Asks the browser to exit fullscreen mode
  33345. */
  33346. static _ExitFullscreen(): void;
  33347. }
  33348. }
  33349. declare module BABYLON {
  33350. /**
  33351. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33352. * during the life time of the application.
  33353. */
  33354. export class EngineStore {
  33355. /** Gets the list of created engines */
  33356. static Instances: Engine[];
  33357. /** @hidden */
  33358. static _LastCreatedScene: Nullable<Scene>;
  33359. /**
  33360. * Gets the latest created engine
  33361. */
  33362. static readonly LastCreatedEngine: Nullable<Engine>;
  33363. /**
  33364. * Gets the latest created scene
  33365. */
  33366. static readonly LastCreatedScene: Nullable<Scene>;
  33367. /**
  33368. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33369. * @ignorenaming
  33370. */
  33371. static UseFallbackTexture: boolean;
  33372. /**
  33373. * Texture content used if a texture cannot loaded
  33374. * @ignorenaming
  33375. */
  33376. static FallbackTexture: string;
  33377. }
  33378. }
  33379. declare module BABYLON {
  33380. /**
  33381. * Helper class that provides a small promise polyfill
  33382. */
  33383. export class PromisePolyfill {
  33384. /**
  33385. * Static function used to check if the polyfill is required
  33386. * If this is the case then the function will inject the polyfill to window.Promise
  33387. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33388. */
  33389. static Apply(force?: boolean): void;
  33390. }
  33391. }
  33392. declare module BABYLON {
  33393. /**
  33394. * Interface for screenshot methods with describe argument called `size` as object with options
  33395. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33396. */
  33397. export interface IScreenshotSize {
  33398. /**
  33399. * number in pixels for canvas height
  33400. */
  33401. height?: number;
  33402. /**
  33403. * multiplier allowing render at a higher or lower resolution
  33404. * If value is defined then height and width will be ignored and taken from camera
  33405. */
  33406. precision?: number;
  33407. /**
  33408. * number in pixels for canvas width
  33409. */
  33410. width?: number;
  33411. }
  33412. }
  33413. declare module BABYLON {
  33414. interface IColor4Like {
  33415. r: float;
  33416. g: float;
  33417. b: float;
  33418. a: float;
  33419. }
  33420. /**
  33421. * Class containing a set of static utilities functions
  33422. */
  33423. export class Tools {
  33424. /**
  33425. * Gets or sets the base URL to use to load assets
  33426. */
  33427. static BaseUrl: string;
  33428. /**
  33429. * Enable/Disable Custom HTTP Request Headers globally.
  33430. * default = false
  33431. * @see CustomRequestHeaders
  33432. */
  33433. static UseCustomRequestHeaders: boolean;
  33434. /**
  33435. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33436. * i.e. when loading files, where the server/service expects an Authorization header
  33437. */
  33438. static CustomRequestHeaders: {
  33439. [key: string]: string;
  33440. };
  33441. /**
  33442. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33443. */
  33444. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33445. /**
  33446. * Default behaviour for cors in the application.
  33447. * It can be a string if the expected behavior is identical in the entire app.
  33448. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33449. */
  33450. static CorsBehavior: string | ((url: string | string[]) => string);
  33451. /**
  33452. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33453. * @ignorenaming
  33454. */
  33455. static UseFallbackTexture: boolean;
  33456. /**
  33457. * Use this object to register external classes like custom textures or material
  33458. * to allow the laoders to instantiate them
  33459. */
  33460. static RegisteredExternalClasses: {
  33461. [key: string]: Object;
  33462. };
  33463. /**
  33464. * Texture content used if a texture cannot loaded
  33465. * @ignorenaming
  33466. */
  33467. static fallbackTexture: string;
  33468. /**
  33469. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33470. * @param u defines the coordinate on X axis
  33471. * @param v defines the coordinate on Y axis
  33472. * @param width defines the width of the source data
  33473. * @param height defines the height of the source data
  33474. * @param pixels defines the source byte array
  33475. * @param color defines the output color
  33476. */
  33477. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33478. /**
  33479. * Interpolates between a and b via alpha
  33480. * @param a The lower value (returned when alpha = 0)
  33481. * @param b The upper value (returned when alpha = 1)
  33482. * @param alpha The interpolation-factor
  33483. * @return The mixed value
  33484. */
  33485. static Mix(a: number, b: number, alpha: number): number;
  33486. /**
  33487. * Tries to instantiate a new object from a given class name
  33488. * @param className defines the class name to instantiate
  33489. * @returns the new object or null if the system was not able to do the instantiation
  33490. */
  33491. static Instantiate(className: string): any;
  33492. /**
  33493. * Provides a slice function that will work even on IE
  33494. * @param data defines the array to slice
  33495. * @param start defines the start of the data (optional)
  33496. * @param end defines the end of the data (optional)
  33497. * @returns the new sliced array
  33498. */
  33499. static Slice<T>(data: T, start?: number, end?: number): T;
  33500. /**
  33501. * Polyfill for setImmediate
  33502. * @param action defines the action to execute after the current execution block
  33503. */
  33504. static SetImmediate(action: () => void): void;
  33505. /**
  33506. * Function indicating if a number is an exponent of 2
  33507. * @param value defines the value to test
  33508. * @returns true if the value is an exponent of 2
  33509. */
  33510. static IsExponentOfTwo(value: number): boolean;
  33511. private static _tmpFloatArray;
  33512. /**
  33513. * Returns the nearest 32-bit single precision float representation of a Number
  33514. * @param value A Number. If the parameter is of a different type, it will get converted
  33515. * to a number or to NaN if it cannot be converted
  33516. * @returns number
  33517. */
  33518. static FloatRound(value: number): number;
  33519. /**
  33520. * Extracts the filename from a path
  33521. * @param path defines the path to use
  33522. * @returns the filename
  33523. */
  33524. static GetFilename(path: string): string;
  33525. /**
  33526. * Extracts the "folder" part of a path (everything before the filename).
  33527. * @param uri The URI to extract the info from
  33528. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33529. * @returns The "folder" part of the path
  33530. */
  33531. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33532. /**
  33533. * Extracts text content from a DOM element hierarchy
  33534. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33535. */
  33536. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33537. /**
  33538. * Convert an angle in radians to degrees
  33539. * @param angle defines the angle to convert
  33540. * @returns the angle in degrees
  33541. */
  33542. static ToDegrees(angle: number): number;
  33543. /**
  33544. * Convert an angle in degrees to radians
  33545. * @param angle defines the angle to convert
  33546. * @returns the angle in radians
  33547. */
  33548. static ToRadians(angle: number): number;
  33549. /**
  33550. * Returns an array if obj is not an array
  33551. * @param obj defines the object to evaluate as an array
  33552. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33553. * @returns either obj directly if obj is an array or a new array containing obj
  33554. */
  33555. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33556. /**
  33557. * Gets the pointer prefix to use
  33558. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33559. */
  33560. static GetPointerPrefix(): string;
  33561. /**
  33562. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33563. * @param url define the url we are trying
  33564. * @param element define the dom element where to configure the cors policy
  33565. */
  33566. static SetCorsBehavior(url: string | string[], element: {
  33567. crossOrigin: string | null;
  33568. }): void;
  33569. /**
  33570. * Removes unwanted characters from an url
  33571. * @param url defines the url to clean
  33572. * @returns the cleaned url
  33573. */
  33574. static CleanUrl(url: string): string;
  33575. /**
  33576. * Gets or sets a function used to pre-process url before using them to load assets
  33577. */
  33578. static PreprocessUrl: (url: string) => string;
  33579. /**
  33580. * Loads an image as an HTMLImageElement.
  33581. * @param input url string, ArrayBuffer, or Blob to load
  33582. * @param onLoad callback called when the image successfully loads
  33583. * @param onError callback called when the image fails to load
  33584. * @param offlineProvider offline provider for caching
  33585. * @param mimeType optional mime type
  33586. * @returns the HTMLImageElement of the loaded image
  33587. */
  33588. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33589. /**
  33590. * Loads a file from a url
  33591. * @param url url string, ArrayBuffer, or Blob to load
  33592. * @param onSuccess callback called when the file successfully loads
  33593. * @param onProgress callback called while file is loading (if the server supports this mode)
  33594. * @param offlineProvider defines the offline provider for caching
  33595. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33596. * @param onError callback called when the file fails to load
  33597. * @returns a file request object
  33598. */
  33599. 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;
  33600. /**
  33601. * Loads a file from a url
  33602. * @param url the file url to load
  33603. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33604. */
  33605. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33606. /**
  33607. * Load a script (identified by an url). When the url returns, the
  33608. * content of this file is added into a new script element, attached to the DOM (body element)
  33609. * @param scriptUrl defines the url of the script to laod
  33610. * @param onSuccess defines the callback called when the script is loaded
  33611. * @param onError defines the callback to call if an error occurs
  33612. * @param scriptId defines the id of the script element
  33613. */
  33614. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33615. /**
  33616. * Load an asynchronous script (identified by an url). When the url returns, the
  33617. * content of this file is added into a new script element, attached to the DOM (body element)
  33618. * @param scriptUrl defines the url of the script to laod
  33619. * @param scriptId defines the id of the script element
  33620. * @returns a promise request object
  33621. */
  33622. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33623. /**
  33624. * Loads a file from a blob
  33625. * @param fileToLoad defines the blob to use
  33626. * @param callback defines the callback to call when data is loaded
  33627. * @param progressCallback defines the callback to call during loading process
  33628. * @returns a file request object
  33629. */
  33630. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33631. /**
  33632. * Reads a file from a File object
  33633. * @param file defines the file to load
  33634. * @param onSuccess defines the callback to call when data is loaded
  33635. * @param onProgress defines the callback to call during loading process
  33636. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33637. * @param onError defines the callback to call when an error occurs
  33638. * @returns a file request object
  33639. */
  33640. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33641. /**
  33642. * Creates a data url from a given string content
  33643. * @param content defines the content to convert
  33644. * @returns the new data url link
  33645. */
  33646. static FileAsURL(content: string): string;
  33647. /**
  33648. * Format the given number to a specific decimal format
  33649. * @param value defines the number to format
  33650. * @param decimals defines the number of decimals to use
  33651. * @returns the formatted string
  33652. */
  33653. static Format(value: number, decimals?: number): string;
  33654. /**
  33655. * Tries to copy an object by duplicating every property
  33656. * @param source defines the source object
  33657. * @param destination defines the target object
  33658. * @param doNotCopyList defines a list of properties to avoid
  33659. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33660. */
  33661. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33662. /**
  33663. * Gets a boolean indicating if the given object has no own property
  33664. * @param obj defines the object to test
  33665. * @returns true if object has no own property
  33666. */
  33667. static IsEmpty(obj: any): boolean;
  33668. /**
  33669. * Function used to register events at window level
  33670. * @param windowElement defines the Window object to use
  33671. * @param events defines the events to register
  33672. */
  33673. static RegisterTopRootEvents(windowElement: Window, events: {
  33674. name: string;
  33675. handler: Nullable<(e: FocusEvent) => any>;
  33676. }[]): void;
  33677. /**
  33678. * Function used to unregister events from window level
  33679. * @param windowElement defines the Window object to use
  33680. * @param events defines the events to unregister
  33681. */
  33682. static UnregisterTopRootEvents(windowElement: Window, events: {
  33683. name: string;
  33684. handler: Nullable<(e: FocusEvent) => any>;
  33685. }[]): void;
  33686. /**
  33687. * @ignore
  33688. */
  33689. static _ScreenshotCanvas: HTMLCanvasElement;
  33690. /**
  33691. * Dumps the current bound framebuffer
  33692. * @param width defines the rendering width
  33693. * @param height defines the rendering height
  33694. * @param engine defines the hosting engine
  33695. * @param successCallback defines the callback triggered once the data are available
  33696. * @param mimeType defines the mime type of the result
  33697. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33698. */
  33699. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33700. /**
  33701. * Converts the canvas data to blob.
  33702. * This acts as a polyfill for browsers not supporting the to blob function.
  33703. * @param canvas Defines the canvas to extract the data from
  33704. * @param successCallback Defines the callback triggered once the data are available
  33705. * @param mimeType Defines the mime type of the result
  33706. */
  33707. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33708. /**
  33709. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33710. * @param successCallback defines the callback triggered once the data are available
  33711. * @param mimeType defines the mime type of the result
  33712. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33713. */
  33714. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33715. /**
  33716. * Downloads a blob in the browser
  33717. * @param blob defines the blob to download
  33718. * @param fileName defines the name of the downloaded file
  33719. */
  33720. static Download(blob: Blob, fileName: string): void;
  33721. /**
  33722. * Captures a screenshot of the current rendering
  33723. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33724. * @param engine defines the rendering engine
  33725. * @param camera defines the source camera
  33726. * @param size This parameter can be set to a single number or to an object with the
  33727. * following (optional) properties: precision, width, height. If a single number is passed,
  33728. * it will be used for both width and height. If an object is passed, the screenshot size
  33729. * will be derived from the parameters. The precision property is a multiplier allowing
  33730. * rendering at a higher or lower resolution
  33731. * @param successCallback defines the callback receives a single parameter which contains the
  33732. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33733. * src parameter of an <img> to display it
  33734. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33735. * Check your browser for supported MIME types
  33736. */
  33737. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33738. /**
  33739. * Captures a screenshot of the current rendering
  33740. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33741. * @param engine defines the rendering engine
  33742. * @param camera defines the source camera
  33743. * @param size This parameter can be set to a single number or to an object with the
  33744. * following (optional) properties: precision, width, height. If a single number is passed,
  33745. * it will be used for both width and height. If an object is passed, the screenshot size
  33746. * will be derived from the parameters. The precision property is a multiplier allowing
  33747. * rendering at a higher or lower resolution
  33748. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33749. * Check your browser for supported MIME types
  33750. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33751. * to the src parameter of an <img> to display it
  33752. */
  33753. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33754. /**
  33755. * Generates an image screenshot from the specified camera.
  33756. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33757. * @param engine The engine to use for rendering
  33758. * @param camera The camera to use for rendering
  33759. * @param size This parameter can be set to a single number or to an object with the
  33760. * following (optional) properties: precision, width, height. If a single number is passed,
  33761. * it will be used for both width and height. If an object is passed, the screenshot size
  33762. * will be derived from the parameters. The precision property is a multiplier allowing
  33763. * rendering at a higher or lower resolution
  33764. * @param successCallback The callback receives a single parameter which contains the
  33765. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33766. * src parameter of an <img> to display it
  33767. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33768. * Check your browser for supported MIME types
  33769. * @param samples Texture samples (default: 1)
  33770. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33771. * @param fileName A name for for the downloaded file.
  33772. */
  33773. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33774. /**
  33775. * Generates an image screenshot from the specified camera.
  33776. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33777. * @param engine The engine to use for rendering
  33778. * @param camera The camera to use for rendering
  33779. * @param size This parameter can be set to a single number or to an object with the
  33780. * following (optional) properties: precision, width, height. If a single number is passed,
  33781. * it will be used for both width and height. If an object is passed, the screenshot size
  33782. * will be derived from the parameters. The precision property is a multiplier allowing
  33783. * rendering at a higher or lower resolution
  33784. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33785. * Check your browser for supported MIME types
  33786. * @param samples Texture samples (default: 1)
  33787. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33788. * @param fileName A name for for the downloaded file.
  33789. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33790. * to the src parameter of an <img> to display it
  33791. */
  33792. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33793. /**
  33794. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33795. * Be aware Math.random() could cause collisions, but:
  33796. * "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"
  33797. * @returns a pseudo random id
  33798. */
  33799. static RandomId(): string;
  33800. /**
  33801. * Test if the given uri is a base64 string
  33802. * @param uri The uri to test
  33803. * @return True if the uri is a base64 string or false otherwise
  33804. */
  33805. static IsBase64(uri: string): boolean;
  33806. /**
  33807. * Decode the given base64 uri.
  33808. * @param uri The uri to decode
  33809. * @return The decoded base64 data.
  33810. */
  33811. static DecodeBase64(uri: string): ArrayBuffer;
  33812. /**
  33813. * Gets the absolute url.
  33814. * @param url the input url
  33815. * @return the absolute url
  33816. */
  33817. static GetAbsoluteUrl(url: string): string;
  33818. /**
  33819. * No log
  33820. */
  33821. static readonly NoneLogLevel: number;
  33822. /**
  33823. * Only message logs
  33824. */
  33825. static readonly MessageLogLevel: number;
  33826. /**
  33827. * Only warning logs
  33828. */
  33829. static readonly WarningLogLevel: number;
  33830. /**
  33831. * Only error logs
  33832. */
  33833. static readonly ErrorLogLevel: number;
  33834. /**
  33835. * All logs
  33836. */
  33837. static readonly AllLogLevel: number;
  33838. /**
  33839. * Gets a value indicating the number of loading errors
  33840. * @ignorenaming
  33841. */
  33842. static readonly errorsCount: number;
  33843. /**
  33844. * Callback called when a new log is added
  33845. */
  33846. static OnNewCacheEntry: (entry: string) => void;
  33847. /**
  33848. * Log a message to the console
  33849. * @param message defines the message to log
  33850. */
  33851. static Log(message: string): void;
  33852. /**
  33853. * Write a warning message to the console
  33854. * @param message defines the message to log
  33855. */
  33856. static Warn(message: string): void;
  33857. /**
  33858. * Write an error message to the console
  33859. * @param message defines the message to log
  33860. */
  33861. static Error(message: string): void;
  33862. /**
  33863. * Gets current log cache (list of logs)
  33864. */
  33865. static readonly LogCache: string;
  33866. /**
  33867. * Clears the log cache
  33868. */
  33869. static ClearLogCache(): void;
  33870. /**
  33871. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33872. */
  33873. static LogLevels: number;
  33874. /**
  33875. * Checks if the window object exists
  33876. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33877. */
  33878. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33879. /**
  33880. * No performance log
  33881. */
  33882. static readonly PerformanceNoneLogLevel: number;
  33883. /**
  33884. * Use user marks to log performance
  33885. */
  33886. static readonly PerformanceUserMarkLogLevel: number;
  33887. /**
  33888. * Log performance to the console
  33889. */
  33890. static readonly PerformanceConsoleLogLevel: number;
  33891. private static _performance;
  33892. /**
  33893. * Sets the current performance log level
  33894. */
  33895. static PerformanceLogLevel: number;
  33896. private static _StartPerformanceCounterDisabled;
  33897. private static _EndPerformanceCounterDisabled;
  33898. private static _StartUserMark;
  33899. private static _EndUserMark;
  33900. private static _StartPerformanceConsole;
  33901. private static _EndPerformanceConsole;
  33902. /**
  33903. * Starts a performance counter
  33904. */
  33905. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33906. /**
  33907. * Ends a specific performance coutner
  33908. */
  33909. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33910. /**
  33911. * Gets either window.performance.now() if supported or Date.now() else
  33912. */
  33913. static readonly Now: number;
  33914. /**
  33915. * This method will return the name of the class used to create the instance of the given object.
  33916. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33917. * @param object the object to get the class name from
  33918. * @param isType defines if the object is actually a type
  33919. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33920. */
  33921. static GetClassName(object: any, isType?: boolean): string;
  33922. /**
  33923. * Gets the first element of an array satisfying a given predicate
  33924. * @param array defines the array to browse
  33925. * @param predicate defines the predicate to use
  33926. * @returns null if not found or the element
  33927. */
  33928. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33929. /**
  33930. * This method will return the name of the full name of the class, including its owning module (if any).
  33931. * 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).
  33932. * @param object the object to get the class name from
  33933. * @param isType defines if the object is actually a type
  33934. * @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.
  33935. * @ignorenaming
  33936. */
  33937. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33938. /**
  33939. * Returns a promise that resolves after the given amount of time.
  33940. * @param delay Number of milliseconds to delay
  33941. * @returns Promise that resolves after the given amount of time
  33942. */
  33943. static DelayAsync(delay: number): Promise<void>;
  33944. }
  33945. /**
  33946. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33947. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33948. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33949. * @param name The name of the class, case should be preserved
  33950. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33951. */
  33952. export function className(name: string, module?: string): (target: Object) => void;
  33953. /**
  33954. * An implementation of a loop for asynchronous functions.
  33955. */
  33956. export class AsyncLoop {
  33957. /**
  33958. * Defines the number of iterations for the loop
  33959. */
  33960. iterations: number;
  33961. /**
  33962. * Defines the current index of the loop.
  33963. */
  33964. index: number;
  33965. private _done;
  33966. private _fn;
  33967. private _successCallback;
  33968. /**
  33969. * Constructor.
  33970. * @param iterations the number of iterations.
  33971. * @param func the function to run each iteration
  33972. * @param successCallback the callback that will be called upon succesful execution
  33973. * @param offset starting offset.
  33974. */
  33975. constructor(
  33976. /**
  33977. * Defines the number of iterations for the loop
  33978. */
  33979. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33980. /**
  33981. * Execute the next iteration. Must be called after the last iteration was finished.
  33982. */
  33983. executeNext(): void;
  33984. /**
  33985. * Break the loop and run the success callback.
  33986. */
  33987. breakLoop(): void;
  33988. /**
  33989. * Create and run an async loop.
  33990. * @param iterations the number of iterations.
  33991. * @param fn the function to run each iteration
  33992. * @param successCallback the callback that will be called upon succesful execution
  33993. * @param offset starting offset.
  33994. * @returns the created async loop object
  33995. */
  33996. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33997. /**
  33998. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33999. * @param iterations total number of iterations
  34000. * @param syncedIterations number of synchronous iterations in each async iteration.
  34001. * @param fn the function to call each iteration.
  34002. * @param callback a success call back that will be called when iterating stops.
  34003. * @param breakFunction a break condition (optional)
  34004. * @param timeout timeout settings for the setTimeout function. default - 0.
  34005. * @returns the created async loop object
  34006. */
  34007. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34008. }
  34009. }
  34010. declare module BABYLON {
  34011. /**
  34012. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34013. * The underlying implementation relies on an associative array to ensure the best performances.
  34014. * The value can be anything including 'null' but except 'undefined'
  34015. */
  34016. export class StringDictionary<T> {
  34017. /**
  34018. * This will clear this dictionary and copy the content from the 'source' one.
  34019. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34020. * @param source the dictionary to take the content from and copy to this dictionary
  34021. */
  34022. copyFrom(source: StringDictionary<T>): void;
  34023. /**
  34024. * Get a value based from its key
  34025. * @param key the given key to get the matching value from
  34026. * @return the value if found, otherwise undefined is returned
  34027. */
  34028. get(key: string): T | undefined;
  34029. /**
  34030. * Get a value from its key or add it if it doesn't exist.
  34031. * This method will ensure you that a given key/data will be present in the dictionary.
  34032. * @param key the given key to get the matching value from
  34033. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34034. * The factory will only be invoked if there's no data for the given key.
  34035. * @return the value corresponding to the key.
  34036. */
  34037. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34038. /**
  34039. * Get a value from its key if present in the dictionary otherwise add it
  34040. * @param key the key to get the value from
  34041. * @param val if there's no such key/value pair in the dictionary add it with this value
  34042. * @return the value corresponding to the key
  34043. */
  34044. getOrAdd(key: string, val: T): T;
  34045. /**
  34046. * Check if there's a given key in the dictionary
  34047. * @param key the key to check for
  34048. * @return true if the key is present, false otherwise
  34049. */
  34050. contains(key: string): boolean;
  34051. /**
  34052. * Add a new key and its corresponding value
  34053. * @param key the key to add
  34054. * @param value the value corresponding to the key
  34055. * @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
  34056. */
  34057. add(key: string, value: T): boolean;
  34058. /**
  34059. * Update a specific value associated to a key
  34060. * @param key defines the key to use
  34061. * @param value defines the value to store
  34062. * @returns true if the value was updated (or false if the key was not found)
  34063. */
  34064. set(key: string, value: T): boolean;
  34065. /**
  34066. * Get the element of the given key and remove it from the dictionary
  34067. * @param key defines the key to search
  34068. * @returns the value associated with the key or null if not found
  34069. */
  34070. getAndRemove(key: string): Nullable<T>;
  34071. /**
  34072. * Remove a key/value from the dictionary.
  34073. * @param key the key to remove
  34074. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34075. */
  34076. remove(key: string): boolean;
  34077. /**
  34078. * Clear the whole content of the dictionary
  34079. */
  34080. clear(): void;
  34081. /**
  34082. * Gets the current count
  34083. */
  34084. readonly count: number;
  34085. /**
  34086. * Execute a callback on each key/val of the dictionary.
  34087. * Note that you can remove any element in this dictionary in the callback implementation
  34088. * @param callback the callback to execute on a given key/value pair
  34089. */
  34090. forEach(callback: (key: string, val: T) => void): void;
  34091. /**
  34092. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34093. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34094. * Note that you can remove any element in this dictionary in the callback implementation
  34095. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34096. * @returns the first item
  34097. */
  34098. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34099. private _count;
  34100. private _data;
  34101. }
  34102. }
  34103. declare module BABYLON {
  34104. /** @hidden */
  34105. export interface ICollisionCoordinator {
  34106. createCollider(): Collider;
  34107. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34108. init(scene: Scene): void;
  34109. }
  34110. /** @hidden */
  34111. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34112. private _scene;
  34113. private _scaledPosition;
  34114. private _scaledVelocity;
  34115. private _finalPosition;
  34116. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34117. createCollider(): Collider;
  34118. init(scene: Scene): void;
  34119. private _collideWithWorld;
  34120. }
  34121. }
  34122. declare module BABYLON {
  34123. /**
  34124. * Class used to manage all inputs for the scene.
  34125. */
  34126. export class InputManager {
  34127. /** The distance in pixel that you have to move to prevent some events */
  34128. static DragMovementThreshold: number;
  34129. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34130. static LongPressDelay: number;
  34131. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34132. static DoubleClickDelay: number;
  34133. /** If you need to check double click without raising a single click at first click, enable this flag */
  34134. static ExclusiveDoubleClickMode: boolean;
  34135. private _wheelEventName;
  34136. private _onPointerMove;
  34137. private _onPointerDown;
  34138. private _onPointerUp;
  34139. private _initClickEvent;
  34140. private _initActionManager;
  34141. private _delayedSimpleClick;
  34142. private _delayedSimpleClickTimeout;
  34143. private _previousDelayedSimpleClickTimeout;
  34144. private _meshPickProceed;
  34145. private _previousButtonPressed;
  34146. private _currentPickResult;
  34147. private _previousPickResult;
  34148. private _totalPointersPressed;
  34149. private _doubleClickOccured;
  34150. private _pointerOverMesh;
  34151. private _pickedDownMesh;
  34152. private _pickedUpMesh;
  34153. private _pointerX;
  34154. private _pointerY;
  34155. private _unTranslatedPointerX;
  34156. private _unTranslatedPointerY;
  34157. private _startingPointerPosition;
  34158. private _previousStartingPointerPosition;
  34159. private _startingPointerTime;
  34160. private _previousStartingPointerTime;
  34161. private _pointerCaptures;
  34162. private _onKeyDown;
  34163. private _onKeyUp;
  34164. private _onCanvasFocusObserver;
  34165. private _onCanvasBlurObserver;
  34166. private _scene;
  34167. /**
  34168. * Creates a new InputManager
  34169. * @param scene defines the hosting scene
  34170. */
  34171. constructor(scene: Scene);
  34172. /**
  34173. * Gets the mesh that is currently under the pointer
  34174. */
  34175. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34176. /**
  34177. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34178. */
  34179. readonly unTranslatedPointer: Vector2;
  34180. /**
  34181. * Gets or sets the current on-screen X position of the pointer
  34182. */
  34183. pointerX: number;
  34184. /**
  34185. * Gets or sets the current on-screen Y position of the pointer
  34186. */
  34187. pointerY: number;
  34188. private _updatePointerPosition;
  34189. private _processPointerMove;
  34190. private _setRayOnPointerInfo;
  34191. private _checkPrePointerObservable;
  34192. /**
  34193. * Use this method to simulate a pointer move on a mesh
  34194. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34195. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34196. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34197. */
  34198. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34199. /**
  34200. * Use this method to simulate a pointer down on a mesh
  34201. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34202. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34203. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34204. */
  34205. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34206. private _processPointerDown;
  34207. /** @hidden */
  34208. _isPointerSwiping(): boolean;
  34209. /**
  34210. * Use this method to simulate a pointer up on a mesh
  34211. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34212. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34213. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34214. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34215. */
  34216. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34217. private _processPointerUp;
  34218. /**
  34219. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34220. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34221. * @returns true if the pointer was captured
  34222. */
  34223. isPointerCaptured(pointerId?: number): boolean;
  34224. /**
  34225. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34226. * @param attachUp defines if you want to attach events to pointerup
  34227. * @param attachDown defines if you want to attach events to pointerdown
  34228. * @param attachMove defines if you want to attach events to pointermove
  34229. */
  34230. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34231. /**
  34232. * Detaches all event handlers
  34233. */
  34234. detachControl(): void;
  34235. /**
  34236. * Force the value of meshUnderPointer
  34237. * @param mesh defines the mesh to use
  34238. */
  34239. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34240. /**
  34241. * Gets the mesh under the pointer
  34242. * @returns a Mesh or null if no mesh is under the pointer
  34243. */
  34244. getPointerOverMesh(): Nullable<AbstractMesh>;
  34245. }
  34246. }
  34247. declare module BABYLON {
  34248. /**
  34249. * Helper class used to generate session unique ID
  34250. */
  34251. export class UniqueIdGenerator {
  34252. private static _UniqueIdCounter;
  34253. /**
  34254. * Gets an unique (relatively to the current scene) Id
  34255. */
  34256. static readonly UniqueId: number;
  34257. }
  34258. }
  34259. declare module BABYLON {
  34260. /**
  34261. * This class defines the direct association between an animation and a target
  34262. */
  34263. export class TargetedAnimation {
  34264. /**
  34265. * Animation to perform
  34266. */
  34267. animation: Animation;
  34268. /**
  34269. * Target to animate
  34270. */
  34271. target: any;
  34272. /**
  34273. * Serialize the object
  34274. * @returns the JSON object representing the current entity
  34275. */
  34276. serialize(): any;
  34277. }
  34278. /**
  34279. * Use this class to create coordinated animations on multiple targets
  34280. */
  34281. export class AnimationGroup implements IDisposable {
  34282. /** The name of the animation group */
  34283. name: string;
  34284. private _scene;
  34285. private _targetedAnimations;
  34286. private _animatables;
  34287. private _from;
  34288. private _to;
  34289. private _isStarted;
  34290. private _isPaused;
  34291. private _speedRatio;
  34292. private _loopAnimation;
  34293. /**
  34294. * Gets or sets the unique id of the node
  34295. */
  34296. uniqueId: number;
  34297. /**
  34298. * This observable will notify when one animation have ended
  34299. */
  34300. onAnimationEndObservable: Observable<TargetedAnimation>;
  34301. /**
  34302. * Observer raised when one animation loops
  34303. */
  34304. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34305. /**
  34306. * Observer raised when all animations have looped
  34307. */
  34308. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34309. /**
  34310. * This observable will notify when all animations have ended.
  34311. */
  34312. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34313. /**
  34314. * This observable will notify when all animations have paused.
  34315. */
  34316. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34317. /**
  34318. * This observable will notify when all animations are playing.
  34319. */
  34320. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34321. /**
  34322. * Gets the first frame
  34323. */
  34324. readonly from: number;
  34325. /**
  34326. * Gets the last frame
  34327. */
  34328. readonly to: number;
  34329. /**
  34330. * Define if the animations are started
  34331. */
  34332. readonly isStarted: boolean;
  34333. /**
  34334. * Gets a value indicating that the current group is playing
  34335. */
  34336. readonly isPlaying: boolean;
  34337. /**
  34338. * Gets or sets the speed ratio to use for all animations
  34339. */
  34340. /**
  34341. * Gets or sets the speed ratio to use for all animations
  34342. */
  34343. speedRatio: number;
  34344. /**
  34345. * Gets or sets if all animations should loop or not
  34346. */
  34347. loopAnimation: boolean;
  34348. /**
  34349. * Gets the targeted animations for this animation group
  34350. */
  34351. readonly targetedAnimations: Array<TargetedAnimation>;
  34352. /**
  34353. * returning the list of animatables controlled by this animation group.
  34354. */
  34355. readonly animatables: Array<Animatable>;
  34356. /**
  34357. * Instantiates a new Animation Group.
  34358. * This helps managing several animations at once.
  34359. * @see http://doc.babylonjs.com/how_to/group
  34360. * @param name Defines the name of the group
  34361. * @param scene Defines the scene the group belongs to
  34362. */
  34363. constructor(
  34364. /** The name of the animation group */
  34365. name: string, scene?: Nullable<Scene>);
  34366. /**
  34367. * Add an animation (with its target) in the group
  34368. * @param animation defines the animation we want to add
  34369. * @param target defines the target of the animation
  34370. * @returns the TargetedAnimation object
  34371. */
  34372. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34373. /**
  34374. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34375. * It can add constant keys at begin or end
  34376. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34377. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34378. * @returns the animation group
  34379. */
  34380. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34381. private _animationLoopCount;
  34382. private _animationLoopFlags;
  34383. private _processLoop;
  34384. /**
  34385. * Start all animations on given targets
  34386. * @param loop defines if animations must loop
  34387. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34388. * @param from defines the from key (optional)
  34389. * @param to defines the to key (optional)
  34390. * @returns the current animation group
  34391. */
  34392. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34393. /**
  34394. * Pause all animations
  34395. * @returns the animation group
  34396. */
  34397. pause(): AnimationGroup;
  34398. /**
  34399. * Play all animations to initial state
  34400. * This function will start() the animations if they were not started or will restart() them if they were paused
  34401. * @param loop defines if animations must loop
  34402. * @returns the animation group
  34403. */
  34404. play(loop?: boolean): AnimationGroup;
  34405. /**
  34406. * Reset all animations to initial state
  34407. * @returns the animation group
  34408. */
  34409. reset(): AnimationGroup;
  34410. /**
  34411. * Restart animations from key 0
  34412. * @returns the animation group
  34413. */
  34414. restart(): AnimationGroup;
  34415. /**
  34416. * Stop all animations
  34417. * @returns the animation group
  34418. */
  34419. stop(): AnimationGroup;
  34420. /**
  34421. * Set animation weight for all animatables
  34422. * @param weight defines the weight to use
  34423. * @return the animationGroup
  34424. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34425. */
  34426. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34427. /**
  34428. * Synchronize and normalize all animatables with a source animatable
  34429. * @param root defines the root animatable to synchronize with
  34430. * @return the animationGroup
  34431. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34432. */
  34433. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34434. /**
  34435. * Goes to a specific frame in this animation group
  34436. * @param frame the frame number to go to
  34437. * @return the animationGroup
  34438. */
  34439. goToFrame(frame: number): AnimationGroup;
  34440. /**
  34441. * Dispose all associated resources
  34442. */
  34443. dispose(): void;
  34444. private _checkAnimationGroupEnded;
  34445. /**
  34446. * Clone the current animation group and returns a copy
  34447. * @param newName defines the name of the new group
  34448. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34449. * @returns the new aniamtion group
  34450. */
  34451. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34452. /**
  34453. * Serializes the animationGroup to an object
  34454. * @returns Serialized object
  34455. */
  34456. serialize(): any;
  34457. /**
  34458. * Returns a new AnimationGroup object parsed from the source provided.
  34459. * @param parsedAnimationGroup defines the source
  34460. * @param scene defines the scene that will receive the animationGroup
  34461. * @returns a new AnimationGroup
  34462. */
  34463. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34464. /**
  34465. * Returns the string "AnimationGroup"
  34466. * @returns "AnimationGroup"
  34467. */
  34468. getClassName(): string;
  34469. /**
  34470. * Creates a detailled string about the object
  34471. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34472. * @returns a string representing the object
  34473. */
  34474. toString(fullDetails?: boolean): string;
  34475. }
  34476. }
  34477. declare module BABYLON {
  34478. /**
  34479. * Define an interface for all classes that will hold resources
  34480. */
  34481. export interface IDisposable {
  34482. /**
  34483. * Releases all held resources
  34484. */
  34485. dispose(): void;
  34486. }
  34487. /** Interface defining initialization parameters for Scene class */
  34488. export interface SceneOptions {
  34489. /**
  34490. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34491. * It will improve performance when the number of geometries becomes important.
  34492. */
  34493. useGeometryUniqueIdsMap?: boolean;
  34494. /**
  34495. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34496. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34497. */
  34498. useMaterialMeshMap?: boolean;
  34499. /**
  34500. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34501. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34502. */
  34503. useClonedMeshhMap?: boolean;
  34504. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34505. virtual?: boolean;
  34506. }
  34507. /**
  34508. * Represents a scene to be rendered by the engine.
  34509. * @see http://doc.babylonjs.com/features/scene
  34510. */
  34511. export class Scene extends AbstractScene implements IAnimatable {
  34512. /** The fog is deactivated */
  34513. static readonly FOGMODE_NONE: number;
  34514. /** The fog density is following an exponential function */
  34515. static readonly FOGMODE_EXP: number;
  34516. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34517. static readonly FOGMODE_EXP2: number;
  34518. /** The fog density is following a linear function. */
  34519. static readonly FOGMODE_LINEAR: number;
  34520. /**
  34521. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34522. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34523. */
  34524. static MinDeltaTime: number;
  34525. /**
  34526. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34527. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34528. */
  34529. static MaxDeltaTime: number;
  34530. /**
  34531. * Factory used to create the default material.
  34532. * @param name The name of the material to create
  34533. * @param scene The scene to create the material for
  34534. * @returns The default material
  34535. */
  34536. static DefaultMaterialFactory(scene: Scene): Material;
  34537. /**
  34538. * Factory used to create the a collision coordinator.
  34539. * @returns The collision coordinator
  34540. */
  34541. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34542. /** @hidden */
  34543. _inputManager: InputManager;
  34544. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34545. cameraToUseForPointers: Nullable<Camera>;
  34546. /** @hidden */
  34547. readonly _isScene: boolean;
  34548. /**
  34549. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34550. */
  34551. autoClear: boolean;
  34552. /**
  34553. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34554. */
  34555. autoClearDepthAndStencil: boolean;
  34556. /**
  34557. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34558. */
  34559. clearColor: Color4;
  34560. /**
  34561. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34562. */
  34563. ambientColor: Color3;
  34564. /**
  34565. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34566. * It should only be one of the following (if not the default embedded one):
  34567. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34568. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34569. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34570. * The material properties need to be setup according to the type of texture in use.
  34571. */
  34572. environmentBRDFTexture: BaseTexture;
  34573. /** @hidden */
  34574. protected _environmentTexture: Nullable<BaseTexture>;
  34575. /**
  34576. * Texture used in all pbr material as the reflection texture.
  34577. * As in the majority of the scene they are the same (exception for multi room and so on),
  34578. * this is easier to reference from here than from all the materials.
  34579. */
  34580. /**
  34581. * Texture used in all pbr material as the reflection texture.
  34582. * As in the majority of the scene they are the same (exception for multi room and so on),
  34583. * this is easier to set here than in all the materials.
  34584. */
  34585. environmentTexture: Nullable<BaseTexture>;
  34586. /** @hidden */
  34587. protected _environmentIntensity: number;
  34588. /**
  34589. * Intensity of the environment in all pbr material.
  34590. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34591. * As in the majority of the scene they are the same (exception for multi room and so on),
  34592. * this is easier to reference from here than from all the materials.
  34593. */
  34594. /**
  34595. * Intensity of the environment in all pbr material.
  34596. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34597. * As in the majority of the scene they are the same (exception for multi room and so on),
  34598. * this is easier to set here than in all the materials.
  34599. */
  34600. environmentIntensity: number;
  34601. /** @hidden */
  34602. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34603. /**
  34604. * Default image processing configuration used either in the rendering
  34605. * Forward main pass or through the imageProcessingPostProcess if present.
  34606. * As in the majority of the scene they are the same (exception for multi camera),
  34607. * this is easier to reference from here than from all the materials and post process.
  34608. *
  34609. * No setter as we it is a shared configuration, you can set the values instead.
  34610. */
  34611. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34612. private _forceWireframe;
  34613. /**
  34614. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34615. */
  34616. forceWireframe: boolean;
  34617. private _forcePointsCloud;
  34618. /**
  34619. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34620. */
  34621. forcePointsCloud: boolean;
  34622. /**
  34623. * Gets or sets the active clipplane 1
  34624. */
  34625. clipPlane: Nullable<Plane>;
  34626. /**
  34627. * Gets or sets the active clipplane 2
  34628. */
  34629. clipPlane2: Nullable<Plane>;
  34630. /**
  34631. * Gets or sets the active clipplane 3
  34632. */
  34633. clipPlane3: Nullable<Plane>;
  34634. /**
  34635. * Gets or sets the active clipplane 4
  34636. */
  34637. clipPlane4: Nullable<Plane>;
  34638. /**
  34639. * Gets or sets a boolean indicating if animations are enabled
  34640. */
  34641. animationsEnabled: boolean;
  34642. private _animationPropertiesOverride;
  34643. /**
  34644. * Gets or sets the animation properties override
  34645. */
  34646. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34647. /**
  34648. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34649. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34650. */
  34651. useConstantAnimationDeltaTime: boolean;
  34652. /**
  34653. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34654. * Please note that it requires to run a ray cast through the scene on every frame
  34655. */
  34656. constantlyUpdateMeshUnderPointer: boolean;
  34657. /**
  34658. * Defines the HTML cursor to use when hovering over interactive elements
  34659. */
  34660. hoverCursor: string;
  34661. /**
  34662. * Defines the HTML default cursor to use (empty by default)
  34663. */
  34664. defaultCursor: string;
  34665. /**
  34666. * Defines wether cursors are handled by the scene.
  34667. */
  34668. doNotHandleCursors: boolean;
  34669. /**
  34670. * This is used to call preventDefault() on pointer down
  34671. * in order to block unwanted artifacts like system double clicks
  34672. */
  34673. preventDefaultOnPointerDown: boolean;
  34674. /**
  34675. * This is used to call preventDefault() on pointer up
  34676. * in order to block unwanted artifacts like system double clicks
  34677. */
  34678. preventDefaultOnPointerUp: boolean;
  34679. /**
  34680. * Gets or sets user defined metadata
  34681. */
  34682. metadata: any;
  34683. /**
  34684. * For internal use only. Please do not use.
  34685. */
  34686. reservedDataStore: any;
  34687. /**
  34688. * Gets the name of the plugin used to load this scene (null by default)
  34689. */
  34690. loadingPluginName: string;
  34691. /**
  34692. * Use this array to add regular expressions used to disable offline support for specific urls
  34693. */
  34694. disableOfflineSupportExceptionRules: RegExp[];
  34695. /**
  34696. * An event triggered when the scene is disposed.
  34697. */
  34698. onDisposeObservable: Observable<Scene>;
  34699. private _onDisposeObserver;
  34700. /** Sets a function to be executed when this scene is disposed. */
  34701. onDispose: () => void;
  34702. /**
  34703. * An event triggered before rendering the scene (right after animations and physics)
  34704. */
  34705. onBeforeRenderObservable: Observable<Scene>;
  34706. private _onBeforeRenderObserver;
  34707. /** Sets a function to be executed before rendering this scene */
  34708. beforeRender: Nullable<() => void>;
  34709. /**
  34710. * An event triggered after rendering the scene
  34711. */
  34712. onAfterRenderObservable: Observable<Scene>;
  34713. /**
  34714. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34715. */
  34716. onAfterRenderCameraObservable: Observable<Camera>;
  34717. private _onAfterRenderObserver;
  34718. /** Sets a function to be executed after rendering this scene */
  34719. afterRender: Nullable<() => void>;
  34720. /**
  34721. * An event triggered before animating the scene
  34722. */
  34723. onBeforeAnimationsObservable: Observable<Scene>;
  34724. /**
  34725. * An event triggered after animations processing
  34726. */
  34727. onAfterAnimationsObservable: Observable<Scene>;
  34728. /**
  34729. * An event triggered before draw calls are ready to be sent
  34730. */
  34731. onBeforeDrawPhaseObservable: Observable<Scene>;
  34732. /**
  34733. * An event triggered after draw calls have been sent
  34734. */
  34735. onAfterDrawPhaseObservable: Observable<Scene>;
  34736. /**
  34737. * An event triggered when the scene is ready
  34738. */
  34739. onReadyObservable: Observable<Scene>;
  34740. /**
  34741. * An event triggered before rendering a camera
  34742. */
  34743. onBeforeCameraRenderObservable: Observable<Camera>;
  34744. private _onBeforeCameraRenderObserver;
  34745. /** Sets a function to be executed before rendering a camera*/
  34746. beforeCameraRender: () => void;
  34747. /**
  34748. * An event triggered after rendering a camera
  34749. */
  34750. onAfterCameraRenderObservable: Observable<Camera>;
  34751. private _onAfterCameraRenderObserver;
  34752. /** Sets a function to be executed after rendering a camera*/
  34753. afterCameraRender: () => void;
  34754. /**
  34755. * An event triggered when active meshes evaluation is about to start
  34756. */
  34757. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34758. /**
  34759. * An event triggered when active meshes evaluation is done
  34760. */
  34761. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34762. /**
  34763. * An event triggered when particles rendering is about to start
  34764. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34765. */
  34766. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34767. /**
  34768. * An event triggered when particles rendering is done
  34769. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34770. */
  34771. onAfterParticlesRenderingObservable: Observable<Scene>;
  34772. /**
  34773. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34774. */
  34775. onDataLoadedObservable: Observable<Scene>;
  34776. /**
  34777. * An event triggered when a camera is created
  34778. */
  34779. onNewCameraAddedObservable: Observable<Camera>;
  34780. /**
  34781. * An event triggered when a camera is removed
  34782. */
  34783. onCameraRemovedObservable: Observable<Camera>;
  34784. /**
  34785. * An event triggered when a light is created
  34786. */
  34787. onNewLightAddedObservable: Observable<Light>;
  34788. /**
  34789. * An event triggered when a light is removed
  34790. */
  34791. onLightRemovedObservable: Observable<Light>;
  34792. /**
  34793. * An event triggered when a geometry is created
  34794. */
  34795. onNewGeometryAddedObservable: Observable<Geometry>;
  34796. /**
  34797. * An event triggered when a geometry is removed
  34798. */
  34799. onGeometryRemovedObservable: Observable<Geometry>;
  34800. /**
  34801. * An event triggered when a transform node is created
  34802. */
  34803. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34804. /**
  34805. * An event triggered when a transform node is removed
  34806. */
  34807. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34808. /**
  34809. * An event triggered when a mesh is created
  34810. */
  34811. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34812. /**
  34813. * An event triggered when a mesh is removed
  34814. */
  34815. onMeshRemovedObservable: Observable<AbstractMesh>;
  34816. /**
  34817. * An event triggered when a skeleton is created
  34818. */
  34819. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34820. /**
  34821. * An event triggered when a skeleton is removed
  34822. */
  34823. onSkeletonRemovedObservable: Observable<Skeleton>;
  34824. /**
  34825. * An event triggered when a material is created
  34826. */
  34827. onNewMaterialAddedObservable: Observable<Material>;
  34828. /**
  34829. * An event triggered when a material is removed
  34830. */
  34831. onMaterialRemovedObservable: Observable<Material>;
  34832. /**
  34833. * An event triggered when a texture is created
  34834. */
  34835. onNewTextureAddedObservable: Observable<BaseTexture>;
  34836. /**
  34837. * An event triggered when a texture is removed
  34838. */
  34839. onTextureRemovedObservable: Observable<BaseTexture>;
  34840. /**
  34841. * An event triggered when render targets are about to be rendered
  34842. * Can happen multiple times per frame.
  34843. */
  34844. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34845. /**
  34846. * An event triggered when render targets were rendered.
  34847. * Can happen multiple times per frame.
  34848. */
  34849. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34850. /**
  34851. * An event triggered before calculating deterministic simulation step
  34852. */
  34853. onBeforeStepObservable: Observable<Scene>;
  34854. /**
  34855. * An event triggered after calculating deterministic simulation step
  34856. */
  34857. onAfterStepObservable: Observable<Scene>;
  34858. /**
  34859. * An event triggered when the activeCamera property is updated
  34860. */
  34861. onActiveCameraChanged: Observable<Scene>;
  34862. /**
  34863. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34864. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34865. * 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)
  34866. */
  34867. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34868. /**
  34869. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34870. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34871. * 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)
  34872. */
  34873. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34874. /**
  34875. * This Observable will when a mesh has been imported into the scene.
  34876. */
  34877. onMeshImportedObservable: Observable<AbstractMesh>;
  34878. /**
  34879. * This Observable will when an animation file has been imported into the scene.
  34880. */
  34881. onAnimationFileImportedObservable: Observable<Scene>;
  34882. /**
  34883. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34884. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34885. */
  34886. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34887. /** @hidden */
  34888. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34889. /**
  34890. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34891. */
  34892. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34893. /**
  34894. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34895. */
  34896. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34897. /**
  34898. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34899. */
  34900. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34901. /** Callback called when a pointer move is detected */
  34902. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34903. /** Callback called when a pointer down is detected */
  34904. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34905. /** Callback called when a pointer up is detected */
  34906. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34907. /** Callback called when a pointer pick is detected */
  34908. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34909. /**
  34910. * 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).
  34911. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34912. */
  34913. onPrePointerObservable: Observable<PointerInfoPre>;
  34914. /**
  34915. * Observable event triggered each time an input event is received from the rendering canvas
  34916. */
  34917. onPointerObservable: Observable<PointerInfo>;
  34918. /**
  34919. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34920. */
  34921. readonly unTranslatedPointer: Vector2;
  34922. /**
  34923. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34924. */
  34925. static DragMovementThreshold: number;
  34926. /**
  34927. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34928. */
  34929. static LongPressDelay: number;
  34930. /**
  34931. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34932. */
  34933. static DoubleClickDelay: number;
  34934. /** If you need to check double click without raising a single click at first click, enable this flag */
  34935. static ExclusiveDoubleClickMode: boolean;
  34936. /** @hidden */
  34937. _mirroredCameraPosition: Nullable<Vector3>;
  34938. /**
  34939. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34940. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34941. */
  34942. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34943. /**
  34944. * Observable event triggered each time an keyboard event is received from the hosting window
  34945. */
  34946. onKeyboardObservable: Observable<KeyboardInfo>;
  34947. private _useRightHandedSystem;
  34948. /**
  34949. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34950. */
  34951. useRightHandedSystem: boolean;
  34952. private _timeAccumulator;
  34953. private _currentStepId;
  34954. private _currentInternalStep;
  34955. /**
  34956. * Sets the step Id used by deterministic lock step
  34957. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34958. * @param newStepId defines the step Id
  34959. */
  34960. setStepId(newStepId: number): void;
  34961. /**
  34962. * Gets the step Id used by deterministic lock step
  34963. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34964. * @returns the step Id
  34965. */
  34966. getStepId(): number;
  34967. /**
  34968. * Gets the internal step used by deterministic lock step
  34969. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34970. * @returns the internal step
  34971. */
  34972. getInternalStep(): number;
  34973. private _fogEnabled;
  34974. /**
  34975. * Gets or sets a boolean indicating if fog is enabled on this scene
  34976. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34977. * (Default is true)
  34978. */
  34979. fogEnabled: boolean;
  34980. private _fogMode;
  34981. /**
  34982. * Gets or sets the fog mode to use
  34983. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34984. * | mode | value |
  34985. * | --- | --- |
  34986. * | FOGMODE_NONE | 0 |
  34987. * | FOGMODE_EXP | 1 |
  34988. * | FOGMODE_EXP2 | 2 |
  34989. * | FOGMODE_LINEAR | 3 |
  34990. */
  34991. fogMode: number;
  34992. /**
  34993. * Gets or sets the fog color to use
  34994. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34995. * (Default is Color3(0.2, 0.2, 0.3))
  34996. */
  34997. fogColor: Color3;
  34998. /**
  34999. * Gets or sets the fog density to use
  35000. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35001. * (Default is 0.1)
  35002. */
  35003. fogDensity: number;
  35004. /**
  35005. * Gets or sets the fog start distance to use
  35006. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35007. * (Default is 0)
  35008. */
  35009. fogStart: number;
  35010. /**
  35011. * Gets or sets the fog end distance to use
  35012. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35013. * (Default is 1000)
  35014. */
  35015. fogEnd: number;
  35016. private _shadowsEnabled;
  35017. /**
  35018. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35019. */
  35020. shadowsEnabled: boolean;
  35021. private _lightsEnabled;
  35022. /**
  35023. * Gets or sets a boolean indicating if lights are enabled on this scene
  35024. */
  35025. lightsEnabled: boolean;
  35026. /** All of the active cameras added to this scene. */
  35027. activeCameras: Camera[];
  35028. /** @hidden */
  35029. _activeCamera: Nullable<Camera>;
  35030. /** Gets or sets the current active camera */
  35031. activeCamera: Nullable<Camera>;
  35032. private _defaultMaterial;
  35033. /** The default material used on meshes when no material is affected */
  35034. /** The default material used on meshes when no material is affected */
  35035. defaultMaterial: Material;
  35036. private _texturesEnabled;
  35037. /**
  35038. * Gets or sets a boolean indicating if textures are enabled on this scene
  35039. */
  35040. texturesEnabled: boolean;
  35041. /**
  35042. * Gets or sets a boolean indicating if particles are enabled on this scene
  35043. */
  35044. particlesEnabled: boolean;
  35045. /**
  35046. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35047. */
  35048. spritesEnabled: boolean;
  35049. private _skeletonsEnabled;
  35050. /**
  35051. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35052. */
  35053. skeletonsEnabled: boolean;
  35054. /**
  35055. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35056. */
  35057. lensFlaresEnabled: boolean;
  35058. /**
  35059. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35060. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35061. */
  35062. collisionsEnabled: boolean;
  35063. private _collisionCoordinator;
  35064. /** @hidden */
  35065. readonly collisionCoordinator: ICollisionCoordinator;
  35066. /**
  35067. * Defines the gravity applied to this scene (used only for collisions)
  35068. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35069. */
  35070. gravity: Vector3;
  35071. /**
  35072. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35073. */
  35074. postProcessesEnabled: boolean;
  35075. /**
  35076. * The list of postprocesses added to the scene
  35077. */
  35078. postProcesses: PostProcess[];
  35079. /**
  35080. * Gets the current postprocess manager
  35081. */
  35082. postProcessManager: PostProcessManager;
  35083. /**
  35084. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35085. */
  35086. renderTargetsEnabled: boolean;
  35087. /**
  35088. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35089. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35090. */
  35091. dumpNextRenderTargets: boolean;
  35092. /**
  35093. * The list of user defined render targets added to the scene
  35094. */
  35095. customRenderTargets: RenderTargetTexture[];
  35096. /**
  35097. * Defines if texture loading must be delayed
  35098. * If true, textures will only be loaded when they need to be rendered
  35099. */
  35100. useDelayedTextureLoading: boolean;
  35101. /**
  35102. * Gets the list of meshes imported to the scene through SceneLoader
  35103. */
  35104. importedMeshesFiles: String[];
  35105. /**
  35106. * Gets or sets a boolean indicating if probes are enabled on this scene
  35107. */
  35108. probesEnabled: boolean;
  35109. /**
  35110. * Gets or sets the current offline provider to use to store scene data
  35111. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35112. */
  35113. offlineProvider: IOfflineProvider;
  35114. /**
  35115. * Gets or sets the action manager associated with the scene
  35116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35117. */
  35118. actionManager: AbstractActionManager;
  35119. private _meshesForIntersections;
  35120. /**
  35121. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35122. */
  35123. proceduralTexturesEnabled: boolean;
  35124. private _engine;
  35125. private _totalVertices;
  35126. /** @hidden */
  35127. _activeIndices: PerfCounter;
  35128. /** @hidden */
  35129. _activeParticles: PerfCounter;
  35130. /** @hidden */
  35131. _activeBones: PerfCounter;
  35132. private _animationRatio;
  35133. /** @hidden */
  35134. _animationTimeLast: number;
  35135. /** @hidden */
  35136. _animationTime: number;
  35137. /**
  35138. * Gets or sets a general scale for animation speed
  35139. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35140. */
  35141. animationTimeScale: number;
  35142. /** @hidden */
  35143. _cachedMaterial: Nullable<Material>;
  35144. /** @hidden */
  35145. _cachedEffect: Nullable<Effect>;
  35146. /** @hidden */
  35147. _cachedVisibility: Nullable<number>;
  35148. private _renderId;
  35149. private _frameId;
  35150. private _executeWhenReadyTimeoutId;
  35151. private _intermediateRendering;
  35152. private _viewUpdateFlag;
  35153. private _projectionUpdateFlag;
  35154. /** @hidden */
  35155. _toBeDisposed: Nullable<IDisposable>[];
  35156. private _activeRequests;
  35157. /** @hidden */
  35158. _pendingData: any[];
  35159. private _isDisposed;
  35160. /**
  35161. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35162. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35163. */
  35164. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35165. private _activeMeshes;
  35166. private _processedMaterials;
  35167. private _renderTargets;
  35168. /** @hidden */
  35169. _activeParticleSystems: SmartArray<IParticleSystem>;
  35170. private _activeSkeletons;
  35171. private _softwareSkinnedMeshes;
  35172. private _renderingManager;
  35173. /** @hidden */
  35174. _activeAnimatables: Animatable[];
  35175. private _transformMatrix;
  35176. private _sceneUbo;
  35177. /** @hidden */
  35178. _viewMatrix: Matrix;
  35179. private _projectionMatrix;
  35180. /** @hidden */
  35181. _forcedViewPosition: Nullable<Vector3>;
  35182. /** @hidden */
  35183. _frustumPlanes: Plane[];
  35184. /**
  35185. * Gets the list of frustum planes (built from the active camera)
  35186. */
  35187. readonly frustumPlanes: Plane[];
  35188. /**
  35189. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35190. * This is useful if there are more lights that the maximum simulteanous authorized
  35191. */
  35192. requireLightSorting: boolean;
  35193. /** @hidden */
  35194. readonly useMaterialMeshMap: boolean;
  35195. /** @hidden */
  35196. readonly useClonedMeshhMap: boolean;
  35197. private _externalData;
  35198. private _uid;
  35199. /**
  35200. * @hidden
  35201. * Backing store of defined scene components.
  35202. */
  35203. _components: ISceneComponent[];
  35204. /**
  35205. * @hidden
  35206. * Backing store of defined scene components.
  35207. */
  35208. _serializableComponents: ISceneSerializableComponent[];
  35209. /**
  35210. * List of components to register on the next registration step.
  35211. */
  35212. private _transientComponents;
  35213. /**
  35214. * Registers the transient components if needed.
  35215. */
  35216. private _registerTransientComponents;
  35217. /**
  35218. * @hidden
  35219. * Add a component to the scene.
  35220. * Note that the ccomponent could be registered on th next frame if this is called after
  35221. * the register component stage.
  35222. * @param component Defines the component to add to the scene
  35223. */
  35224. _addComponent(component: ISceneComponent): void;
  35225. /**
  35226. * @hidden
  35227. * Gets a component from the scene.
  35228. * @param name defines the name of the component to retrieve
  35229. * @returns the component or null if not present
  35230. */
  35231. _getComponent(name: string): Nullable<ISceneComponent>;
  35232. /**
  35233. * @hidden
  35234. * Defines the actions happening before camera updates.
  35235. */
  35236. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35237. /**
  35238. * @hidden
  35239. * Defines the actions happening before clear the canvas.
  35240. */
  35241. _beforeClearStage: Stage<SimpleStageAction>;
  35242. /**
  35243. * @hidden
  35244. * Defines the actions when collecting render targets for the frame.
  35245. */
  35246. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35247. /**
  35248. * @hidden
  35249. * Defines the actions happening for one camera in the frame.
  35250. */
  35251. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35252. /**
  35253. * @hidden
  35254. * Defines the actions happening during the per mesh ready checks.
  35255. */
  35256. _isReadyForMeshStage: Stage<MeshStageAction>;
  35257. /**
  35258. * @hidden
  35259. * Defines the actions happening before evaluate active mesh checks.
  35260. */
  35261. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35262. /**
  35263. * @hidden
  35264. * Defines the actions happening during the evaluate sub mesh checks.
  35265. */
  35266. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35267. /**
  35268. * @hidden
  35269. * Defines the actions happening during the active mesh stage.
  35270. */
  35271. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35272. /**
  35273. * @hidden
  35274. * Defines the actions happening during the per camera render target step.
  35275. */
  35276. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35277. /**
  35278. * @hidden
  35279. * Defines the actions happening just before the active camera is drawing.
  35280. */
  35281. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35282. /**
  35283. * @hidden
  35284. * Defines the actions happening just before a render target is drawing.
  35285. */
  35286. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35287. /**
  35288. * @hidden
  35289. * Defines the actions happening just before a rendering group is drawing.
  35290. */
  35291. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35292. /**
  35293. * @hidden
  35294. * Defines the actions happening just before a mesh is drawing.
  35295. */
  35296. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35297. /**
  35298. * @hidden
  35299. * Defines the actions happening just after a mesh has been drawn.
  35300. */
  35301. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35302. /**
  35303. * @hidden
  35304. * Defines the actions happening just after a rendering group has been drawn.
  35305. */
  35306. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35307. /**
  35308. * @hidden
  35309. * Defines the actions happening just after the active camera has been drawn.
  35310. */
  35311. _afterCameraDrawStage: Stage<CameraStageAction>;
  35312. /**
  35313. * @hidden
  35314. * Defines the actions happening just after a render target has been drawn.
  35315. */
  35316. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35317. /**
  35318. * @hidden
  35319. * Defines the actions happening just after rendering all cameras and computing intersections.
  35320. */
  35321. _afterRenderStage: Stage<SimpleStageAction>;
  35322. /**
  35323. * @hidden
  35324. * Defines the actions happening when a pointer move event happens.
  35325. */
  35326. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35327. /**
  35328. * @hidden
  35329. * Defines the actions happening when a pointer down event happens.
  35330. */
  35331. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35332. /**
  35333. * @hidden
  35334. * Defines the actions happening when a pointer up event happens.
  35335. */
  35336. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35337. /**
  35338. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35339. */
  35340. private geometriesByUniqueId;
  35341. /**
  35342. * Creates a new Scene
  35343. * @param engine defines the engine to use to render this scene
  35344. * @param options defines the scene options
  35345. */
  35346. constructor(engine: Engine, options?: SceneOptions);
  35347. /**
  35348. * Gets a string idenfifying the name of the class
  35349. * @returns "Scene" string
  35350. */
  35351. getClassName(): string;
  35352. private _defaultMeshCandidates;
  35353. /**
  35354. * @hidden
  35355. */
  35356. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35357. private _defaultSubMeshCandidates;
  35358. /**
  35359. * @hidden
  35360. */
  35361. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35362. /**
  35363. * Sets the default candidate providers for the scene.
  35364. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35365. * and getCollidingSubMeshCandidates to their default function
  35366. */
  35367. setDefaultCandidateProviders(): void;
  35368. /**
  35369. * Gets the mesh that is currently under the pointer
  35370. */
  35371. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35372. /**
  35373. * Gets or sets the current on-screen X position of the pointer
  35374. */
  35375. pointerX: number;
  35376. /**
  35377. * Gets or sets the current on-screen Y position of the pointer
  35378. */
  35379. pointerY: number;
  35380. /**
  35381. * Gets the cached material (ie. the latest rendered one)
  35382. * @returns the cached material
  35383. */
  35384. getCachedMaterial(): Nullable<Material>;
  35385. /**
  35386. * Gets the cached effect (ie. the latest rendered one)
  35387. * @returns the cached effect
  35388. */
  35389. getCachedEffect(): Nullable<Effect>;
  35390. /**
  35391. * Gets the cached visibility state (ie. the latest rendered one)
  35392. * @returns the cached visibility state
  35393. */
  35394. getCachedVisibility(): Nullable<number>;
  35395. /**
  35396. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35397. * @param material defines the current material
  35398. * @param effect defines the current effect
  35399. * @param visibility defines the current visibility state
  35400. * @returns true if one parameter is not cached
  35401. */
  35402. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35403. /**
  35404. * Gets the engine associated with the scene
  35405. * @returns an Engine
  35406. */
  35407. getEngine(): Engine;
  35408. /**
  35409. * Gets the total number of vertices rendered per frame
  35410. * @returns the total number of vertices rendered per frame
  35411. */
  35412. getTotalVertices(): number;
  35413. /**
  35414. * Gets the performance counter for total vertices
  35415. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35416. */
  35417. readonly totalVerticesPerfCounter: PerfCounter;
  35418. /**
  35419. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35420. * @returns the total number of active indices rendered per frame
  35421. */
  35422. getActiveIndices(): number;
  35423. /**
  35424. * Gets the performance counter for active indices
  35425. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35426. */
  35427. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35428. /**
  35429. * Gets the total number of active particles rendered per frame
  35430. * @returns the total number of active particles rendered per frame
  35431. */
  35432. getActiveParticles(): number;
  35433. /**
  35434. * Gets the performance counter for active particles
  35435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35436. */
  35437. readonly activeParticlesPerfCounter: PerfCounter;
  35438. /**
  35439. * Gets the total number of active bones rendered per frame
  35440. * @returns the total number of active bones rendered per frame
  35441. */
  35442. getActiveBones(): number;
  35443. /**
  35444. * Gets the performance counter for active bones
  35445. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35446. */
  35447. readonly activeBonesPerfCounter: PerfCounter;
  35448. /**
  35449. * Gets the array of active meshes
  35450. * @returns an array of AbstractMesh
  35451. */
  35452. getActiveMeshes(): SmartArray<AbstractMesh>;
  35453. /**
  35454. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35455. * @returns a number
  35456. */
  35457. getAnimationRatio(): number;
  35458. /**
  35459. * Gets an unique Id for the current render phase
  35460. * @returns a number
  35461. */
  35462. getRenderId(): number;
  35463. /**
  35464. * Gets an unique Id for the current frame
  35465. * @returns a number
  35466. */
  35467. getFrameId(): number;
  35468. /** Call this function if you want to manually increment the render Id*/
  35469. incrementRenderId(): void;
  35470. private _createUbo;
  35471. /**
  35472. * Use this method to simulate a pointer move on a mesh
  35473. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35474. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35475. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35476. * @returns the current scene
  35477. */
  35478. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35479. /**
  35480. * Use this method to simulate a pointer down on a mesh
  35481. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35482. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35483. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35484. * @returns the current scene
  35485. */
  35486. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35487. /**
  35488. * Use this method to simulate a pointer up on a mesh
  35489. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35490. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35491. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35492. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35493. * @returns the current scene
  35494. */
  35495. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35496. /**
  35497. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35498. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35499. * @returns true if the pointer was captured
  35500. */
  35501. isPointerCaptured(pointerId?: number): boolean;
  35502. /**
  35503. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35504. * @param attachUp defines if you want to attach events to pointerup
  35505. * @param attachDown defines if you want to attach events to pointerdown
  35506. * @param attachMove defines if you want to attach events to pointermove
  35507. */
  35508. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35509. /** Detaches all event handlers*/
  35510. detachControl(): void;
  35511. /**
  35512. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35513. * Delay loaded resources are not taking in account
  35514. * @return true if all required resources are ready
  35515. */
  35516. isReady(): boolean;
  35517. /** Resets all cached information relative to material (including effect and visibility) */
  35518. resetCachedMaterial(): void;
  35519. /**
  35520. * Registers a function to be called before every frame render
  35521. * @param func defines the function to register
  35522. */
  35523. registerBeforeRender(func: () => void): void;
  35524. /**
  35525. * Unregisters a function called before every frame render
  35526. * @param func defines the function to unregister
  35527. */
  35528. unregisterBeforeRender(func: () => void): void;
  35529. /**
  35530. * Registers a function to be called after every frame render
  35531. * @param func defines the function to register
  35532. */
  35533. registerAfterRender(func: () => void): void;
  35534. /**
  35535. * Unregisters a function called after every frame render
  35536. * @param func defines the function to unregister
  35537. */
  35538. unregisterAfterRender(func: () => void): void;
  35539. private _executeOnceBeforeRender;
  35540. /**
  35541. * The provided function will run before render once and will be disposed afterwards.
  35542. * A timeout delay can be provided so that the function will be executed in N ms.
  35543. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35544. * @param func The function to be executed.
  35545. * @param timeout optional delay in ms
  35546. */
  35547. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35548. /** @hidden */
  35549. _addPendingData(data: any): void;
  35550. /** @hidden */
  35551. _removePendingData(data: any): void;
  35552. /**
  35553. * Returns the number of items waiting to be loaded
  35554. * @returns the number of items waiting to be loaded
  35555. */
  35556. getWaitingItemsCount(): number;
  35557. /**
  35558. * Returns a boolean indicating if the scene is still loading data
  35559. */
  35560. readonly isLoading: boolean;
  35561. /**
  35562. * Registers a function to be executed when the scene is ready
  35563. * @param {Function} func - the function to be executed
  35564. */
  35565. executeWhenReady(func: () => void): void;
  35566. /**
  35567. * Returns a promise that resolves when the scene is ready
  35568. * @returns A promise that resolves when the scene is ready
  35569. */
  35570. whenReadyAsync(): Promise<void>;
  35571. /** @hidden */
  35572. _checkIsReady(): void;
  35573. /**
  35574. * Gets all animatable attached to the scene
  35575. */
  35576. readonly animatables: Animatable[];
  35577. /**
  35578. * Resets the last animation time frame.
  35579. * Useful to override when animations start running when loading a scene for the first time.
  35580. */
  35581. resetLastAnimationTimeFrame(): void;
  35582. /**
  35583. * Gets the current view matrix
  35584. * @returns a Matrix
  35585. */
  35586. getViewMatrix(): Matrix;
  35587. /**
  35588. * Gets the current projection matrix
  35589. * @returns a Matrix
  35590. */
  35591. getProjectionMatrix(): Matrix;
  35592. /**
  35593. * Gets the current transform matrix
  35594. * @returns a Matrix made of View * Projection
  35595. */
  35596. getTransformMatrix(): Matrix;
  35597. /**
  35598. * Sets the current transform matrix
  35599. * @param viewL defines the View matrix to use
  35600. * @param projectionL defines the Projection matrix to use
  35601. * @param viewR defines the right View matrix to use (if provided)
  35602. * @param projectionR defines the right Projection matrix to use (if provided)
  35603. */
  35604. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35605. /**
  35606. * Gets the uniform buffer used to store scene data
  35607. * @returns a UniformBuffer
  35608. */
  35609. getSceneUniformBuffer(): UniformBuffer;
  35610. /**
  35611. * Gets an unique (relatively to the current scene) Id
  35612. * @returns an unique number for the scene
  35613. */
  35614. getUniqueId(): number;
  35615. /**
  35616. * Add a mesh to the list of scene's meshes
  35617. * @param newMesh defines the mesh to add
  35618. * @param recursive if all child meshes should also be added to the scene
  35619. */
  35620. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35621. /**
  35622. * Remove a mesh for the list of scene's meshes
  35623. * @param toRemove defines the mesh to remove
  35624. * @param recursive if all child meshes should also be removed from the scene
  35625. * @returns the index where the mesh was in the mesh list
  35626. */
  35627. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35628. /**
  35629. * Add a transform node to the list of scene's transform nodes
  35630. * @param newTransformNode defines the transform node to add
  35631. */
  35632. addTransformNode(newTransformNode: TransformNode): void;
  35633. /**
  35634. * Remove a transform node for the list of scene's transform nodes
  35635. * @param toRemove defines the transform node to remove
  35636. * @returns the index where the transform node was in the transform node list
  35637. */
  35638. removeTransformNode(toRemove: TransformNode): number;
  35639. /**
  35640. * Remove a skeleton for the list of scene's skeletons
  35641. * @param toRemove defines the skeleton to remove
  35642. * @returns the index where the skeleton was in the skeleton list
  35643. */
  35644. removeSkeleton(toRemove: Skeleton): number;
  35645. /**
  35646. * Remove a morph target for the list of scene's morph targets
  35647. * @param toRemove defines the morph target to remove
  35648. * @returns the index where the morph target was in the morph target list
  35649. */
  35650. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35651. /**
  35652. * Remove a light for the list of scene's lights
  35653. * @param toRemove defines the light to remove
  35654. * @returns the index where the light was in the light list
  35655. */
  35656. removeLight(toRemove: Light): number;
  35657. /**
  35658. * Remove a camera for the list of scene's cameras
  35659. * @param toRemove defines the camera to remove
  35660. * @returns the index where the camera was in the camera list
  35661. */
  35662. removeCamera(toRemove: Camera): number;
  35663. /**
  35664. * Remove a particle system for the list of scene's particle systems
  35665. * @param toRemove defines the particle system to remove
  35666. * @returns the index where the particle system was in the particle system list
  35667. */
  35668. removeParticleSystem(toRemove: IParticleSystem): number;
  35669. /**
  35670. * Remove a animation for the list of scene's animations
  35671. * @param toRemove defines the animation to remove
  35672. * @returns the index where the animation was in the animation list
  35673. */
  35674. removeAnimation(toRemove: Animation): number;
  35675. /**
  35676. * Will stop the animation of the given target
  35677. * @param target - the target
  35678. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35679. * @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)
  35680. */
  35681. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35682. /**
  35683. * Removes the given animation group from this scene.
  35684. * @param toRemove The animation group to remove
  35685. * @returns The index of the removed animation group
  35686. */
  35687. removeAnimationGroup(toRemove: AnimationGroup): number;
  35688. /**
  35689. * Removes the given multi-material from this scene.
  35690. * @param toRemove The multi-material to remove
  35691. * @returns The index of the removed multi-material
  35692. */
  35693. removeMultiMaterial(toRemove: MultiMaterial): number;
  35694. /**
  35695. * Removes the given material from this scene.
  35696. * @param toRemove The material to remove
  35697. * @returns The index of the removed material
  35698. */
  35699. removeMaterial(toRemove: Material): number;
  35700. /**
  35701. * Removes the given action manager from this scene.
  35702. * @param toRemove The action manager to remove
  35703. * @returns The index of the removed action manager
  35704. */
  35705. removeActionManager(toRemove: AbstractActionManager): number;
  35706. /**
  35707. * Removes the given texture from this scene.
  35708. * @param toRemove The texture to remove
  35709. * @returns The index of the removed texture
  35710. */
  35711. removeTexture(toRemove: BaseTexture): number;
  35712. /**
  35713. * Adds the given light to this scene
  35714. * @param newLight The light to add
  35715. */
  35716. addLight(newLight: Light): void;
  35717. /**
  35718. * Sorts the list list based on light priorities
  35719. */
  35720. sortLightsByPriority(): void;
  35721. /**
  35722. * Adds the given camera to this scene
  35723. * @param newCamera The camera to add
  35724. */
  35725. addCamera(newCamera: Camera): void;
  35726. /**
  35727. * Adds the given skeleton to this scene
  35728. * @param newSkeleton The skeleton to add
  35729. */
  35730. addSkeleton(newSkeleton: Skeleton): void;
  35731. /**
  35732. * Adds the given particle system to this scene
  35733. * @param newParticleSystem The particle system to add
  35734. */
  35735. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35736. /**
  35737. * Adds the given animation to this scene
  35738. * @param newAnimation The animation to add
  35739. */
  35740. addAnimation(newAnimation: Animation): void;
  35741. /**
  35742. * Adds the given animation group to this scene.
  35743. * @param newAnimationGroup The animation group to add
  35744. */
  35745. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35746. /**
  35747. * Adds the given multi-material to this scene
  35748. * @param newMultiMaterial The multi-material to add
  35749. */
  35750. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35751. /**
  35752. * Adds the given material to this scene
  35753. * @param newMaterial The material to add
  35754. */
  35755. addMaterial(newMaterial: Material): void;
  35756. /**
  35757. * Adds the given morph target to this scene
  35758. * @param newMorphTargetManager The morph target to add
  35759. */
  35760. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35761. /**
  35762. * Adds the given geometry to this scene
  35763. * @param newGeometry The geometry to add
  35764. */
  35765. addGeometry(newGeometry: Geometry): void;
  35766. /**
  35767. * Adds the given action manager to this scene
  35768. * @param newActionManager The action manager to add
  35769. */
  35770. addActionManager(newActionManager: AbstractActionManager): void;
  35771. /**
  35772. * Adds the given texture to this scene.
  35773. * @param newTexture The texture to add
  35774. */
  35775. addTexture(newTexture: BaseTexture): void;
  35776. /**
  35777. * Switch active camera
  35778. * @param newCamera defines the new active camera
  35779. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35780. */
  35781. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35782. /**
  35783. * sets the active camera of the scene using its ID
  35784. * @param id defines the camera's ID
  35785. * @return the new active camera or null if none found.
  35786. */
  35787. setActiveCameraByID(id: string): Nullable<Camera>;
  35788. /**
  35789. * sets the active camera of the scene using its name
  35790. * @param name defines the camera's name
  35791. * @returns the new active camera or null if none found.
  35792. */
  35793. setActiveCameraByName(name: string): Nullable<Camera>;
  35794. /**
  35795. * get an animation group using its name
  35796. * @param name defines the material's name
  35797. * @return the animation group or null if none found.
  35798. */
  35799. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35800. /**
  35801. * Get a material using its unique id
  35802. * @param uniqueId defines the material's unique id
  35803. * @return the material or null if none found.
  35804. */
  35805. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35806. /**
  35807. * get a material using its id
  35808. * @param id defines the material's ID
  35809. * @return the material or null if none found.
  35810. */
  35811. getMaterialByID(id: string): Nullable<Material>;
  35812. /**
  35813. * Gets a the last added material using a given id
  35814. * @param id defines the material's ID
  35815. * @return the last material with the given id or null if none found.
  35816. */
  35817. getLastMaterialByID(id: string): Nullable<Material>;
  35818. /**
  35819. * Gets a material using its name
  35820. * @param name defines the material's name
  35821. * @return the material or null if none found.
  35822. */
  35823. getMaterialByName(name: string): Nullable<Material>;
  35824. /**
  35825. * Get a texture using its unique id
  35826. * @param uniqueId defines the texture's unique id
  35827. * @return the texture or null if none found.
  35828. */
  35829. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35830. /**
  35831. * Gets a camera using its id
  35832. * @param id defines the id to look for
  35833. * @returns the camera or null if not found
  35834. */
  35835. getCameraByID(id: string): Nullable<Camera>;
  35836. /**
  35837. * Gets a camera using its unique id
  35838. * @param uniqueId defines the unique id to look for
  35839. * @returns the camera or null if not found
  35840. */
  35841. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35842. /**
  35843. * Gets a camera using its name
  35844. * @param name defines the camera's name
  35845. * @return the camera or null if none found.
  35846. */
  35847. getCameraByName(name: string): Nullable<Camera>;
  35848. /**
  35849. * Gets a bone using its id
  35850. * @param id defines the bone's id
  35851. * @return the bone or null if not found
  35852. */
  35853. getBoneByID(id: string): Nullable<Bone>;
  35854. /**
  35855. * Gets a bone using its id
  35856. * @param name defines the bone's name
  35857. * @return the bone or null if not found
  35858. */
  35859. getBoneByName(name: string): Nullable<Bone>;
  35860. /**
  35861. * Gets a light node using its name
  35862. * @param name defines the the light's name
  35863. * @return the light or null if none found.
  35864. */
  35865. getLightByName(name: string): Nullable<Light>;
  35866. /**
  35867. * Gets a light node using its id
  35868. * @param id defines the light's id
  35869. * @return the light or null if none found.
  35870. */
  35871. getLightByID(id: string): Nullable<Light>;
  35872. /**
  35873. * Gets a light node using its scene-generated unique ID
  35874. * @param uniqueId defines the light's unique id
  35875. * @return the light or null if none found.
  35876. */
  35877. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35878. /**
  35879. * Gets a particle system by id
  35880. * @param id defines the particle system id
  35881. * @return the corresponding system or null if none found
  35882. */
  35883. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35884. /**
  35885. * Gets a geometry using its ID
  35886. * @param id defines the geometry's id
  35887. * @return the geometry or null if none found.
  35888. */
  35889. getGeometryByID(id: string): Nullable<Geometry>;
  35890. private _getGeometryByUniqueID;
  35891. /**
  35892. * Add a new geometry to this scene
  35893. * @param geometry defines the geometry to be added to the scene.
  35894. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35895. * @return a boolean defining if the geometry was added or not
  35896. */
  35897. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35898. /**
  35899. * Removes an existing geometry
  35900. * @param geometry defines the geometry to be removed from the scene
  35901. * @return a boolean defining if the geometry was removed or not
  35902. */
  35903. removeGeometry(geometry: Geometry): boolean;
  35904. /**
  35905. * Gets the list of geometries attached to the scene
  35906. * @returns an array of Geometry
  35907. */
  35908. getGeometries(): Geometry[];
  35909. /**
  35910. * Gets the first added mesh found of a given ID
  35911. * @param id defines the id to search for
  35912. * @return the mesh found or null if not found at all
  35913. */
  35914. getMeshByID(id: string): Nullable<AbstractMesh>;
  35915. /**
  35916. * Gets a list of meshes using their id
  35917. * @param id defines the id to search for
  35918. * @returns a list of meshes
  35919. */
  35920. getMeshesByID(id: string): Array<AbstractMesh>;
  35921. /**
  35922. * Gets the first added transform node found of a given ID
  35923. * @param id defines the id to search for
  35924. * @return the found transform node or null if not found at all.
  35925. */
  35926. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35927. /**
  35928. * Gets a transform node with its auto-generated unique id
  35929. * @param uniqueId efines the unique id to search for
  35930. * @return the found transform node or null if not found at all.
  35931. */
  35932. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35933. /**
  35934. * Gets a list of transform nodes using their id
  35935. * @param id defines the id to search for
  35936. * @returns a list of transform nodes
  35937. */
  35938. getTransformNodesByID(id: string): Array<TransformNode>;
  35939. /**
  35940. * Gets a mesh with its auto-generated unique id
  35941. * @param uniqueId defines the unique id to search for
  35942. * @return the found mesh or null if not found at all.
  35943. */
  35944. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35945. /**
  35946. * Gets a the last added mesh using a given id
  35947. * @param id defines the id to search for
  35948. * @return the found mesh or null if not found at all.
  35949. */
  35950. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35951. /**
  35952. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35953. * @param id defines the id to search for
  35954. * @return the found node or null if not found at all
  35955. */
  35956. getLastEntryByID(id: string): Nullable<Node>;
  35957. /**
  35958. * Gets a node (Mesh, Camera, Light) using a given id
  35959. * @param id defines the id to search for
  35960. * @return the found node or null if not found at all
  35961. */
  35962. getNodeByID(id: string): Nullable<Node>;
  35963. /**
  35964. * Gets a node (Mesh, Camera, Light) using a given name
  35965. * @param name defines the name to search for
  35966. * @return the found node or null if not found at all.
  35967. */
  35968. getNodeByName(name: string): Nullable<Node>;
  35969. /**
  35970. * Gets a mesh using a given name
  35971. * @param name defines the name to search for
  35972. * @return the found mesh or null if not found at all.
  35973. */
  35974. getMeshByName(name: string): Nullable<AbstractMesh>;
  35975. /**
  35976. * Gets a transform node using a given name
  35977. * @param name defines the name to search for
  35978. * @return the found transform node or null if not found at all.
  35979. */
  35980. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35981. /**
  35982. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35983. * @param id defines the id to search for
  35984. * @return the found skeleton or null if not found at all.
  35985. */
  35986. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35987. /**
  35988. * Gets a skeleton using a given auto generated unique id
  35989. * @param uniqueId defines the unique id to search for
  35990. * @return the found skeleton or null if not found at all.
  35991. */
  35992. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35993. /**
  35994. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35995. * @param id defines the id to search for
  35996. * @return the found skeleton or null if not found at all.
  35997. */
  35998. getSkeletonById(id: string): Nullable<Skeleton>;
  35999. /**
  36000. * Gets a skeleton using a given name
  36001. * @param name defines the name to search for
  36002. * @return the found skeleton or null if not found at all.
  36003. */
  36004. getSkeletonByName(name: string): Nullable<Skeleton>;
  36005. /**
  36006. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36007. * @param id defines the id to search for
  36008. * @return the found morph target manager or null if not found at all.
  36009. */
  36010. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36011. /**
  36012. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36013. * @param id defines the id to search for
  36014. * @return the found morph target or null if not found at all.
  36015. */
  36016. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36017. /**
  36018. * Gets a boolean indicating if the given mesh is active
  36019. * @param mesh defines the mesh to look for
  36020. * @returns true if the mesh is in the active list
  36021. */
  36022. isActiveMesh(mesh: AbstractMesh): boolean;
  36023. /**
  36024. * Return a unique id as a string which can serve as an identifier for the scene
  36025. */
  36026. readonly uid: string;
  36027. /**
  36028. * Add an externaly attached data from its key.
  36029. * This method call will fail and return false, if such key already exists.
  36030. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36031. * @param key the unique key that identifies the data
  36032. * @param data the data object to associate to the key for this Engine instance
  36033. * @return true if no such key were already present and the data was added successfully, false otherwise
  36034. */
  36035. addExternalData<T>(key: string, data: T): boolean;
  36036. /**
  36037. * Get an externaly attached data from its key
  36038. * @param key the unique key that identifies the data
  36039. * @return the associated data, if present (can be null), or undefined if not present
  36040. */
  36041. getExternalData<T>(key: string): Nullable<T>;
  36042. /**
  36043. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36044. * @param key the unique key that identifies the data
  36045. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36046. * @return the associated data, can be null if the factory returned null.
  36047. */
  36048. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36049. /**
  36050. * Remove an externaly attached data from the Engine instance
  36051. * @param key the unique key that identifies the data
  36052. * @return true if the data was successfully removed, false if it doesn't exist
  36053. */
  36054. removeExternalData(key: string): boolean;
  36055. private _evaluateSubMesh;
  36056. /**
  36057. * Clear the processed materials smart array preventing retention point in material dispose.
  36058. */
  36059. freeProcessedMaterials(): void;
  36060. private _preventFreeActiveMeshesAndRenderingGroups;
  36061. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36062. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36063. * when disposing several meshes in a row or a hierarchy of meshes.
  36064. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36065. */
  36066. blockfreeActiveMeshesAndRenderingGroups: boolean;
  36067. /**
  36068. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36069. */
  36070. freeActiveMeshes(): void;
  36071. /**
  36072. * Clear the info related to rendering groups preventing retention points during dispose.
  36073. */
  36074. freeRenderingGroups(): void;
  36075. /** @hidden */
  36076. _isInIntermediateRendering(): boolean;
  36077. /**
  36078. * Lambda returning the list of potentially active meshes.
  36079. */
  36080. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36081. /**
  36082. * Lambda returning the list of potentially active sub meshes.
  36083. */
  36084. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36085. /**
  36086. * Lambda returning the list of potentially intersecting sub meshes.
  36087. */
  36088. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36089. /**
  36090. * Lambda returning the list of potentially colliding sub meshes.
  36091. */
  36092. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36093. private _activeMeshesFrozen;
  36094. private _skipEvaluateActiveMeshesCompletely;
  36095. /**
  36096. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36097. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36098. * @returns the current scene
  36099. */
  36100. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36101. /**
  36102. * Use this function to restart evaluating active meshes on every frame
  36103. * @returns the current scene
  36104. */
  36105. unfreezeActiveMeshes(): Scene;
  36106. private _evaluateActiveMeshes;
  36107. private _activeMesh;
  36108. /**
  36109. * Update the transform matrix to update from the current active camera
  36110. * @param force defines a boolean used to force the update even if cache is up to date
  36111. */
  36112. updateTransformMatrix(force?: boolean): void;
  36113. private _bindFrameBuffer;
  36114. /** @hidden */
  36115. _allowPostProcessClearColor: boolean;
  36116. /** @hidden */
  36117. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36118. private _processSubCameras;
  36119. private _checkIntersections;
  36120. /** @hidden */
  36121. _advancePhysicsEngineStep(step: number): void;
  36122. /**
  36123. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36124. */
  36125. getDeterministicFrameTime: () => number;
  36126. /** @hidden */
  36127. _animate(): void;
  36128. /** Execute all animations (for a frame) */
  36129. animate(): void;
  36130. /**
  36131. * Render the scene
  36132. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36133. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36134. */
  36135. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36136. /**
  36137. * Freeze all materials
  36138. * A frozen material will not be updatable but should be faster to render
  36139. */
  36140. freezeMaterials(): void;
  36141. /**
  36142. * Unfreeze all materials
  36143. * A frozen material will not be updatable but should be faster to render
  36144. */
  36145. unfreezeMaterials(): void;
  36146. /**
  36147. * Releases all held ressources
  36148. */
  36149. dispose(): void;
  36150. /**
  36151. * Gets if the scene is already disposed
  36152. */
  36153. readonly isDisposed: boolean;
  36154. /**
  36155. * Call this function to reduce memory footprint of the scene.
  36156. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36157. */
  36158. clearCachedVertexData(): void;
  36159. /**
  36160. * This function will remove the local cached buffer data from texture.
  36161. * It will save memory but will prevent the texture from being rebuilt
  36162. */
  36163. cleanCachedTextureBuffer(): void;
  36164. /**
  36165. * Get the world extend vectors with an optional filter
  36166. *
  36167. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36168. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36169. */
  36170. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36171. min: Vector3;
  36172. max: Vector3;
  36173. };
  36174. /**
  36175. * Creates a ray that can be used to pick in the scene
  36176. * @param x defines the x coordinate of the origin (on-screen)
  36177. * @param y defines the y coordinate of the origin (on-screen)
  36178. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36179. * @param camera defines the camera to use for the picking
  36180. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36181. * @returns a Ray
  36182. */
  36183. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36184. /**
  36185. * Creates a ray that can be used to pick in the scene
  36186. * @param x defines the x coordinate of the origin (on-screen)
  36187. * @param y defines the y coordinate of the origin (on-screen)
  36188. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36189. * @param result defines the ray where to store the picking ray
  36190. * @param camera defines the camera to use for the picking
  36191. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36192. * @returns the current scene
  36193. */
  36194. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36195. /**
  36196. * Creates a ray that can be used to pick in the scene
  36197. * @param x defines the x coordinate of the origin (on-screen)
  36198. * @param y defines the y coordinate of the origin (on-screen)
  36199. * @param camera defines the camera to use for the picking
  36200. * @returns a Ray
  36201. */
  36202. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36203. /**
  36204. * Creates a ray that can be used to pick in the scene
  36205. * @param x defines the x coordinate of the origin (on-screen)
  36206. * @param y defines the y coordinate of the origin (on-screen)
  36207. * @param result defines the ray where to store the picking ray
  36208. * @param camera defines the camera to use for the picking
  36209. * @returns the current scene
  36210. */
  36211. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36212. /** Launch a ray to try to pick a mesh in the scene
  36213. * @param x position on screen
  36214. * @param y position on screen
  36215. * @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
  36216. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36217. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36218. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36219. * @returns a PickingInfo
  36220. */
  36221. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36222. /** Use the given ray to pick a mesh in the scene
  36223. * @param ray The ray to use to pick meshes
  36224. * @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
  36225. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36226. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36227. * @returns a PickingInfo
  36228. */
  36229. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36230. /**
  36231. * Launch a ray to try to pick a mesh in the scene
  36232. * @param x X position on screen
  36233. * @param y Y position on screen
  36234. * @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
  36235. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36236. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36237. * @returns an array of PickingInfo
  36238. */
  36239. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36240. /**
  36241. * Launch a ray to try to pick a mesh in the scene
  36242. * @param ray Ray to use
  36243. * @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
  36244. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36245. * @returns an array of PickingInfo
  36246. */
  36247. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36248. /**
  36249. * Force the value of meshUnderPointer
  36250. * @param mesh defines the mesh to use
  36251. */
  36252. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36253. /**
  36254. * Gets the mesh under the pointer
  36255. * @returns a Mesh or null if no mesh is under the pointer
  36256. */
  36257. getPointerOverMesh(): Nullable<AbstractMesh>;
  36258. /** @hidden */
  36259. _rebuildGeometries(): void;
  36260. /** @hidden */
  36261. _rebuildTextures(): void;
  36262. private _getByTags;
  36263. /**
  36264. * Get a list of meshes by tags
  36265. * @param tagsQuery defines the tags query to use
  36266. * @param forEach defines a predicate used to filter results
  36267. * @returns an array of Mesh
  36268. */
  36269. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36270. /**
  36271. * Get a list of cameras by tags
  36272. * @param tagsQuery defines the tags query to use
  36273. * @param forEach defines a predicate used to filter results
  36274. * @returns an array of Camera
  36275. */
  36276. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36277. /**
  36278. * Get a list of lights by tags
  36279. * @param tagsQuery defines the tags query to use
  36280. * @param forEach defines a predicate used to filter results
  36281. * @returns an array of Light
  36282. */
  36283. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36284. /**
  36285. * Get a list of materials by tags
  36286. * @param tagsQuery defines the tags query to use
  36287. * @param forEach defines a predicate used to filter results
  36288. * @returns an array of Material
  36289. */
  36290. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36291. /**
  36292. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36293. * This allowed control for front to back rendering or reversly depending of the special needs.
  36294. *
  36295. * @param renderingGroupId The rendering group id corresponding to its index
  36296. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36297. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36298. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36299. */
  36300. 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;
  36301. /**
  36302. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36303. *
  36304. * @param renderingGroupId The rendering group id corresponding to its index
  36305. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36306. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36307. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36308. */
  36309. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36310. /**
  36311. * Gets the current auto clear configuration for one rendering group of the rendering
  36312. * manager.
  36313. * @param index the rendering group index to get the information for
  36314. * @returns The auto clear setup for the requested rendering group
  36315. */
  36316. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36317. private _blockMaterialDirtyMechanism;
  36318. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36319. blockMaterialDirtyMechanism: boolean;
  36320. /**
  36321. * Will flag all materials as dirty to trigger new shader compilation
  36322. * @param flag defines the flag used to specify which material part must be marked as dirty
  36323. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36324. */
  36325. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36326. /** @hidden */
  36327. _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;
  36328. /** @hidden */
  36329. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36330. /** @hidden */
  36331. _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;
  36332. /** @hidden */
  36333. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36334. /** @hidden */
  36335. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36336. /** @hidden */
  36337. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36338. }
  36339. }
  36340. declare module BABYLON {
  36341. /**
  36342. * Set of assets to keep when moving a scene into an asset container.
  36343. */
  36344. export class KeepAssets extends AbstractScene {
  36345. }
  36346. /**
  36347. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36348. */
  36349. export class InstantiatedEntries {
  36350. /**
  36351. * List of new root nodes (eg. nodes with no parent)
  36352. */
  36353. rootNodes: TransformNode[];
  36354. /**
  36355. * List of new skeletons
  36356. */
  36357. skeletons: Skeleton[];
  36358. /**
  36359. * List of new animation groups
  36360. */
  36361. animationGroups: AnimationGroup[];
  36362. }
  36363. /**
  36364. * Container with a set of assets that can be added or removed from a scene.
  36365. */
  36366. export class AssetContainer extends AbstractScene {
  36367. /**
  36368. * The scene the AssetContainer belongs to.
  36369. */
  36370. scene: Scene;
  36371. /**
  36372. * Instantiates an AssetContainer.
  36373. * @param scene The scene the AssetContainer belongs to.
  36374. */
  36375. constructor(scene: Scene);
  36376. /**
  36377. * Instantiate or clone all meshes and add the new ones to the scene.
  36378. * Skeletons and animation groups will all be cloned
  36379. * @param nameFunction defines an optional function used to get new names for clones
  36380. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36381. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36382. */
  36383. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36384. /**
  36385. * Adds all the assets from the container to the scene.
  36386. */
  36387. addAllToScene(): void;
  36388. /**
  36389. * Removes all the assets in the container from the scene
  36390. */
  36391. removeAllFromScene(): void;
  36392. /**
  36393. * Disposes all the assets in the container
  36394. */
  36395. dispose(): void;
  36396. private _moveAssets;
  36397. /**
  36398. * Removes all the assets contained in the scene and adds them to the container.
  36399. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36400. */
  36401. moveAllFromScene(keepAssets?: KeepAssets): void;
  36402. /**
  36403. * 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.
  36404. * @returns the root mesh
  36405. */
  36406. createRootMesh(): Mesh;
  36407. /**
  36408. * Merge animations from this asset container into a scene
  36409. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36410. * @param animatables set of animatables to retarget to a node from the scene
  36411. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36412. */
  36413. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36414. }
  36415. }
  36416. declare module BABYLON {
  36417. /**
  36418. * Defines how the parser contract is defined.
  36419. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36420. */
  36421. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36422. /**
  36423. * Defines how the individual parser contract is defined.
  36424. * These parser can parse an individual asset
  36425. */
  36426. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36427. /**
  36428. * Base class of the scene acting as a container for the different elements composing a scene.
  36429. * This class is dynamically extended by the different components of the scene increasing
  36430. * flexibility and reducing coupling
  36431. */
  36432. export abstract class AbstractScene {
  36433. /**
  36434. * Stores the list of available parsers in the application.
  36435. */
  36436. private static _BabylonFileParsers;
  36437. /**
  36438. * Stores the list of available individual parsers in the application.
  36439. */
  36440. private static _IndividualBabylonFileParsers;
  36441. /**
  36442. * Adds a parser in the list of available ones
  36443. * @param name Defines the name of the parser
  36444. * @param parser Defines the parser to add
  36445. */
  36446. static AddParser(name: string, parser: BabylonFileParser): void;
  36447. /**
  36448. * Gets a general parser from the list of avaialble ones
  36449. * @param name Defines the name of the parser
  36450. * @returns the requested parser or null
  36451. */
  36452. static GetParser(name: string): Nullable<BabylonFileParser>;
  36453. /**
  36454. * Adds n individual parser in the list of available ones
  36455. * @param name Defines the name of the parser
  36456. * @param parser Defines the parser to add
  36457. */
  36458. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36459. /**
  36460. * Gets an individual parser from the list of avaialble ones
  36461. * @param name Defines the name of the parser
  36462. * @returns the requested parser or null
  36463. */
  36464. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36465. /**
  36466. * Parser json data and populate both a scene and its associated container object
  36467. * @param jsonData Defines the data to parse
  36468. * @param scene Defines the scene to parse the data for
  36469. * @param container Defines the container attached to the parsing sequence
  36470. * @param rootUrl Defines the root url of the data
  36471. */
  36472. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36473. /**
  36474. * Gets the list of root nodes (ie. nodes with no parent)
  36475. */
  36476. rootNodes: Node[];
  36477. /** All of the cameras added to this scene
  36478. * @see http://doc.babylonjs.com/babylon101/cameras
  36479. */
  36480. cameras: Camera[];
  36481. /**
  36482. * All of the lights added to this scene
  36483. * @see http://doc.babylonjs.com/babylon101/lights
  36484. */
  36485. lights: Light[];
  36486. /**
  36487. * All of the (abstract) meshes added to this scene
  36488. */
  36489. meshes: AbstractMesh[];
  36490. /**
  36491. * The list of skeletons added to the scene
  36492. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36493. */
  36494. skeletons: Skeleton[];
  36495. /**
  36496. * All of the particle systems added to this scene
  36497. * @see http://doc.babylonjs.com/babylon101/particles
  36498. */
  36499. particleSystems: IParticleSystem[];
  36500. /**
  36501. * Gets a list of Animations associated with the scene
  36502. */
  36503. animations: Animation[];
  36504. /**
  36505. * All of the animation groups added to this scene
  36506. * @see http://doc.babylonjs.com/how_to/group
  36507. */
  36508. animationGroups: AnimationGroup[];
  36509. /**
  36510. * All of the multi-materials added to this scene
  36511. * @see http://doc.babylonjs.com/how_to/multi_materials
  36512. */
  36513. multiMaterials: MultiMaterial[];
  36514. /**
  36515. * All of the materials added to this scene
  36516. * In the context of a Scene, it is not supposed to be modified manually.
  36517. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36518. * Note also that the order of the Material within the array is not significant and might change.
  36519. * @see http://doc.babylonjs.com/babylon101/materials
  36520. */
  36521. materials: Material[];
  36522. /**
  36523. * The list of morph target managers added to the scene
  36524. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36525. */
  36526. morphTargetManagers: MorphTargetManager[];
  36527. /**
  36528. * The list of geometries used in the scene.
  36529. */
  36530. geometries: Geometry[];
  36531. /**
  36532. * All of the tranform nodes added to this scene
  36533. * In the context of a Scene, it is not supposed to be modified manually.
  36534. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36535. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36536. * @see http://doc.babylonjs.com/how_to/transformnode
  36537. */
  36538. transformNodes: TransformNode[];
  36539. /**
  36540. * ActionManagers available on the scene.
  36541. */
  36542. actionManagers: AbstractActionManager[];
  36543. /**
  36544. * Textures to keep.
  36545. */
  36546. textures: BaseTexture[];
  36547. /**
  36548. * Environment texture for the scene
  36549. */
  36550. environmentTexture: Nullable<BaseTexture>;
  36551. /**
  36552. * @returns all meshes, lights, cameras, transformNodes and bones
  36553. */
  36554. getNodes(): Array<Node>;
  36555. }
  36556. }
  36557. declare module BABYLON {
  36558. /**
  36559. * Interface used to define options for Sound class
  36560. */
  36561. export interface ISoundOptions {
  36562. /**
  36563. * Does the sound autoplay once loaded.
  36564. */
  36565. autoplay?: boolean;
  36566. /**
  36567. * Does the sound loop after it finishes playing once.
  36568. */
  36569. loop?: boolean;
  36570. /**
  36571. * Sound's volume
  36572. */
  36573. volume?: number;
  36574. /**
  36575. * Is it a spatial sound?
  36576. */
  36577. spatialSound?: boolean;
  36578. /**
  36579. * Maximum distance to hear that sound
  36580. */
  36581. maxDistance?: number;
  36582. /**
  36583. * Uses user defined attenuation function
  36584. */
  36585. useCustomAttenuation?: boolean;
  36586. /**
  36587. * Define the roll off factor of spatial sounds.
  36588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36589. */
  36590. rolloffFactor?: number;
  36591. /**
  36592. * Define the reference distance the sound should be heard perfectly.
  36593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36594. */
  36595. refDistance?: number;
  36596. /**
  36597. * Define the distance attenuation model the sound will follow.
  36598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36599. */
  36600. distanceModel?: string;
  36601. /**
  36602. * Defines the playback speed (1 by default)
  36603. */
  36604. playbackRate?: number;
  36605. /**
  36606. * Defines if the sound is from a streaming source
  36607. */
  36608. streaming?: boolean;
  36609. /**
  36610. * Defines an optional length (in seconds) inside the sound file
  36611. */
  36612. length?: number;
  36613. /**
  36614. * Defines an optional offset (in seconds) inside the sound file
  36615. */
  36616. offset?: number;
  36617. /**
  36618. * If true, URLs will not be required to state the audio file codec to use.
  36619. */
  36620. skipCodecCheck?: boolean;
  36621. }
  36622. /**
  36623. * Defines a sound that can be played in the application.
  36624. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36626. */
  36627. export class Sound {
  36628. /**
  36629. * The name of the sound in the scene.
  36630. */
  36631. name: string;
  36632. /**
  36633. * Does the sound autoplay once loaded.
  36634. */
  36635. autoplay: boolean;
  36636. /**
  36637. * Does the sound loop after it finishes playing once.
  36638. */
  36639. loop: boolean;
  36640. /**
  36641. * Does the sound use a custom attenuation curve to simulate the falloff
  36642. * happening when the source gets further away from the camera.
  36643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36644. */
  36645. useCustomAttenuation: boolean;
  36646. /**
  36647. * The sound track id this sound belongs to.
  36648. */
  36649. soundTrackId: number;
  36650. /**
  36651. * Is this sound currently played.
  36652. */
  36653. isPlaying: boolean;
  36654. /**
  36655. * Is this sound currently paused.
  36656. */
  36657. isPaused: boolean;
  36658. /**
  36659. * Does this sound enables spatial sound.
  36660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36661. */
  36662. spatialSound: boolean;
  36663. /**
  36664. * Define the reference distance the sound should be heard perfectly.
  36665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36666. */
  36667. refDistance: number;
  36668. /**
  36669. * Define the roll off factor of spatial sounds.
  36670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36671. */
  36672. rolloffFactor: number;
  36673. /**
  36674. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36676. */
  36677. maxDistance: number;
  36678. /**
  36679. * Define the distance attenuation model the sound will follow.
  36680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36681. */
  36682. distanceModel: string;
  36683. /**
  36684. * @hidden
  36685. * Back Compat
  36686. **/
  36687. onended: () => any;
  36688. /**
  36689. * Observable event when the current playing sound finishes.
  36690. */
  36691. onEndedObservable: Observable<Sound>;
  36692. private _panningModel;
  36693. private _playbackRate;
  36694. private _streaming;
  36695. private _startTime;
  36696. private _startOffset;
  36697. private _position;
  36698. /** @hidden */
  36699. _positionInEmitterSpace: boolean;
  36700. private _localDirection;
  36701. private _volume;
  36702. private _isReadyToPlay;
  36703. private _isDirectional;
  36704. private _readyToPlayCallback;
  36705. private _audioBuffer;
  36706. private _soundSource;
  36707. private _streamingSource;
  36708. private _soundPanner;
  36709. private _soundGain;
  36710. private _inputAudioNode;
  36711. private _outputAudioNode;
  36712. private _coneInnerAngle;
  36713. private _coneOuterAngle;
  36714. private _coneOuterGain;
  36715. private _scene;
  36716. private _connectedTransformNode;
  36717. private _customAttenuationFunction;
  36718. private _registerFunc;
  36719. private _isOutputConnected;
  36720. private _htmlAudioElement;
  36721. private _urlType;
  36722. private _length?;
  36723. private _offset?;
  36724. /** @hidden */
  36725. static _SceneComponentInitialization: (scene: Scene) => void;
  36726. /**
  36727. * Create a sound and attach it to a scene
  36728. * @param name Name of your sound
  36729. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36730. * @param scene defines the scene the sound belongs to
  36731. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36732. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36733. */
  36734. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36735. /**
  36736. * Release the sound and its associated resources
  36737. */
  36738. dispose(): void;
  36739. /**
  36740. * Gets if the sounds is ready to be played or not.
  36741. * @returns true if ready, otherwise false
  36742. */
  36743. isReady(): boolean;
  36744. private _soundLoaded;
  36745. /**
  36746. * Sets the data of the sound from an audiobuffer
  36747. * @param audioBuffer The audioBuffer containing the data
  36748. */
  36749. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36750. /**
  36751. * Updates the current sounds options such as maxdistance, loop...
  36752. * @param options A JSON object containing values named as the object properties
  36753. */
  36754. updateOptions(options: ISoundOptions): void;
  36755. private _createSpatialParameters;
  36756. private _updateSpatialParameters;
  36757. /**
  36758. * Switch the panning model to HRTF:
  36759. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36761. */
  36762. switchPanningModelToHRTF(): void;
  36763. /**
  36764. * Switch the panning model to Equal Power:
  36765. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36767. */
  36768. switchPanningModelToEqualPower(): void;
  36769. private _switchPanningModel;
  36770. /**
  36771. * Connect this sound to a sound track audio node like gain...
  36772. * @param soundTrackAudioNode the sound track audio node to connect to
  36773. */
  36774. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36775. /**
  36776. * Transform this sound into a directional source
  36777. * @param coneInnerAngle Size of the inner cone in degree
  36778. * @param coneOuterAngle Size of the outer cone in degree
  36779. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36780. */
  36781. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36782. /**
  36783. * Gets or sets the inner angle for the directional cone.
  36784. */
  36785. /**
  36786. * Gets or sets the inner angle for the directional cone.
  36787. */
  36788. directionalConeInnerAngle: number;
  36789. /**
  36790. * Gets or sets the outer angle for the directional cone.
  36791. */
  36792. /**
  36793. * Gets or sets the outer angle for the directional cone.
  36794. */
  36795. directionalConeOuterAngle: number;
  36796. /**
  36797. * Sets the position of the emitter if spatial sound is enabled
  36798. * @param newPosition Defines the new posisiton
  36799. */
  36800. setPosition(newPosition: Vector3): void;
  36801. /**
  36802. * Sets the local direction of the emitter if spatial sound is enabled
  36803. * @param newLocalDirection Defines the new local direction
  36804. */
  36805. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36806. private _updateDirection;
  36807. /** @hidden */
  36808. updateDistanceFromListener(): void;
  36809. /**
  36810. * Sets a new custom attenuation function for the sound.
  36811. * @param callback Defines the function used for the attenuation
  36812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36813. */
  36814. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36815. /**
  36816. * Play the sound
  36817. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36818. * @param offset (optional) Start the sound at a specific time in seconds
  36819. * @param length (optional) Sound duration (in seconds)
  36820. */
  36821. play(time?: number, offset?: number, length?: number): void;
  36822. private _onended;
  36823. /**
  36824. * Stop the sound
  36825. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36826. */
  36827. stop(time?: number): void;
  36828. /**
  36829. * Put the sound in pause
  36830. */
  36831. pause(): void;
  36832. /**
  36833. * Sets a dedicated volume for this sounds
  36834. * @param newVolume Define the new volume of the sound
  36835. * @param time Define time for gradual change to new volume
  36836. */
  36837. setVolume(newVolume: number, time?: number): void;
  36838. /**
  36839. * Set the sound play back rate
  36840. * @param newPlaybackRate Define the playback rate the sound should be played at
  36841. */
  36842. setPlaybackRate(newPlaybackRate: number): void;
  36843. /**
  36844. * Gets the volume of the sound.
  36845. * @returns the volume of the sound
  36846. */
  36847. getVolume(): number;
  36848. /**
  36849. * Attach the sound to a dedicated mesh
  36850. * @param transformNode The transform node to connect the sound with
  36851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36852. */
  36853. attachToMesh(transformNode: TransformNode): void;
  36854. /**
  36855. * Detach the sound from the previously attached mesh
  36856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36857. */
  36858. detachFromMesh(): void;
  36859. private _onRegisterAfterWorldMatrixUpdate;
  36860. /**
  36861. * Clone the current sound in the scene.
  36862. * @returns the new sound clone
  36863. */
  36864. clone(): Nullable<Sound>;
  36865. /**
  36866. * Gets the current underlying audio buffer containing the data
  36867. * @returns the audio buffer
  36868. */
  36869. getAudioBuffer(): Nullable<AudioBuffer>;
  36870. /**
  36871. * Serializes the Sound in a JSON representation
  36872. * @returns the JSON representation of the sound
  36873. */
  36874. serialize(): any;
  36875. /**
  36876. * Parse a JSON representation of a sound to innstantiate in a given scene
  36877. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36878. * @param scene Define the scene the new parsed sound should be created in
  36879. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36880. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36881. * @returns the newly parsed sound
  36882. */
  36883. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36884. }
  36885. }
  36886. declare module BABYLON {
  36887. /**
  36888. * This defines an action helpful to play a defined sound on a triggered action.
  36889. */
  36890. export class PlaySoundAction extends Action {
  36891. private _sound;
  36892. /**
  36893. * Instantiate the action
  36894. * @param triggerOptions defines the trigger options
  36895. * @param sound defines the sound to play
  36896. * @param condition defines the trigger related conditions
  36897. */
  36898. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36899. /** @hidden */
  36900. _prepare(): void;
  36901. /**
  36902. * Execute the action and play the sound.
  36903. */
  36904. execute(): void;
  36905. /**
  36906. * Serializes the actions and its related information.
  36907. * @param parent defines the object to serialize in
  36908. * @returns the serialized object
  36909. */
  36910. serialize(parent: any): any;
  36911. }
  36912. /**
  36913. * This defines an action helpful to stop a defined sound on a triggered action.
  36914. */
  36915. export class StopSoundAction extends Action {
  36916. private _sound;
  36917. /**
  36918. * Instantiate the action
  36919. * @param triggerOptions defines the trigger options
  36920. * @param sound defines the sound to stop
  36921. * @param condition defines the trigger related conditions
  36922. */
  36923. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36924. /** @hidden */
  36925. _prepare(): void;
  36926. /**
  36927. * Execute the action and stop the sound.
  36928. */
  36929. execute(): void;
  36930. /**
  36931. * Serializes the actions and its related information.
  36932. * @param parent defines the object to serialize in
  36933. * @returns the serialized object
  36934. */
  36935. serialize(parent: any): any;
  36936. }
  36937. }
  36938. declare module BABYLON {
  36939. /**
  36940. * This defines an action responsible to change the value of a property
  36941. * by interpolating between its current value and the newly set one once triggered.
  36942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36943. */
  36944. export class InterpolateValueAction extends Action {
  36945. /**
  36946. * Defines the path of the property where the value should be interpolated
  36947. */
  36948. propertyPath: string;
  36949. /**
  36950. * Defines the target value at the end of the interpolation.
  36951. */
  36952. value: any;
  36953. /**
  36954. * Defines the time it will take for the property to interpolate to the value.
  36955. */
  36956. duration: number;
  36957. /**
  36958. * Defines if the other scene animations should be stopped when the action has been triggered
  36959. */
  36960. stopOtherAnimations?: boolean;
  36961. /**
  36962. * Defines a callback raised once the interpolation animation has been done.
  36963. */
  36964. onInterpolationDone?: () => void;
  36965. /**
  36966. * Observable triggered once the interpolation animation has been done.
  36967. */
  36968. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36969. private _target;
  36970. private _effectiveTarget;
  36971. private _property;
  36972. /**
  36973. * Instantiate the action
  36974. * @param triggerOptions defines the trigger options
  36975. * @param target defines the object containing the value to interpolate
  36976. * @param propertyPath defines the path to the property in the target object
  36977. * @param value defines the target value at the end of the interpolation
  36978. * @param duration deines the time it will take for the property to interpolate to the value.
  36979. * @param condition defines the trigger related conditions
  36980. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36981. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36982. */
  36983. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36984. /** @hidden */
  36985. _prepare(): void;
  36986. /**
  36987. * Execute the action starts the value interpolation.
  36988. */
  36989. execute(): void;
  36990. /**
  36991. * Serializes the actions and its related information.
  36992. * @param parent defines the object to serialize in
  36993. * @returns the serialized object
  36994. */
  36995. serialize(parent: any): any;
  36996. }
  36997. }
  36998. declare module BABYLON {
  36999. /**
  37000. * Options allowed during the creation of a sound track.
  37001. */
  37002. export interface ISoundTrackOptions {
  37003. /**
  37004. * The volume the sound track should take during creation
  37005. */
  37006. volume?: number;
  37007. /**
  37008. * Define if the sound track is the main sound track of the scene
  37009. */
  37010. mainTrack?: boolean;
  37011. }
  37012. /**
  37013. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37014. * It will be also used in a future release to apply effects on a specific track.
  37015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37016. */
  37017. export class SoundTrack {
  37018. /**
  37019. * The unique identifier of the sound track in the scene.
  37020. */
  37021. id: number;
  37022. /**
  37023. * The list of sounds included in the sound track.
  37024. */
  37025. soundCollection: Array<Sound>;
  37026. private _outputAudioNode;
  37027. private _scene;
  37028. private _connectedAnalyser;
  37029. private _options;
  37030. private _isInitialized;
  37031. /**
  37032. * Creates a new sound track.
  37033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37034. * @param scene Define the scene the sound track belongs to
  37035. * @param options
  37036. */
  37037. constructor(scene: Scene, options?: ISoundTrackOptions);
  37038. private _initializeSoundTrackAudioGraph;
  37039. /**
  37040. * Release the sound track and its associated resources
  37041. */
  37042. dispose(): void;
  37043. /**
  37044. * Adds a sound to this sound track
  37045. * @param sound define the cound to add
  37046. * @ignoreNaming
  37047. */
  37048. AddSound(sound: Sound): void;
  37049. /**
  37050. * Removes a sound to this sound track
  37051. * @param sound define the cound to remove
  37052. * @ignoreNaming
  37053. */
  37054. RemoveSound(sound: Sound): void;
  37055. /**
  37056. * Set a global volume for the full sound track.
  37057. * @param newVolume Define the new volume of the sound track
  37058. */
  37059. setVolume(newVolume: number): void;
  37060. /**
  37061. * Switch the panning model to HRTF:
  37062. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37064. */
  37065. switchPanningModelToHRTF(): void;
  37066. /**
  37067. * Switch the panning model to Equal Power:
  37068. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37070. */
  37071. switchPanningModelToEqualPower(): void;
  37072. /**
  37073. * Connect the sound track to an audio analyser allowing some amazing
  37074. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37076. * @param analyser The analyser to connect to the engine
  37077. */
  37078. connectToAnalyser(analyser: Analyser): void;
  37079. }
  37080. }
  37081. declare module BABYLON {
  37082. interface AbstractScene {
  37083. /**
  37084. * The list of sounds used in the scene.
  37085. */
  37086. sounds: Nullable<Array<Sound>>;
  37087. }
  37088. interface Scene {
  37089. /**
  37090. * @hidden
  37091. * Backing field
  37092. */
  37093. _mainSoundTrack: SoundTrack;
  37094. /**
  37095. * The main sound track played by the scene.
  37096. * It cotains your primary collection of sounds.
  37097. */
  37098. mainSoundTrack: SoundTrack;
  37099. /**
  37100. * The list of sound tracks added to the scene
  37101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37102. */
  37103. soundTracks: Nullable<Array<SoundTrack>>;
  37104. /**
  37105. * Gets a sound using a given name
  37106. * @param name defines the name to search for
  37107. * @return the found sound or null if not found at all.
  37108. */
  37109. getSoundByName(name: string): Nullable<Sound>;
  37110. /**
  37111. * Gets or sets if audio support is enabled
  37112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37113. */
  37114. audioEnabled: boolean;
  37115. /**
  37116. * Gets or sets if audio will be output to headphones
  37117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37118. */
  37119. headphone: boolean;
  37120. /**
  37121. * Gets or sets custom audio listener position provider
  37122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37123. */
  37124. audioListenerPositionProvider: Nullable<() => Vector3>;
  37125. /**
  37126. * Gets or sets a refresh rate when using 3D audio positioning
  37127. */
  37128. audioPositioningRefreshRate: number;
  37129. }
  37130. /**
  37131. * Defines the sound scene component responsible to manage any sounds
  37132. * in a given scene.
  37133. */
  37134. export class AudioSceneComponent implements ISceneSerializableComponent {
  37135. /**
  37136. * The component name helpfull to identify the component in the list of scene components.
  37137. */
  37138. readonly name: string;
  37139. /**
  37140. * The scene the component belongs to.
  37141. */
  37142. scene: Scene;
  37143. private _audioEnabled;
  37144. /**
  37145. * Gets whether audio is enabled or not.
  37146. * Please use related enable/disable method to switch state.
  37147. */
  37148. readonly audioEnabled: boolean;
  37149. private _headphone;
  37150. /**
  37151. * Gets whether audio is outputing to headphone or not.
  37152. * Please use the according Switch methods to change output.
  37153. */
  37154. readonly headphone: boolean;
  37155. /**
  37156. * Gets or sets a refresh rate when using 3D audio positioning
  37157. */
  37158. audioPositioningRefreshRate: number;
  37159. private _audioListenerPositionProvider;
  37160. /**
  37161. * Gets the current audio listener position provider
  37162. */
  37163. /**
  37164. * Sets a custom listener position for all sounds in the scene
  37165. * By default, this is the position of the first active camera
  37166. */
  37167. audioListenerPositionProvider: Nullable<() => Vector3>;
  37168. /**
  37169. * Creates a new instance of the component for the given scene
  37170. * @param scene Defines the scene to register the component in
  37171. */
  37172. constructor(scene: Scene);
  37173. /**
  37174. * Registers the component in a given scene
  37175. */
  37176. register(): void;
  37177. /**
  37178. * Rebuilds the elements related to this component in case of
  37179. * context lost for instance.
  37180. */
  37181. rebuild(): void;
  37182. /**
  37183. * Serializes the component data to the specified json object
  37184. * @param serializationObject The object to serialize to
  37185. */
  37186. serialize(serializationObject: any): void;
  37187. /**
  37188. * Adds all the elements from the container to the scene
  37189. * @param container the container holding the elements
  37190. */
  37191. addFromContainer(container: AbstractScene): void;
  37192. /**
  37193. * Removes all the elements in the container from the scene
  37194. * @param container contains the elements to remove
  37195. * @param dispose if the removed element should be disposed (default: false)
  37196. */
  37197. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37198. /**
  37199. * Disposes the component and the associated ressources.
  37200. */
  37201. dispose(): void;
  37202. /**
  37203. * Disables audio in the associated scene.
  37204. */
  37205. disableAudio(): void;
  37206. /**
  37207. * Enables audio in the associated scene.
  37208. */
  37209. enableAudio(): void;
  37210. /**
  37211. * Switch audio to headphone output.
  37212. */
  37213. switchAudioModeForHeadphones(): void;
  37214. /**
  37215. * Switch audio to normal speakers.
  37216. */
  37217. switchAudioModeForNormalSpeakers(): void;
  37218. private _cachedCameraDirection;
  37219. private _cachedCameraPosition;
  37220. private _lastCheck;
  37221. private _afterRender;
  37222. }
  37223. }
  37224. declare module BABYLON {
  37225. /**
  37226. * Wraps one or more Sound objects and selects one with random weight for playback.
  37227. */
  37228. export class WeightedSound {
  37229. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37230. loop: boolean;
  37231. private _coneInnerAngle;
  37232. private _coneOuterAngle;
  37233. private _volume;
  37234. /** A Sound is currently playing. */
  37235. isPlaying: boolean;
  37236. /** A Sound is currently paused. */
  37237. isPaused: boolean;
  37238. private _sounds;
  37239. private _weights;
  37240. private _currentIndex?;
  37241. /**
  37242. * Creates a new WeightedSound from the list of sounds given.
  37243. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37244. * @param sounds Array of Sounds that will be selected from.
  37245. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37246. */
  37247. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37248. /**
  37249. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37250. */
  37251. /**
  37252. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37253. */
  37254. directionalConeInnerAngle: number;
  37255. /**
  37256. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37257. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37258. */
  37259. /**
  37260. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37261. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37262. */
  37263. directionalConeOuterAngle: number;
  37264. /**
  37265. * Playback volume.
  37266. */
  37267. /**
  37268. * Playback volume.
  37269. */
  37270. volume: number;
  37271. private _onended;
  37272. /**
  37273. * Suspend playback
  37274. */
  37275. pause(): void;
  37276. /**
  37277. * Stop playback
  37278. */
  37279. stop(): void;
  37280. /**
  37281. * Start playback.
  37282. * @param startOffset Position the clip head at a specific time in seconds.
  37283. */
  37284. play(startOffset?: number): void;
  37285. }
  37286. }
  37287. declare module BABYLON {
  37288. /**
  37289. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37291. */
  37292. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37293. /**
  37294. * Gets the name of the behavior.
  37295. */
  37296. readonly name: string;
  37297. /**
  37298. * The easing function used by animations
  37299. */
  37300. static EasingFunction: BackEase;
  37301. /**
  37302. * The easing mode used by animations
  37303. */
  37304. static EasingMode: number;
  37305. /**
  37306. * The duration of the animation, in milliseconds
  37307. */
  37308. transitionDuration: number;
  37309. /**
  37310. * Length of the distance animated by the transition when lower radius is reached
  37311. */
  37312. lowerRadiusTransitionRange: number;
  37313. /**
  37314. * Length of the distance animated by the transition when upper radius is reached
  37315. */
  37316. upperRadiusTransitionRange: number;
  37317. private _autoTransitionRange;
  37318. /**
  37319. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37320. */
  37321. /**
  37322. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37323. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37324. */
  37325. autoTransitionRange: boolean;
  37326. private _attachedCamera;
  37327. private _onAfterCheckInputsObserver;
  37328. private _onMeshTargetChangedObserver;
  37329. /**
  37330. * Initializes the behavior.
  37331. */
  37332. init(): void;
  37333. /**
  37334. * Attaches the behavior to its arc rotate camera.
  37335. * @param camera Defines the camera to attach the behavior to
  37336. */
  37337. attach(camera: ArcRotateCamera): void;
  37338. /**
  37339. * Detaches the behavior from its current arc rotate camera.
  37340. */
  37341. detach(): void;
  37342. private _radiusIsAnimating;
  37343. private _radiusBounceTransition;
  37344. private _animatables;
  37345. private _cachedWheelPrecision;
  37346. /**
  37347. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37348. * @param radiusLimit The limit to check against.
  37349. * @return Bool to indicate if at limit.
  37350. */
  37351. private _isRadiusAtLimit;
  37352. /**
  37353. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37354. * @param radiusDelta The delta by which to animate to. Can be negative.
  37355. */
  37356. private _applyBoundRadiusAnimation;
  37357. /**
  37358. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37359. */
  37360. protected _clearAnimationLocks(): void;
  37361. /**
  37362. * Stops and removes all animations that have been applied to the camera
  37363. */
  37364. stopAllAnimations(): void;
  37365. }
  37366. }
  37367. declare module BABYLON {
  37368. /**
  37369. * 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.
  37370. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37371. */
  37372. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37373. /**
  37374. * Gets the name of the behavior.
  37375. */
  37376. readonly name: string;
  37377. private _mode;
  37378. private _radiusScale;
  37379. private _positionScale;
  37380. private _defaultElevation;
  37381. private _elevationReturnTime;
  37382. private _elevationReturnWaitTime;
  37383. private _zoomStopsAnimation;
  37384. private _framingTime;
  37385. /**
  37386. * The easing function used by animations
  37387. */
  37388. static EasingFunction: ExponentialEase;
  37389. /**
  37390. * The easing mode used by animations
  37391. */
  37392. static EasingMode: number;
  37393. /**
  37394. * Sets the current mode used by the behavior
  37395. */
  37396. /**
  37397. * Gets current mode used by the behavior.
  37398. */
  37399. mode: number;
  37400. /**
  37401. * Sets the scale applied to the radius (1 by default)
  37402. */
  37403. /**
  37404. * Gets the scale applied to the radius
  37405. */
  37406. radiusScale: number;
  37407. /**
  37408. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37409. */
  37410. /**
  37411. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37412. */
  37413. positionScale: number;
  37414. /**
  37415. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37416. * behaviour is triggered, in radians.
  37417. */
  37418. /**
  37419. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37420. * behaviour is triggered, in radians.
  37421. */
  37422. defaultElevation: number;
  37423. /**
  37424. * Sets the time (in milliseconds) taken to return to the default beta position.
  37425. * Negative value indicates camera should not return to default.
  37426. */
  37427. /**
  37428. * Gets the time (in milliseconds) taken to return to the default beta position.
  37429. * Negative value indicates camera should not return to default.
  37430. */
  37431. elevationReturnTime: number;
  37432. /**
  37433. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37434. */
  37435. /**
  37436. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37437. */
  37438. elevationReturnWaitTime: number;
  37439. /**
  37440. * Sets the flag that indicates if user zooming should stop animation.
  37441. */
  37442. /**
  37443. * Gets the flag that indicates if user zooming should stop animation.
  37444. */
  37445. zoomStopsAnimation: boolean;
  37446. /**
  37447. * Sets the transition time when framing the mesh, in milliseconds
  37448. */
  37449. /**
  37450. * Gets the transition time when framing the mesh, in milliseconds
  37451. */
  37452. framingTime: number;
  37453. /**
  37454. * Define if the behavior should automatically change the configured
  37455. * camera limits and sensibilities.
  37456. */
  37457. autoCorrectCameraLimitsAndSensibility: boolean;
  37458. private _onPrePointerObservableObserver;
  37459. private _onAfterCheckInputsObserver;
  37460. private _onMeshTargetChangedObserver;
  37461. private _attachedCamera;
  37462. private _isPointerDown;
  37463. private _lastInteractionTime;
  37464. /**
  37465. * Initializes the behavior.
  37466. */
  37467. init(): void;
  37468. /**
  37469. * Attaches the behavior to its arc rotate camera.
  37470. * @param camera Defines the camera to attach the behavior to
  37471. */
  37472. attach(camera: ArcRotateCamera): void;
  37473. /**
  37474. * Detaches the behavior from its current arc rotate camera.
  37475. */
  37476. detach(): void;
  37477. private _animatables;
  37478. private _betaIsAnimating;
  37479. private _betaTransition;
  37480. private _radiusTransition;
  37481. private _vectorTransition;
  37482. /**
  37483. * Targets the given mesh and updates zoom level accordingly.
  37484. * @param mesh The mesh to target.
  37485. * @param radius Optional. If a cached radius position already exists, overrides default.
  37486. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37487. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37488. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37489. */
  37490. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37491. /**
  37492. * Targets the given mesh with its children and updates zoom level accordingly.
  37493. * @param mesh The mesh to target.
  37494. * @param radius Optional. If a cached radius position already exists, overrides default.
  37495. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37496. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37497. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37498. */
  37499. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37500. /**
  37501. * Targets the given meshes with their children and updates zoom level accordingly.
  37502. * @param meshes The mesh to target.
  37503. * @param radius Optional. If a cached radius position already exists, overrides default.
  37504. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37505. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37506. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37507. */
  37508. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37509. /**
  37510. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37511. * @param minimumWorld Determines the smaller position of the bounding box extend
  37512. * @param maximumWorld Determines the bigger position of the bounding box extend
  37513. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37514. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37515. */
  37516. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37517. /**
  37518. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37519. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37520. * frustum width.
  37521. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37522. * to fully enclose the mesh in the viewing frustum.
  37523. */
  37524. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37525. /**
  37526. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37527. * is automatically returned to its default position (expected to be above ground plane).
  37528. */
  37529. private _maintainCameraAboveGround;
  37530. /**
  37531. * Returns the frustum slope based on the canvas ratio and camera FOV
  37532. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37533. */
  37534. private _getFrustumSlope;
  37535. /**
  37536. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37537. */
  37538. private _clearAnimationLocks;
  37539. /**
  37540. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37541. */
  37542. private _applyUserInteraction;
  37543. /**
  37544. * Stops and removes all animations that have been applied to the camera
  37545. */
  37546. stopAllAnimations(): void;
  37547. /**
  37548. * Gets a value indicating if the user is moving the camera
  37549. */
  37550. readonly isUserIsMoving: boolean;
  37551. /**
  37552. * The camera can move all the way towards the mesh.
  37553. */
  37554. static IgnoreBoundsSizeMode: number;
  37555. /**
  37556. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37557. */
  37558. static FitFrustumSidesMode: number;
  37559. }
  37560. }
  37561. declare module BABYLON {
  37562. /**
  37563. * Base class for Camera Pointer Inputs.
  37564. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37565. * for example usage.
  37566. */
  37567. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37568. /**
  37569. * Defines the camera the input is attached to.
  37570. */
  37571. abstract camera: Camera;
  37572. /**
  37573. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37574. */
  37575. protected _altKey: boolean;
  37576. protected _ctrlKey: boolean;
  37577. protected _metaKey: boolean;
  37578. protected _shiftKey: boolean;
  37579. /**
  37580. * Which mouse buttons were pressed at time of last mouse event.
  37581. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37582. */
  37583. protected _buttonsPressed: number;
  37584. /**
  37585. * Defines the buttons associated with the input to handle camera move.
  37586. */
  37587. buttons: number[];
  37588. /**
  37589. * Attach the input controls to a specific dom element to get the input from.
  37590. * @param element Defines the element the controls should be listened from
  37591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37592. */
  37593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37594. /**
  37595. * Detach the current controls from the specified dom element.
  37596. * @param element Defines the element to stop listening the inputs from
  37597. */
  37598. detachControl(element: Nullable<HTMLElement>): void;
  37599. /**
  37600. * Gets the class name of the current input.
  37601. * @returns the class name
  37602. */
  37603. getClassName(): string;
  37604. /**
  37605. * Get the friendly name associated with the input class.
  37606. * @returns the input friendly name
  37607. */
  37608. getSimpleName(): string;
  37609. /**
  37610. * Called on pointer POINTERDOUBLETAP event.
  37611. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37612. */
  37613. protected onDoubleTap(type: string): void;
  37614. /**
  37615. * Called on pointer POINTERMOVE event if only a single touch is active.
  37616. * Override this method to provide functionality.
  37617. */
  37618. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37619. /**
  37620. * Called on pointer POINTERMOVE event if multiple touches are active.
  37621. * Override this method to provide functionality.
  37622. */
  37623. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37624. /**
  37625. * Called on JS contextmenu event.
  37626. * Override this method to provide functionality.
  37627. */
  37628. protected onContextMenu(evt: PointerEvent): void;
  37629. /**
  37630. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37631. * press.
  37632. * Override this method to provide functionality.
  37633. */
  37634. protected onButtonDown(evt: PointerEvent): void;
  37635. /**
  37636. * Called each time a new POINTERUP event occurs. Ie, for each button
  37637. * release.
  37638. * Override this method to provide functionality.
  37639. */
  37640. protected onButtonUp(evt: PointerEvent): void;
  37641. /**
  37642. * Called when window becomes inactive.
  37643. * Override this method to provide functionality.
  37644. */
  37645. protected onLostFocus(): void;
  37646. private _pointerInput;
  37647. private _observer;
  37648. private _onLostFocus;
  37649. private pointA;
  37650. private pointB;
  37651. }
  37652. }
  37653. declare module BABYLON {
  37654. /**
  37655. * Manage the pointers inputs to control an arc rotate camera.
  37656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37657. */
  37658. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37659. /**
  37660. * Defines the camera the input is attached to.
  37661. */
  37662. camera: ArcRotateCamera;
  37663. /**
  37664. * Gets the class name of the current input.
  37665. * @returns the class name
  37666. */
  37667. getClassName(): string;
  37668. /**
  37669. * Defines the buttons associated with the input to handle camera move.
  37670. */
  37671. buttons: number[];
  37672. /**
  37673. * Defines the pointer angular sensibility along the X axis or how fast is
  37674. * the camera rotating.
  37675. */
  37676. angularSensibilityX: number;
  37677. /**
  37678. * Defines the pointer angular sensibility along the Y axis or how fast is
  37679. * the camera rotating.
  37680. */
  37681. angularSensibilityY: number;
  37682. /**
  37683. * Defines the pointer pinch precision or how fast is the camera zooming.
  37684. */
  37685. pinchPrecision: number;
  37686. /**
  37687. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37688. * from 0.
  37689. * It defines the percentage of current camera.radius to use as delta when
  37690. * pinch zoom is used.
  37691. */
  37692. pinchDeltaPercentage: number;
  37693. /**
  37694. * Defines the pointer panning sensibility or how fast is the camera moving.
  37695. */
  37696. panningSensibility: number;
  37697. /**
  37698. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37699. */
  37700. multiTouchPanning: boolean;
  37701. /**
  37702. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37703. * zoom (pinch) through multitouch.
  37704. */
  37705. multiTouchPanAndZoom: boolean;
  37706. /**
  37707. * Revers pinch action direction.
  37708. */
  37709. pinchInwards: boolean;
  37710. private _isPanClick;
  37711. private _twoFingerActivityCount;
  37712. private _isPinching;
  37713. /**
  37714. * Called on pointer POINTERMOVE event if only a single touch is active.
  37715. */
  37716. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37717. /**
  37718. * Called on pointer POINTERDOUBLETAP event.
  37719. */
  37720. protected onDoubleTap(type: string): void;
  37721. /**
  37722. * Called on pointer POINTERMOVE event if multiple touches are active.
  37723. */
  37724. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37725. /**
  37726. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37727. * press.
  37728. */
  37729. protected onButtonDown(evt: PointerEvent): void;
  37730. /**
  37731. * Called each time a new POINTERUP event occurs. Ie, for each button
  37732. * release.
  37733. */
  37734. protected onButtonUp(evt: PointerEvent): void;
  37735. /**
  37736. * Called when window becomes inactive.
  37737. */
  37738. protected onLostFocus(): void;
  37739. }
  37740. }
  37741. declare module BABYLON {
  37742. /**
  37743. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37744. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37745. */
  37746. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37747. /**
  37748. * Defines the camera the input is attached to.
  37749. */
  37750. camera: ArcRotateCamera;
  37751. /**
  37752. * Defines the list of key codes associated with the up action (increase alpha)
  37753. */
  37754. keysUp: number[];
  37755. /**
  37756. * Defines the list of key codes associated with the down action (decrease alpha)
  37757. */
  37758. keysDown: number[];
  37759. /**
  37760. * Defines the list of key codes associated with the left action (increase beta)
  37761. */
  37762. keysLeft: number[];
  37763. /**
  37764. * Defines the list of key codes associated with the right action (decrease beta)
  37765. */
  37766. keysRight: number[];
  37767. /**
  37768. * Defines the list of key codes associated with the reset action.
  37769. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37770. */
  37771. keysReset: number[];
  37772. /**
  37773. * Defines the panning sensibility of the inputs.
  37774. * (How fast is the camera paning)
  37775. */
  37776. panningSensibility: number;
  37777. /**
  37778. * Defines the zooming sensibility of the inputs.
  37779. * (How fast is the camera zooming)
  37780. */
  37781. zoomingSensibility: number;
  37782. /**
  37783. * Defines wether maintaining the alt key down switch the movement mode from
  37784. * orientation to zoom.
  37785. */
  37786. useAltToZoom: boolean;
  37787. /**
  37788. * Rotation speed of the camera
  37789. */
  37790. angularSpeed: number;
  37791. private _keys;
  37792. private _ctrlPressed;
  37793. private _altPressed;
  37794. private _onCanvasBlurObserver;
  37795. private _onKeyboardObserver;
  37796. private _engine;
  37797. private _scene;
  37798. /**
  37799. * Attach the input controls to a specific dom element to get the input from.
  37800. * @param element Defines the element the controls should be listened from
  37801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37802. */
  37803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37804. /**
  37805. * Detach the current controls from the specified dom element.
  37806. * @param element Defines the element to stop listening the inputs from
  37807. */
  37808. detachControl(element: Nullable<HTMLElement>): void;
  37809. /**
  37810. * Update the current camera state depending on the inputs that have been used this frame.
  37811. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37812. */
  37813. checkInputs(): void;
  37814. /**
  37815. * Gets the class name of the current intput.
  37816. * @returns the class name
  37817. */
  37818. getClassName(): string;
  37819. /**
  37820. * Get the friendly name associated with the input class.
  37821. * @returns the input friendly name
  37822. */
  37823. getSimpleName(): string;
  37824. }
  37825. }
  37826. declare module BABYLON {
  37827. /**
  37828. * Manage the mouse wheel inputs to control an arc rotate camera.
  37829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37830. */
  37831. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37832. /**
  37833. * Defines the camera the input is attached to.
  37834. */
  37835. camera: ArcRotateCamera;
  37836. /**
  37837. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37838. */
  37839. wheelPrecision: number;
  37840. /**
  37841. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37842. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37843. */
  37844. wheelDeltaPercentage: number;
  37845. private _wheel;
  37846. private _observer;
  37847. private computeDeltaFromMouseWheelLegacyEvent;
  37848. /**
  37849. * Attach the input controls to a specific dom element to get the input from.
  37850. * @param element Defines the element the controls should be listened from
  37851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37852. */
  37853. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37854. /**
  37855. * Detach the current controls from the specified dom element.
  37856. * @param element Defines the element to stop listening the inputs from
  37857. */
  37858. detachControl(element: Nullable<HTMLElement>): void;
  37859. /**
  37860. * Gets the class name of the current intput.
  37861. * @returns the class name
  37862. */
  37863. getClassName(): string;
  37864. /**
  37865. * Get the friendly name associated with the input class.
  37866. * @returns the input friendly name
  37867. */
  37868. getSimpleName(): string;
  37869. }
  37870. }
  37871. declare module BABYLON {
  37872. /**
  37873. * Default Inputs manager for the ArcRotateCamera.
  37874. * It groups all the default supported inputs for ease of use.
  37875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37876. */
  37877. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37878. /**
  37879. * Instantiates a new ArcRotateCameraInputsManager.
  37880. * @param camera Defines the camera the inputs belong to
  37881. */
  37882. constructor(camera: ArcRotateCamera);
  37883. /**
  37884. * Add mouse wheel input support to the input manager.
  37885. * @returns the current input manager
  37886. */
  37887. addMouseWheel(): ArcRotateCameraInputsManager;
  37888. /**
  37889. * Add pointers input support to the input manager.
  37890. * @returns the current input manager
  37891. */
  37892. addPointers(): ArcRotateCameraInputsManager;
  37893. /**
  37894. * Add keyboard input support to the input manager.
  37895. * @returns the current input manager
  37896. */
  37897. addKeyboard(): ArcRotateCameraInputsManager;
  37898. }
  37899. }
  37900. declare module BABYLON {
  37901. /**
  37902. * This represents an orbital type of camera.
  37903. *
  37904. * 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.
  37905. * 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.
  37906. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37907. */
  37908. export class ArcRotateCamera extends TargetCamera {
  37909. /**
  37910. * Defines the rotation angle of the camera along the longitudinal axis.
  37911. */
  37912. alpha: number;
  37913. /**
  37914. * Defines the rotation angle of the camera along the latitudinal axis.
  37915. */
  37916. beta: number;
  37917. /**
  37918. * Defines the radius of the camera from it s target point.
  37919. */
  37920. radius: number;
  37921. protected _target: Vector3;
  37922. protected _targetHost: Nullable<AbstractMesh>;
  37923. /**
  37924. * Defines the target point of the camera.
  37925. * The camera looks towards it form the radius distance.
  37926. */
  37927. target: Vector3;
  37928. /**
  37929. * Define the current local position of the camera in the scene
  37930. */
  37931. position: Vector3;
  37932. protected _upVector: Vector3;
  37933. protected _upToYMatrix: Matrix;
  37934. protected _YToUpMatrix: Matrix;
  37935. /**
  37936. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37937. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37938. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37939. */
  37940. upVector: Vector3;
  37941. /**
  37942. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37943. */
  37944. setMatUp(): void;
  37945. /**
  37946. * Current inertia value on the longitudinal axis.
  37947. * The bigger this number the longer it will take for the camera to stop.
  37948. */
  37949. inertialAlphaOffset: number;
  37950. /**
  37951. * Current inertia value on the latitudinal axis.
  37952. * The bigger this number the longer it will take for the camera to stop.
  37953. */
  37954. inertialBetaOffset: number;
  37955. /**
  37956. * Current inertia value on the radius axis.
  37957. * The bigger this number the longer it will take for the camera to stop.
  37958. */
  37959. inertialRadiusOffset: number;
  37960. /**
  37961. * Minimum allowed angle on the longitudinal axis.
  37962. * This can help limiting how the Camera is able to move in the scene.
  37963. */
  37964. lowerAlphaLimit: Nullable<number>;
  37965. /**
  37966. * Maximum allowed angle on the longitudinal axis.
  37967. * This can help limiting how the Camera is able to move in the scene.
  37968. */
  37969. upperAlphaLimit: Nullable<number>;
  37970. /**
  37971. * Minimum allowed angle on the latitudinal axis.
  37972. * This can help limiting how the Camera is able to move in the scene.
  37973. */
  37974. lowerBetaLimit: number;
  37975. /**
  37976. * Maximum allowed angle on the latitudinal axis.
  37977. * This can help limiting how the Camera is able to move in the scene.
  37978. */
  37979. upperBetaLimit: number;
  37980. /**
  37981. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37982. * This can help limiting how the Camera is able to move in the scene.
  37983. */
  37984. lowerRadiusLimit: Nullable<number>;
  37985. /**
  37986. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37987. * This can help limiting how the Camera is able to move in the scene.
  37988. */
  37989. upperRadiusLimit: Nullable<number>;
  37990. /**
  37991. * Defines the current inertia value used during panning of the camera along the X axis.
  37992. */
  37993. inertialPanningX: number;
  37994. /**
  37995. * Defines the current inertia value used during panning of the camera along the Y axis.
  37996. */
  37997. inertialPanningY: number;
  37998. /**
  37999. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38000. * Basically if your fingers moves away from more than this distance you will be considered
  38001. * in pinch mode.
  38002. */
  38003. pinchToPanMaxDistance: number;
  38004. /**
  38005. * Defines the maximum distance the camera can pan.
  38006. * This could help keeping the cammera always in your scene.
  38007. */
  38008. panningDistanceLimit: Nullable<number>;
  38009. /**
  38010. * Defines the target of the camera before paning.
  38011. */
  38012. panningOriginTarget: Vector3;
  38013. /**
  38014. * Defines the value of the inertia used during panning.
  38015. * 0 would mean stop inertia and one would mean no decelleration at all.
  38016. */
  38017. panningInertia: number;
  38018. /**
  38019. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38020. */
  38021. angularSensibilityX: number;
  38022. /**
  38023. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38024. */
  38025. angularSensibilityY: number;
  38026. /**
  38027. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38028. */
  38029. pinchPrecision: number;
  38030. /**
  38031. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38032. * It will be used instead of pinchDeltaPrecision if different from 0.
  38033. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38034. */
  38035. pinchDeltaPercentage: number;
  38036. /**
  38037. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38038. */
  38039. panningSensibility: number;
  38040. /**
  38041. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38042. */
  38043. keysUp: number[];
  38044. /**
  38045. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38046. */
  38047. keysDown: number[];
  38048. /**
  38049. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38050. */
  38051. keysLeft: number[];
  38052. /**
  38053. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38054. */
  38055. keysRight: number[];
  38056. /**
  38057. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38058. */
  38059. wheelPrecision: number;
  38060. /**
  38061. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38062. * It will be used instead of pinchDeltaPrecision if different from 0.
  38063. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38064. */
  38065. wheelDeltaPercentage: number;
  38066. /**
  38067. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38068. */
  38069. zoomOnFactor: number;
  38070. /**
  38071. * Defines a screen offset for the camera position.
  38072. */
  38073. targetScreenOffset: Vector2;
  38074. /**
  38075. * Allows the camera to be completely reversed.
  38076. * If false the camera can not arrive upside down.
  38077. */
  38078. allowUpsideDown: boolean;
  38079. /**
  38080. * Define if double tap/click is used to restore the previously saved state of the camera.
  38081. */
  38082. useInputToRestoreState: boolean;
  38083. /** @hidden */
  38084. _viewMatrix: Matrix;
  38085. /** @hidden */
  38086. _useCtrlForPanning: boolean;
  38087. /** @hidden */
  38088. _panningMouseButton: number;
  38089. /**
  38090. * Defines the input associated to the camera.
  38091. */
  38092. inputs: ArcRotateCameraInputsManager;
  38093. /** @hidden */
  38094. _reset: () => void;
  38095. /**
  38096. * Defines the allowed panning axis.
  38097. */
  38098. panningAxis: Vector3;
  38099. protected _localDirection: Vector3;
  38100. protected _transformedDirection: Vector3;
  38101. private _bouncingBehavior;
  38102. /**
  38103. * Gets the bouncing behavior of the camera if it has been enabled.
  38104. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38105. */
  38106. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38107. /**
  38108. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38109. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38110. */
  38111. useBouncingBehavior: boolean;
  38112. private _framingBehavior;
  38113. /**
  38114. * Gets the framing behavior of the camera if it has been enabled.
  38115. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38116. */
  38117. readonly framingBehavior: Nullable<FramingBehavior>;
  38118. /**
  38119. * Defines if the framing behavior of the camera is enabled on the camera.
  38120. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38121. */
  38122. useFramingBehavior: boolean;
  38123. private _autoRotationBehavior;
  38124. /**
  38125. * Gets the auto rotation behavior of the camera if it has been enabled.
  38126. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38127. */
  38128. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38129. /**
  38130. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38131. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38132. */
  38133. useAutoRotationBehavior: boolean;
  38134. /**
  38135. * Observable triggered when the mesh target has been changed on the camera.
  38136. */
  38137. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38138. /**
  38139. * Event raised when the camera is colliding with a mesh.
  38140. */
  38141. onCollide: (collidedMesh: AbstractMesh) => void;
  38142. /**
  38143. * Defines whether the camera should check collision with the objects oh the scene.
  38144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38145. */
  38146. checkCollisions: boolean;
  38147. /**
  38148. * Defines the collision radius of the camera.
  38149. * This simulates a sphere around the camera.
  38150. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38151. */
  38152. collisionRadius: Vector3;
  38153. protected _collider: Collider;
  38154. protected _previousPosition: Vector3;
  38155. protected _collisionVelocity: Vector3;
  38156. protected _newPosition: Vector3;
  38157. protected _previousAlpha: number;
  38158. protected _previousBeta: number;
  38159. protected _previousRadius: number;
  38160. protected _collisionTriggered: boolean;
  38161. protected _targetBoundingCenter: Nullable<Vector3>;
  38162. private _computationVector;
  38163. /**
  38164. * Instantiates a new ArcRotateCamera in a given scene
  38165. * @param name Defines the name of the camera
  38166. * @param alpha Defines the camera rotation along the logitudinal axis
  38167. * @param beta Defines the camera rotation along the latitudinal axis
  38168. * @param radius Defines the camera distance from its target
  38169. * @param target Defines the camera target
  38170. * @param scene Defines the scene the camera belongs to
  38171. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38172. */
  38173. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38174. /** @hidden */
  38175. _initCache(): void;
  38176. /** @hidden */
  38177. _updateCache(ignoreParentClass?: boolean): void;
  38178. protected _getTargetPosition(): Vector3;
  38179. private _storedAlpha;
  38180. private _storedBeta;
  38181. private _storedRadius;
  38182. private _storedTarget;
  38183. private _storedTargetScreenOffset;
  38184. /**
  38185. * Stores the current state of the camera (alpha, beta, radius and target)
  38186. * @returns the camera itself
  38187. */
  38188. storeState(): Camera;
  38189. /**
  38190. * @hidden
  38191. * Restored camera state. You must call storeState() first
  38192. */
  38193. _restoreStateValues(): boolean;
  38194. /** @hidden */
  38195. _isSynchronizedViewMatrix(): boolean;
  38196. /**
  38197. * Attached controls to the current camera.
  38198. * @param element Defines the element the controls should be listened from
  38199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38200. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38201. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38202. */
  38203. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38204. /**
  38205. * Detach the current controls from the camera.
  38206. * The camera will stop reacting to inputs.
  38207. * @param element Defines the element to stop listening the inputs from
  38208. */
  38209. detachControl(element: HTMLElement): void;
  38210. /** @hidden */
  38211. _checkInputs(): void;
  38212. protected _checkLimits(): void;
  38213. /**
  38214. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38215. */
  38216. rebuildAnglesAndRadius(): void;
  38217. /**
  38218. * Use a position to define the current camera related information like alpha, beta and radius
  38219. * @param position Defines the position to set the camera at
  38220. */
  38221. setPosition(position: Vector3): void;
  38222. /**
  38223. * Defines the target the camera should look at.
  38224. * This will automatically adapt alpha beta and radius to fit within the new target.
  38225. * @param target Defines the new target as a Vector or a mesh
  38226. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38227. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38228. */
  38229. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38230. /** @hidden */
  38231. _getViewMatrix(): Matrix;
  38232. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38233. /**
  38234. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38235. * @param meshes Defines the mesh to zoom on
  38236. * @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)
  38237. */
  38238. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38239. /**
  38240. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38241. * The target will be changed but the radius
  38242. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38243. * @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)
  38244. */
  38245. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38246. min: Vector3;
  38247. max: Vector3;
  38248. distance: number;
  38249. }, doNotUpdateMaxZ?: boolean): void;
  38250. /**
  38251. * @override
  38252. * Override Camera.createRigCamera
  38253. */
  38254. createRigCamera(name: string, cameraIndex: number): Camera;
  38255. /**
  38256. * @hidden
  38257. * @override
  38258. * Override Camera._updateRigCameras
  38259. */
  38260. _updateRigCameras(): void;
  38261. /**
  38262. * Destroy the camera and release the current resources hold by it.
  38263. */
  38264. dispose(): void;
  38265. /**
  38266. * Gets the current object class name.
  38267. * @return the class name
  38268. */
  38269. getClassName(): string;
  38270. }
  38271. }
  38272. declare module BABYLON {
  38273. /**
  38274. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38275. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38276. */
  38277. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38278. /**
  38279. * Gets the name of the behavior.
  38280. */
  38281. readonly name: string;
  38282. private _zoomStopsAnimation;
  38283. private _idleRotationSpeed;
  38284. private _idleRotationWaitTime;
  38285. private _idleRotationSpinupTime;
  38286. /**
  38287. * Sets the flag that indicates if user zooming should stop animation.
  38288. */
  38289. /**
  38290. * Gets the flag that indicates if user zooming should stop animation.
  38291. */
  38292. zoomStopsAnimation: boolean;
  38293. /**
  38294. * Sets the default speed at which the camera rotates around the model.
  38295. */
  38296. /**
  38297. * Gets the default speed at which the camera rotates around the model.
  38298. */
  38299. idleRotationSpeed: number;
  38300. /**
  38301. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38302. */
  38303. /**
  38304. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38305. */
  38306. idleRotationWaitTime: number;
  38307. /**
  38308. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38309. */
  38310. /**
  38311. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38312. */
  38313. idleRotationSpinupTime: number;
  38314. /**
  38315. * Gets a value indicating if the camera is currently rotating because of this behavior
  38316. */
  38317. readonly rotationInProgress: boolean;
  38318. private _onPrePointerObservableObserver;
  38319. private _onAfterCheckInputsObserver;
  38320. private _attachedCamera;
  38321. private _isPointerDown;
  38322. private _lastFrameTime;
  38323. private _lastInteractionTime;
  38324. private _cameraRotationSpeed;
  38325. /**
  38326. * Initializes the behavior.
  38327. */
  38328. init(): void;
  38329. /**
  38330. * Attaches the behavior to its arc rotate camera.
  38331. * @param camera Defines the camera to attach the behavior to
  38332. */
  38333. attach(camera: ArcRotateCamera): void;
  38334. /**
  38335. * Detaches the behavior from its current arc rotate camera.
  38336. */
  38337. detach(): void;
  38338. /**
  38339. * Returns true if user is scrolling.
  38340. * @return true if user is scrolling.
  38341. */
  38342. private _userIsZooming;
  38343. private _lastFrameRadius;
  38344. private _shouldAnimationStopForInteraction;
  38345. /**
  38346. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38347. */
  38348. private _applyUserInteraction;
  38349. private _userIsMoving;
  38350. }
  38351. }
  38352. declare module BABYLON {
  38353. /**
  38354. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38355. */
  38356. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38357. private ui;
  38358. /**
  38359. * The name of the behavior
  38360. */
  38361. name: string;
  38362. /**
  38363. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38364. */
  38365. distanceAwayFromFace: number;
  38366. /**
  38367. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38368. */
  38369. distanceAwayFromBottomOfFace: number;
  38370. private _faceVectors;
  38371. private _target;
  38372. private _scene;
  38373. private _onRenderObserver;
  38374. private _tmpMatrix;
  38375. private _tmpVector;
  38376. /**
  38377. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38378. * @param ui The transform node that should be attched to the mesh
  38379. */
  38380. constructor(ui: TransformNode);
  38381. /**
  38382. * Initializes the behavior
  38383. */
  38384. init(): void;
  38385. private _closestFace;
  38386. private _zeroVector;
  38387. private _lookAtTmpMatrix;
  38388. private _lookAtToRef;
  38389. /**
  38390. * Attaches the AttachToBoxBehavior to the passed in mesh
  38391. * @param target The mesh that the specified node will be attached to
  38392. */
  38393. attach(target: Mesh): void;
  38394. /**
  38395. * Detaches the behavior from the mesh
  38396. */
  38397. detach(): void;
  38398. }
  38399. }
  38400. declare module BABYLON {
  38401. /**
  38402. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38403. */
  38404. export class FadeInOutBehavior implements Behavior<Mesh> {
  38405. /**
  38406. * Time in milliseconds to delay before fading in (Default: 0)
  38407. */
  38408. delay: number;
  38409. /**
  38410. * Time in milliseconds for the mesh to fade in (Default: 300)
  38411. */
  38412. fadeInTime: number;
  38413. private _millisecondsPerFrame;
  38414. private _hovered;
  38415. private _hoverValue;
  38416. private _ownerNode;
  38417. /**
  38418. * Instatiates the FadeInOutBehavior
  38419. */
  38420. constructor();
  38421. /**
  38422. * The name of the behavior
  38423. */
  38424. readonly name: string;
  38425. /**
  38426. * Initializes the behavior
  38427. */
  38428. init(): void;
  38429. /**
  38430. * Attaches the fade behavior on the passed in mesh
  38431. * @param ownerNode The mesh that will be faded in/out once attached
  38432. */
  38433. attach(ownerNode: Mesh): void;
  38434. /**
  38435. * Detaches the behavior from the mesh
  38436. */
  38437. detach(): void;
  38438. /**
  38439. * Triggers the mesh to begin fading in or out
  38440. * @param value if the object should fade in or out (true to fade in)
  38441. */
  38442. fadeIn(value: boolean): void;
  38443. private _update;
  38444. private _setAllVisibility;
  38445. }
  38446. }
  38447. declare module BABYLON {
  38448. /**
  38449. * Class containing a set of static utilities functions for managing Pivots
  38450. * @hidden
  38451. */
  38452. export class PivotTools {
  38453. private static _PivotCached;
  38454. private static _OldPivotPoint;
  38455. private static _PivotTranslation;
  38456. private static _PivotTmpVector;
  38457. /** @hidden */
  38458. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38459. /** @hidden */
  38460. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38461. }
  38462. }
  38463. declare module BABYLON {
  38464. /**
  38465. * Class containing static functions to help procedurally build meshes
  38466. */
  38467. export class PlaneBuilder {
  38468. /**
  38469. * Creates a plane mesh
  38470. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38471. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38472. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38474. * * 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
  38475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38476. * @param name defines the name of the mesh
  38477. * @param options defines the options used to create the mesh
  38478. * @param scene defines the hosting scene
  38479. * @returns the plane mesh
  38480. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38481. */
  38482. static CreatePlane(name: string, options: {
  38483. size?: number;
  38484. width?: number;
  38485. height?: number;
  38486. sideOrientation?: number;
  38487. frontUVs?: Vector4;
  38488. backUVs?: Vector4;
  38489. updatable?: boolean;
  38490. sourcePlane?: Plane;
  38491. }, scene?: Nullable<Scene>): Mesh;
  38492. }
  38493. }
  38494. declare module BABYLON {
  38495. /**
  38496. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38497. */
  38498. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38499. private static _AnyMouseID;
  38500. /**
  38501. * Abstract mesh the behavior is set on
  38502. */
  38503. attachedNode: AbstractMesh;
  38504. private _dragPlane;
  38505. private _scene;
  38506. private _pointerObserver;
  38507. private _beforeRenderObserver;
  38508. private static _planeScene;
  38509. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38510. /**
  38511. * 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)
  38512. */
  38513. maxDragAngle: number;
  38514. /**
  38515. * @hidden
  38516. */
  38517. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38518. /**
  38519. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38520. */
  38521. currentDraggingPointerID: number;
  38522. /**
  38523. * The last position where the pointer hit the drag plane in world space
  38524. */
  38525. lastDragPosition: Vector3;
  38526. /**
  38527. * If the behavior is currently in a dragging state
  38528. */
  38529. dragging: boolean;
  38530. /**
  38531. * 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)
  38532. */
  38533. dragDeltaRatio: number;
  38534. /**
  38535. * If the drag plane orientation should be updated during the dragging (Default: true)
  38536. */
  38537. updateDragPlane: boolean;
  38538. private _debugMode;
  38539. private _moving;
  38540. /**
  38541. * Fires each time the attached mesh is dragged with the pointer
  38542. * * delta between last drag position and current drag position in world space
  38543. * * dragDistance along the drag axis
  38544. * * dragPlaneNormal normal of the current drag plane used during the drag
  38545. * * dragPlanePoint in world space where the drag intersects the drag plane
  38546. */
  38547. onDragObservable: Observable<{
  38548. delta: Vector3;
  38549. dragPlanePoint: Vector3;
  38550. dragPlaneNormal: Vector3;
  38551. dragDistance: number;
  38552. pointerId: number;
  38553. }>;
  38554. /**
  38555. * Fires each time a drag begins (eg. mouse down on mesh)
  38556. */
  38557. onDragStartObservable: Observable<{
  38558. dragPlanePoint: Vector3;
  38559. pointerId: number;
  38560. }>;
  38561. /**
  38562. * Fires each time a drag ends (eg. mouse release after drag)
  38563. */
  38564. onDragEndObservable: Observable<{
  38565. dragPlanePoint: Vector3;
  38566. pointerId: number;
  38567. }>;
  38568. /**
  38569. * If the attached mesh should be moved when dragged
  38570. */
  38571. moveAttached: boolean;
  38572. /**
  38573. * If the drag behavior will react to drag events (Default: true)
  38574. */
  38575. enabled: boolean;
  38576. /**
  38577. * If pointer events should start and release the drag (Default: true)
  38578. */
  38579. startAndReleaseDragOnPointerEvents: boolean;
  38580. /**
  38581. * If camera controls should be detached during the drag
  38582. */
  38583. detachCameraControls: boolean;
  38584. /**
  38585. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38586. */
  38587. useObjectOrienationForDragging: boolean;
  38588. private _options;
  38589. /**
  38590. * Gets the options used by the behavior
  38591. */
  38592. /**
  38593. * Sets the options used by the behavior
  38594. */
  38595. options: {
  38596. dragAxis?: Vector3;
  38597. dragPlaneNormal?: Vector3;
  38598. };
  38599. /**
  38600. * Creates a pointer drag behavior that can be attached to a mesh
  38601. * @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)
  38602. */
  38603. constructor(options?: {
  38604. dragAxis?: Vector3;
  38605. dragPlaneNormal?: Vector3;
  38606. });
  38607. /**
  38608. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38609. */
  38610. validateDrag: (targetPosition: Vector3) => boolean;
  38611. /**
  38612. * The name of the behavior
  38613. */
  38614. readonly name: string;
  38615. /**
  38616. * Initializes the behavior
  38617. */
  38618. init(): void;
  38619. private _tmpVector;
  38620. private _alternatePickedPoint;
  38621. private _worldDragAxis;
  38622. private _targetPosition;
  38623. private _attachedElement;
  38624. /**
  38625. * Attaches the drag behavior the passed in mesh
  38626. * @param ownerNode The mesh that will be dragged around once attached
  38627. * @param predicate Predicate to use for pick filtering
  38628. */
  38629. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38630. /**
  38631. * Force relase the drag action by code.
  38632. */
  38633. releaseDrag(): void;
  38634. private _startDragRay;
  38635. private _lastPointerRay;
  38636. /**
  38637. * Simulates the start of a pointer drag event on the behavior
  38638. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38639. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38640. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38641. */
  38642. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38643. private _startDrag;
  38644. private _dragDelta;
  38645. private _moveDrag;
  38646. private _pickWithRayOnDragPlane;
  38647. private _pointA;
  38648. private _pointB;
  38649. private _pointC;
  38650. private _lineA;
  38651. private _lineB;
  38652. private _localAxis;
  38653. private _lookAt;
  38654. private _updateDragPlanePosition;
  38655. /**
  38656. * Detaches the behavior from the mesh
  38657. */
  38658. detach(): void;
  38659. }
  38660. }
  38661. declare module BABYLON {
  38662. /**
  38663. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38664. */
  38665. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38666. private _dragBehaviorA;
  38667. private _dragBehaviorB;
  38668. private _startDistance;
  38669. private _initialScale;
  38670. private _targetScale;
  38671. private _ownerNode;
  38672. private _sceneRenderObserver;
  38673. /**
  38674. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38675. */
  38676. constructor();
  38677. /**
  38678. * The name of the behavior
  38679. */
  38680. readonly name: string;
  38681. /**
  38682. * Initializes the behavior
  38683. */
  38684. init(): void;
  38685. private _getCurrentDistance;
  38686. /**
  38687. * Attaches the scale behavior the passed in mesh
  38688. * @param ownerNode The mesh that will be scaled around once attached
  38689. */
  38690. attach(ownerNode: Mesh): void;
  38691. /**
  38692. * Detaches the behavior from the mesh
  38693. */
  38694. detach(): void;
  38695. }
  38696. }
  38697. declare module BABYLON {
  38698. /**
  38699. * 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
  38700. */
  38701. export class SixDofDragBehavior implements Behavior<Mesh> {
  38702. private static _virtualScene;
  38703. private _ownerNode;
  38704. private _sceneRenderObserver;
  38705. private _scene;
  38706. private _targetPosition;
  38707. private _virtualOriginMesh;
  38708. private _virtualDragMesh;
  38709. private _pointerObserver;
  38710. private _moving;
  38711. private _startingOrientation;
  38712. /**
  38713. * 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)
  38714. */
  38715. private zDragFactor;
  38716. /**
  38717. * If the object should rotate to face the drag origin
  38718. */
  38719. rotateDraggedObject: boolean;
  38720. /**
  38721. * If the behavior is currently in a dragging state
  38722. */
  38723. dragging: boolean;
  38724. /**
  38725. * 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)
  38726. */
  38727. dragDeltaRatio: number;
  38728. /**
  38729. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38730. */
  38731. currentDraggingPointerID: number;
  38732. /**
  38733. * If camera controls should be detached during the drag
  38734. */
  38735. detachCameraControls: boolean;
  38736. /**
  38737. * Fires each time a drag starts
  38738. */
  38739. onDragStartObservable: Observable<{}>;
  38740. /**
  38741. * Fires each time a drag ends (eg. mouse release after drag)
  38742. */
  38743. onDragEndObservable: Observable<{}>;
  38744. /**
  38745. * 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
  38746. */
  38747. constructor();
  38748. /**
  38749. * The name of the behavior
  38750. */
  38751. readonly name: string;
  38752. /**
  38753. * Initializes the behavior
  38754. */
  38755. init(): void;
  38756. /**
  38757. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38758. */
  38759. private readonly _pointerCamera;
  38760. /**
  38761. * Attaches the scale behavior the passed in mesh
  38762. * @param ownerNode The mesh that will be scaled around once attached
  38763. */
  38764. attach(ownerNode: Mesh): void;
  38765. /**
  38766. * Detaches the behavior from the mesh
  38767. */
  38768. detach(): void;
  38769. }
  38770. }
  38771. declare module BABYLON {
  38772. /**
  38773. * Class used to apply inverse kinematics to bones
  38774. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38775. */
  38776. export class BoneIKController {
  38777. private static _tmpVecs;
  38778. private static _tmpQuat;
  38779. private static _tmpMats;
  38780. /**
  38781. * Gets or sets the target mesh
  38782. */
  38783. targetMesh: AbstractMesh;
  38784. /** Gets or sets the mesh used as pole */
  38785. poleTargetMesh: AbstractMesh;
  38786. /**
  38787. * Gets or sets the bone used as pole
  38788. */
  38789. poleTargetBone: Nullable<Bone>;
  38790. /**
  38791. * Gets or sets the target position
  38792. */
  38793. targetPosition: Vector3;
  38794. /**
  38795. * Gets or sets the pole target position
  38796. */
  38797. poleTargetPosition: Vector3;
  38798. /**
  38799. * Gets or sets the pole target local offset
  38800. */
  38801. poleTargetLocalOffset: Vector3;
  38802. /**
  38803. * Gets or sets the pole angle
  38804. */
  38805. poleAngle: number;
  38806. /**
  38807. * Gets or sets the mesh associated with the controller
  38808. */
  38809. mesh: AbstractMesh;
  38810. /**
  38811. * 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)
  38812. */
  38813. slerpAmount: number;
  38814. private _bone1Quat;
  38815. private _bone1Mat;
  38816. private _bone2Ang;
  38817. private _bone1;
  38818. private _bone2;
  38819. private _bone1Length;
  38820. private _bone2Length;
  38821. private _maxAngle;
  38822. private _maxReach;
  38823. private _rightHandedSystem;
  38824. private _bendAxis;
  38825. private _slerping;
  38826. private _adjustRoll;
  38827. /**
  38828. * Gets or sets maximum allowed angle
  38829. */
  38830. maxAngle: number;
  38831. /**
  38832. * Creates a new BoneIKController
  38833. * @param mesh defines the mesh to control
  38834. * @param bone defines the bone to control
  38835. * @param options defines options to set up the controller
  38836. */
  38837. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38838. targetMesh?: AbstractMesh;
  38839. poleTargetMesh?: AbstractMesh;
  38840. poleTargetBone?: Bone;
  38841. poleTargetLocalOffset?: Vector3;
  38842. poleAngle?: number;
  38843. bendAxis?: Vector3;
  38844. maxAngle?: number;
  38845. slerpAmount?: number;
  38846. });
  38847. private _setMaxAngle;
  38848. /**
  38849. * Force the controller to update the bones
  38850. */
  38851. update(): void;
  38852. }
  38853. }
  38854. declare module BABYLON {
  38855. /**
  38856. * Class used to make a bone look toward a point in space
  38857. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38858. */
  38859. export class BoneLookController {
  38860. private static _tmpVecs;
  38861. private static _tmpQuat;
  38862. private static _tmpMats;
  38863. /**
  38864. * The target Vector3 that the bone will look at
  38865. */
  38866. target: Vector3;
  38867. /**
  38868. * The mesh that the bone is attached to
  38869. */
  38870. mesh: AbstractMesh;
  38871. /**
  38872. * The bone that will be looking to the target
  38873. */
  38874. bone: Bone;
  38875. /**
  38876. * The up axis of the coordinate system that is used when the bone is rotated
  38877. */
  38878. upAxis: Vector3;
  38879. /**
  38880. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38881. */
  38882. upAxisSpace: Space;
  38883. /**
  38884. * Used to make an adjustment to the yaw of the bone
  38885. */
  38886. adjustYaw: number;
  38887. /**
  38888. * Used to make an adjustment to the pitch of the bone
  38889. */
  38890. adjustPitch: number;
  38891. /**
  38892. * Used to make an adjustment to the roll of the bone
  38893. */
  38894. adjustRoll: number;
  38895. /**
  38896. * 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)
  38897. */
  38898. slerpAmount: number;
  38899. private _minYaw;
  38900. private _maxYaw;
  38901. private _minPitch;
  38902. private _maxPitch;
  38903. private _minYawSin;
  38904. private _minYawCos;
  38905. private _maxYawSin;
  38906. private _maxYawCos;
  38907. private _midYawConstraint;
  38908. private _minPitchTan;
  38909. private _maxPitchTan;
  38910. private _boneQuat;
  38911. private _slerping;
  38912. private _transformYawPitch;
  38913. private _transformYawPitchInv;
  38914. private _firstFrameSkipped;
  38915. private _yawRange;
  38916. private _fowardAxis;
  38917. /**
  38918. * Gets or sets the minimum yaw angle that the bone can look to
  38919. */
  38920. minYaw: number;
  38921. /**
  38922. * Gets or sets the maximum yaw angle that the bone can look to
  38923. */
  38924. maxYaw: number;
  38925. /**
  38926. * Gets or sets the minimum pitch angle that the bone can look to
  38927. */
  38928. minPitch: number;
  38929. /**
  38930. * Gets or sets the maximum pitch angle that the bone can look to
  38931. */
  38932. maxPitch: number;
  38933. /**
  38934. * Create a BoneLookController
  38935. * @param mesh the mesh that the bone belongs to
  38936. * @param bone the bone that will be looking to the target
  38937. * @param target the target Vector3 to look at
  38938. * @param options optional settings:
  38939. * * maxYaw: the maximum angle the bone will yaw to
  38940. * * minYaw: the minimum angle the bone will yaw to
  38941. * * maxPitch: the maximum angle the bone will pitch to
  38942. * * minPitch: the minimum angle the bone will yaw to
  38943. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38944. * * upAxis: the up axis of the coordinate system
  38945. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38946. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38947. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38948. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38949. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38950. * * adjustRoll: used to make an adjustment to the roll of the bone
  38951. **/
  38952. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38953. maxYaw?: number;
  38954. minYaw?: number;
  38955. maxPitch?: number;
  38956. minPitch?: number;
  38957. slerpAmount?: number;
  38958. upAxis?: Vector3;
  38959. upAxisSpace?: Space;
  38960. yawAxis?: Vector3;
  38961. pitchAxis?: Vector3;
  38962. adjustYaw?: number;
  38963. adjustPitch?: number;
  38964. adjustRoll?: number;
  38965. });
  38966. /**
  38967. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38968. */
  38969. update(): void;
  38970. private _getAngleDiff;
  38971. private _getAngleBetween;
  38972. private _isAngleBetween;
  38973. }
  38974. }
  38975. declare module BABYLON {
  38976. /**
  38977. * Manage the gamepad inputs to control an arc rotate camera.
  38978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38979. */
  38980. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38981. /**
  38982. * Defines the camera the input is attached to.
  38983. */
  38984. camera: ArcRotateCamera;
  38985. /**
  38986. * Defines the gamepad the input is gathering event from.
  38987. */
  38988. gamepad: Nullable<Gamepad>;
  38989. /**
  38990. * Defines the gamepad rotation sensiblity.
  38991. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38992. */
  38993. gamepadRotationSensibility: number;
  38994. /**
  38995. * Defines the gamepad move sensiblity.
  38996. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38997. */
  38998. gamepadMoveSensibility: number;
  38999. private _yAxisScale;
  39000. /**
  39001. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39002. */
  39003. invertYAxis: boolean;
  39004. private _onGamepadConnectedObserver;
  39005. private _onGamepadDisconnectedObserver;
  39006. /**
  39007. * Attach the input controls to a specific dom element to get the input from.
  39008. * @param element Defines the element the controls should be listened from
  39009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39010. */
  39011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39012. /**
  39013. * Detach the current controls from the specified dom element.
  39014. * @param element Defines the element to stop listening the inputs from
  39015. */
  39016. detachControl(element: Nullable<HTMLElement>): void;
  39017. /**
  39018. * Update the current camera state depending on the inputs that have been used this frame.
  39019. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39020. */
  39021. checkInputs(): void;
  39022. /**
  39023. * Gets the class name of the current intput.
  39024. * @returns the class name
  39025. */
  39026. getClassName(): string;
  39027. /**
  39028. * Get the friendly name associated with the input class.
  39029. * @returns the input friendly name
  39030. */
  39031. getSimpleName(): string;
  39032. }
  39033. }
  39034. declare module BABYLON {
  39035. interface ArcRotateCameraInputsManager {
  39036. /**
  39037. * Add orientation input support to the input manager.
  39038. * @returns the current input manager
  39039. */
  39040. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39041. }
  39042. /**
  39043. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39045. */
  39046. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39047. /**
  39048. * Defines the camera the input is attached to.
  39049. */
  39050. camera: ArcRotateCamera;
  39051. /**
  39052. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39053. */
  39054. alphaCorrection: number;
  39055. /**
  39056. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39057. */
  39058. gammaCorrection: number;
  39059. private _alpha;
  39060. private _gamma;
  39061. private _dirty;
  39062. private _deviceOrientationHandler;
  39063. /**
  39064. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39065. */
  39066. constructor();
  39067. /**
  39068. * Attach the input controls to a specific dom element to get the input from.
  39069. * @param element Defines the element the controls should be listened from
  39070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39071. */
  39072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39073. /** @hidden */
  39074. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39075. /**
  39076. * Update the current camera state depending on the inputs that have been used this frame.
  39077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39078. */
  39079. checkInputs(): void;
  39080. /**
  39081. * Detach the current controls from the specified dom element.
  39082. * @param element Defines the element to stop listening the inputs from
  39083. */
  39084. detachControl(element: Nullable<HTMLElement>): void;
  39085. /**
  39086. * Gets the class name of the current intput.
  39087. * @returns the class name
  39088. */
  39089. getClassName(): string;
  39090. /**
  39091. * Get the friendly name associated with the input class.
  39092. * @returns the input friendly name
  39093. */
  39094. getSimpleName(): string;
  39095. }
  39096. }
  39097. declare module BABYLON {
  39098. /**
  39099. * Listen to mouse events to control the camera.
  39100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39101. */
  39102. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39103. /**
  39104. * Defines the camera the input is attached to.
  39105. */
  39106. camera: FlyCamera;
  39107. /**
  39108. * Defines if touch is enabled. (Default is true.)
  39109. */
  39110. touchEnabled: boolean;
  39111. /**
  39112. * Defines the buttons associated with the input to handle camera rotation.
  39113. */
  39114. buttons: number[];
  39115. /**
  39116. * Assign buttons for Yaw control.
  39117. */
  39118. buttonsYaw: number[];
  39119. /**
  39120. * Assign buttons for Pitch control.
  39121. */
  39122. buttonsPitch: number[];
  39123. /**
  39124. * Assign buttons for Roll control.
  39125. */
  39126. buttonsRoll: number[];
  39127. /**
  39128. * Detect if any button is being pressed while mouse is moved.
  39129. * -1 = Mouse locked.
  39130. * 0 = Left button.
  39131. * 1 = Middle Button.
  39132. * 2 = Right Button.
  39133. */
  39134. activeButton: number;
  39135. /**
  39136. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39137. * Higher values reduce its sensitivity.
  39138. */
  39139. angularSensibility: number;
  39140. private _mousemoveCallback;
  39141. private _observer;
  39142. private _rollObserver;
  39143. private previousPosition;
  39144. private noPreventDefault;
  39145. private element;
  39146. /**
  39147. * Listen to mouse events to control the camera.
  39148. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39150. */
  39151. constructor(touchEnabled?: boolean);
  39152. /**
  39153. * Attach the mouse control to the HTML DOM element.
  39154. * @param element Defines the element that listens to the input events.
  39155. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39156. */
  39157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39158. /**
  39159. * Detach the current controls from the specified dom element.
  39160. * @param element Defines the element to stop listening the inputs from
  39161. */
  39162. detachControl(element: Nullable<HTMLElement>): void;
  39163. /**
  39164. * Gets the class name of the current input.
  39165. * @returns the class name.
  39166. */
  39167. getClassName(): string;
  39168. /**
  39169. * Get the friendly name associated with the input class.
  39170. * @returns the input's friendly name.
  39171. */
  39172. getSimpleName(): string;
  39173. private _pointerInput;
  39174. private _onMouseMove;
  39175. /**
  39176. * Rotate camera by mouse offset.
  39177. */
  39178. private rotateCamera;
  39179. }
  39180. }
  39181. declare module BABYLON {
  39182. /**
  39183. * Default Inputs manager for the FlyCamera.
  39184. * It groups all the default supported inputs for ease of use.
  39185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39186. */
  39187. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39188. /**
  39189. * Instantiates a new FlyCameraInputsManager.
  39190. * @param camera Defines the camera the inputs belong to.
  39191. */
  39192. constructor(camera: FlyCamera);
  39193. /**
  39194. * Add keyboard input support to the input manager.
  39195. * @returns the new FlyCameraKeyboardMoveInput().
  39196. */
  39197. addKeyboard(): FlyCameraInputsManager;
  39198. /**
  39199. * Add mouse input support to the input manager.
  39200. * @param touchEnabled Enable touch screen support.
  39201. * @returns the new FlyCameraMouseInput().
  39202. */
  39203. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39204. }
  39205. }
  39206. declare module BABYLON {
  39207. /**
  39208. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39209. * such as in a 3D Space Shooter or a Flight Simulator.
  39210. */
  39211. export class FlyCamera extends TargetCamera {
  39212. /**
  39213. * Define the collision ellipsoid of the camera.
  39214. * This is helpful for simulating a camera body, like a player's body.
  39215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39216. */
  39217. ellipsoid: Vector3;
  39218. /**
  39219. * Define an offset for the position of the ellipsoid around the camera.
  39220. * This can be helpful if the camera is attached away from the player's body center,
  39221. * such as at its head.
  39222. */
  39223. ellipsoidOffset: Vector3;
  39224. /**
  39225. * Enable or disable collisions of the camera with the rest of the scene objects.
  39226. */
  39227. checkCollisions: boolean;
  39228. /**
  39229. * Enable or disable gravity on the camera.
  39230. */
  39231. applyGravity: boolean;
  39232. /**
  39233. * Define the current direction the camera is moving to.
  39234. */
  39235. cameraDirection: Vector3;
  39236. /**
  39237. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39238. * This overrides and empties cameraRotation.
  39239. */
  39240. rotationQuaternion: Quaternion;
  39241. /**
  39242. * Track Roll to maintain the wanted Rolling when looking around.
  39243. */
  39244. _trackRoll: number;
  39245. /**
  39246. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39247. */
  39248. rollCorrect: number;
  39249. /**
  39250. * Mimic a banked turn, Rolling the camera when Yawing.
  39251. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39252. */
  39253. bankedTurn: boolean;
  39254. /**
  39255. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39256. */
  39257. bankedTurnLimit: number;
  39258. /**
  39259. * Value of 0 disables the banked Roll.
  39260. * Value of 1 is equal to the Yaw angle in radians.
  39261. */
  39262. bankedTurnMultiplier: number;
  39263. /**
  39264. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39265. */
  39266. inputs: FlyCameraInputsManager;
  39267. /**
  39268. * Gets the input sensibility for mouse input.
  39269. * Higher values reduce sensitivity.
  39270. */
  39271. /**
  39272. * Sets the input sensibility for a mouse input.
  39273. * Higher values reduce sensitivity.
  39274. */
  39275. angularSensibility: number;
  39276. /**
  39277. * Get the keys for camera movement forward.
  39278. */
  39279. /**
  39280. * Set the keys for camera movement forward.
  39281. */
  39282. keysForward: number[];
  39283. /**
  39284. * Get the keys for camera movement backward.
  39285. */
  39286. keysBackward: number[];
  39287. /**
  39288. * Get the keys for camera movement up.
  39289. */
  39290. /**
  39291. * Set the keys for camera movement up.
  39292. */
  39293. keysUp: number[];
  39294. /**
  39295. * Get the keys for camera movement down.
  39296. */
  39297. /**
  39298. * Set the keys for camera movement down.
  39299. */
  39300. keysDown: number[];
  39301. /**
  39302. * Get the keys for camera movement left.
  39303. */
  39304. /**
  39305. * Set the keys for camera movement left.
  39306. */
  39307. keysLeft: number[];
  39308. /**
  39309. * Set the keys for camera movement right.
  39310. */
  39311. /**
  39312. * Set the keys for camera movement right.
  39313. */
  39314. keysRight: number[];
  39315. /**
  39316. * Event raised when the camera collides with a mesh in the scene.
  39317. */
  39318. onCollide: (collidedMesh: AbstractMesh) => void;
  39319. private _collider;
  39320. private _needMoveForGravity;
  39321. private _oldPosition;
  39322. private _diffPosition;
  39323. private _newPosition;
  39324. /** @hidden */
  39325. _localDirection: Vector3;
  39326. /** @hidden */
  39327. _transformedDirection: Vector3;
  39328. /**
  39329. * Instantiates a FlyCamera.
  39330. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39331. * such as in a 3D Space Shooter or a Flight Simulator.
  39332. * @param name Define the name of the camera in the scene.
  39333. * @param position Define the starting position of the camera in the scene.
  39334. * @param scene Define the scene the camera belongs to.
  39335. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39336. */
  39337. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39338. /**
  39339. * Attach a control to the HTML DOM element.
  39340. * @param element Defines the element that listens to the input events.
  39341. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39342. */
  39343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39344. /**
  39345. * Detach a control from the HTML DOM element.
  39346. * The camera will stop reacting to that input.
  39347. * @param element Defines the element that listens to the input events.
  39348. */
  39349. detachControl(element: HTMLElement): void;
  39350. private _collisionMask;
  39351. /**
  39352. * Get the mask that the camera ignores in collision events.
  39353. */
  39354. /**
  39355. * Set the mask that the camera ignores in collision events.
  39356. */
  39357. collisionMask: number;
  39358. /** @hidden */
  39359. _collideWithWorld(displacement: Vector3): void;
  39360. /** @hidden */
  39361. private _onCollisionPositionChange;
  39362. /** @hidden */
  39363. _checkInputs(): void;
  39364. /** @hidden */
  39365. _decideIfNeedsToMove(): boolean;
  39366. /** @hidden */
  39367. _updatePosition(): void;
  39368. /**
  39369. * Restore the Roll to its target value at the rate specified.
  39370. * @param rate - Higher means slower restoring.
  39371. * @hidden
  39372. */
  39373. restoreRoll(rate: number): void;
  39374. /**
  39375. * Destroy the camera and release the current resources held by it.
  39376. */
  39377. dispose(): void;
  39378. /**
  39379. * Get the current object class name.
  39380. * @returns the class name.
  39381. */
  39382. getClassName(): string;
  39383. }
  39384. }
  39385. declare module BABYLON {
  39386. /**
  39387. * Listen to keyboard events to control the camera.
  39388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39389. */
  39390. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39391. /**
  39392. * Defines the camera the input is attached to.
  39393. */
  39394. camera: FlyCamera;
  39395. /**
  39396. * The list of keyboard keys used to control the forward move of the camera.
  39397. */
  39398. keysForward: number[];
  39399. /**
  39400. * The list of keyboard keys used to control the backward move of the camera.
  39401. */
  39402. keysBackward: number[];
  39403. /**
  39404. * The list of keyboard keys used to control the forward move of the camera.
  39405. */
  39406. keysUp: number[];
  39407. /**
  39408. * The list of keyboard keys used to control the backward move of the camera.
  39409. */
  39410. keysDown: number[];
  39411. /**
  39412. * The list of keyboard keys used to control the right strafe move of the camera.
  39413. */
  39414. keysRight: number[];
  39415. /**
  39416. * The list of keyboard keys used to control the left strafe move of the camera.
  39417. */
  39418. keysLeft: number[];
  39419. private _keys;
  39420. private _onCanvasBlurObserver;
  39421. private _onKeyboardObserver;
  39422. private _engine;
  39423. private _scene;
  39424. /**
  39425. * Attach the input controls to a specific dom element to get the input from.
  39426. * @param element Defines the element the controls should be listened from
  39427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39428. */
  39429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39430. /**
  39431. * Detach the current controls from the specified dom element.
  39432. * @param element Defines the element to stop listening the inputs from
  39433. */
  39434. detachControl(element: Nullable<HTMLElement>): void;
  39435. /**
  39436. * Gets the class name of the current intput.
  39437. * @returns the class name
  39438. */
  39439. getClassName(): string;
  39440. /** @hidden */
  39441. _onLostFocus(e: FocusEvent): void;
  39442. /**
  39443. * Get the friendly name associated with the input class.
  39444. * @returns the input friendly name
  39445. */
  39446. getSimpleName(): string;
  39447. /**
  39448. * Update the current camera state depending on the inputs that have been used this frame.
  39449. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39450. */
  39451. checkInputs(): void;
  39452. }
  39453. }
  39454. declare module BABYLON {
  39455. /**
  39456. * Manage the mouse wheel inputs to control a follow camera.
  39457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39458. */
  39459. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39460. /**
  39461. * Defines the camera the input is attached to.
  39462. */
  39463. camera: FollowCamera;
  39464. /**
  39465. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39466. */
  39467. axisControlRadius: boolean;
  39468. /**
  39469. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39470. */
  39471. axisControlHeight: boolean;
  39472. /**
  39473. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39474. */
  39475. axisControlRotation: boolean;
  39476. /**
  39477. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39478. * relation to mouseWheel events.
  39479. */
  39480. wheelPrecision: number;
  39481. /**
  39482. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39483. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39484. */
  39485. wheelDeltaPercentage: number;
  39486. private _wheel;
  39487. private _observer;
  39488. /**
  39489. * Attach the input controls to a specific dom element to get the input from.
  39490. * @param element Defines the element the controls should be listened from
  39491. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39492. */
  39493. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39494. /**
  39495. * Detach the current controls from the specified dom element.
  39496. * @param element Defines the element to stop listening the inputs from
  39497. */
  39498. detachControl(element: Nullable<HTMLElement>): void;
  39499. /**
  39500. * Gets the class name of the current intput.
  39501. * @returns the class name
  39502. */
  39503. getClassName(): string;
  39504. /**
  39505. * Get the friendly name associated with the input class.
  39506. * @returns the input friendly name
  39507. */
  39508. getSimpleName(): string;
  39509. }
  39510. }
  39511. declare module BABYLON {
  39512. /**
  39513. * Manage the pointers inputs to control an follow camera.
  39514. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39515. */
  39516. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39517. /**
  39518. * Defines the camera the input is attached to.
  39519. */
  39520. camera: FollowCamera;
  39521. /**
  39522. * Gets the class name of the current input.
  39523. * @returns the class name
  39524. */
  39525. getClassName(): string;
  39526. /**
  39527. * Defines the pointer angular sensibility along the X axis or how fast is
  39528. * the camera rotating.
  39529. * A negative number will reverse the axis direction.
  39530. */
  39531. angularSensibilityX: number;
  39532. /**
  39533. * Defines the pointer angular sensibility along the Y axis or how fast is
  39534. * the camera rotating.
  39535. * A negative number will reverse the axis direction.
  39536. */
  39537. angularSensibilityY: number;
  39538. /**
  39539. * Defines the pointer pinch precision or how fast is the camera zooming.
  39540. * A negative number will reverse the axis direction.
  39541. */
  39542. pinchPrecision: number;
  39543. /**
  39544. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39545. * from 0.
  39546. * It defines the percentage of current camera.radius to use as delta when
  39547. * pinch zoom is used.
  39548. */
  39549. pinchDeltaPercentage: number;
  39550. /**
  39551. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39552. */
  39553. axisXControlRadius: boolean;
  39554. /**
  39555. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39556. */
  39557. axisXControlHeight: boolean;
  39558. /**
  39559. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39560. */
  39561. axisXControlRotation: boolean;
  39562. /**
  39563. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39564. */
  39565. axisYControlRadius: boolean;
  39566. /**
  39567. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39568. */
  39569. axisYControlHeight: boolean;
  39570. /**
  39571. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39572. */
  39573. axisYControlRotation: boolean;
  39574. /**
  39575. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39576. */
  39577. axisPinchControlRadius: boolean;
  39578. /**
  39579. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39580. */
  39581. axisPinchControlHeight: boolean;
  39582. /**
  39583. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39584. */
  39585. axisPinchControlRotation: boolean;
  39586. /**
  39587. * Log error messages if basic misconfiguration has occurred.
  39588. */
  39589. warningEnable: boolean;
  39590. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39591. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39592. private _warningCounter;
  39593. private _warning;
  39594. }
  39595. }
  39596. declare module BABYLON {
  39597. /**
  39598. * Default Inputs manager for the FollowCamera.
  39599. * It groups all the default supported inputs for ease of use.
  39600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39601. */
  39602. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39603. /**
  39604. * Instantiates a new FollowCameraInputsManager.
  39605. * @param camera Defines the camera the inputs belong to
  39606. */
  39607. constructor(camera: FollowCamera);
  39608. /**
  39609. * Add keyboard input support to the input manager.
  39610. * @returns the current input manager
  39611. */
  39612. addKeyboard(): FollowCameraInputsManager;
  39613. /**
  39614. * Add mouse wheel input support to the input manager.
  39615. * @returns the current input manager
  39616. */
  39617. addMouseWheel(): FollowCameraInputsManager;
  39618. /**
  39619. * Add pointers input support to the input manager.
  39620. * @returns the current input manager
  39621. */
  39622. addPointers(): FollowCameraInputsManager;
  39623. /**
  39624. * Add orientation input support to the input manager.
  39625. * @returns the current input manager
  39626. */
  39627. addVRDeviceOrientation(): FollowCameraInputsManager;
  39628. }
  39629. }
  39630. declare module BABYLON {
  39631. /**
  39632. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39633. * an arc rotate version arcFollowCamera are available.
  39634. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39635. */
  39636. export class FollowCamera extends TargetCamera {
  39637. /**
  39638. * Distance the follow camera should follow an object at
  39639. */
  39640. radius: number;
  39641. /**
  39642. * Minimum allowed distance of the camera to the axis of rotation
  39643. * (The camera can not get closer).
  39644. * This can help limiting how the Camera is able to move in the scene.
  39645. */
  39646. lowerRadiusLimit: Nullable<number>;
  39647. /**
  39648. * Maximum allowed distance of the camera to the axis of rotation
  39649. * (The camera can not get further).
  39650. * This can help limiting how the Camera is able to move in the scene.
  39651. */
  39652. upperRadiusLimit: Nullable<number>;
  39653. /**
  39654. * Define a rotation offset between the camera and the object it follows
  39655. */
  39656. rotationOffset: number;
  39657. /**
  39658. * Minimum allowed angle to camera position relative to target object.
  39659. * This can help limiting how the Camera is able to move in the scene.
  39660. */
  39661. lowerRotationOffsetLimit: Nullable<number>;
  39662. /**
  39663. * Maximum allowed angle to camera position relative to target object.
  39664. * This can help limiting how the Camera is able to move in the scene.
  39665. */
  39666. upperRotationOffsetLimit: Nullable<number>;
  39667. /**
  39668. * Define a height offset between the camera and the object it follows.
  39669. * It can help following an object from the top (like a car chaing a plane)
  39670. */
  39671. heightOffset: number;
  39672. /**
  39673. * Minimum allowed height of camera position relative to target object.
  39674. * This can help limiting how the Camera is able to move in the scene.
  39675. */
  39676. lowerHeightOffsetLimit: Nullable<number>;
  39677. /**
  39678. * Maximum allowed height of camera position relative to target object.
  39679. * This can help limiting how the Camera is able to move in the scene.
  39680. */
  39681. upperHeightOffsetLimit: Nullable<number>;
  39682. /**
  39683. * Define how fast the camera can accelerate to follow it s target.
  39684. */
  39685. cameraAcceleration: number;
  39686. /**
  39687. * Define the speed limit of the camera following an object.
  39688. */
  39689. maxCameraSpeed: number;
  39690. /**
  39691. * Define the target of the camera.
  39692. */
  39693. lockedTarget: Nullable<AbstractMesh>;
  39694. /**
  39695. * Defines the input associated with the camera.
  39696. */
  39697. inputs: FollowCameraInputsManager;
  39698. /**
  39699. * Instantiates the follow camera.
  39700. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39701. * @param name Define the name of the camera in the scene
  39702. * @param position Define the position of the camera
  39703. * @param scene Define the scene the camera belong to
  39704. * @param lockedTarget Define the target of the camera
  39705. */
  39706. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39707. private _follow;
  39708. /**
  39709. * Attached controls to the current camera.
  39710. * @param element Defines the element the controls should be listened from
  39711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39712. */
  39713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39714. /**
  39715. * Detach the current controls from the camera.
  39716. * The camera will stop reacting to inputs.
  39717. * @param element Defines the element to stop listening the inputs from
  39718. */
  39719. detachControl(element: HTMLElement): void;
  39720. /** @hidden */
  39721. _checkInputs(): void;
  39722. private _checkLimits;
  39723. /**
  39724. * Gets the camera class name.
  39725. * @returns the class name
  39726. */
  39727. getClassName(): string;
  39728. }
  39729. /**
  39730. * Arc Rotate version of the follow camera.
  39731. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39732. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39733. */
  39734. export class ArcFollowCamera extends TargetCamera {
  39735. /** The longitudinal angle of the camera */
  39736. alpha: number;
  39737. /** The latitudinal angle of the camera */
  39738. beta: number;
  39739. /** The radius of the camera from its target */
  39740. radius: number;
  39741. /** Define the camera target (the messh it should follow) */
  39742. target: Nullable<AbstractMesh>;
  39743. private _cartesianCoordinates;
  39744. /**
  39745. * Instantiates a new ArcFollowCamera
  39746. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39747. * @param name Define the name of the camera
  39748. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39749. * @param beta Define the rotation angle of the camera around the elevation axis
  39750. * @param radius Define the radius of the camera from its target point
  39751. * @param target Define the target of the camera
  39752. * @param scene Define the scene the camera belongs to
  39753. */
  39754. constructor(name: string,
  39755. /** The longitudinal angle of the camera */
  39756. alpha: number,
  39757. /** The latitudinal angle of the camera */
  39758. beta: number,
  39759. /** The radius of the camera from its target */
  39760. radius: number,
  39761. /** Define the camera target (the messh it should follow) */
  39762. target: Nullable<AbstractMesh>, scene: Scene);
  39763. private _follow;
  39764. /** @hidden */
  39765. _checkInputs(): void;
  39766. /**
  39767. * Returns the class name of the object.
  39768. * It is mostly used internally for serialization purposes.
  39769. */
  39770. getClassName(): string;
  39771. }
  39772. }
  39773. declare module BABYLON {
  39774. /**
  39775. * Manage the keyboard inputs to control the movement of a follow camera.
  39776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39777. */
  39778. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39779. /**
  39780. * Defines the camera the input is attached to.
  39781. */
  39782. camera: FollowCamera;
  39783. /**
  39784. * Defines the list of key codes associated with the up action (increase heightOffset)
  39785. */
  39786. keysHeightOffsetIncr: number[];
  39787. /**
  39788. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39789. */
  39790. keysHeightOffsetDecr: number[];
  39791. /**
  39792. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39793. */
  39794. keysHeightOffsetModifierAlt: boolean;
  39795. /**
  39796. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39797. */
  39798. keysHeightOffsetModifierCtrl: boolean;
  39799. /**
  39800. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39801. */
  39802. keysHeightOffsetModifierShift: boolean;
  39803. /**
  39804. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39805. */
  39806. keysRotationOffsetIncr: number[];
  39807. /**
  39808. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39809. */
  39810. keysRotationOffsetDecr: number[];
  39811. /**
  39812. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39813. */
  39814. keysRotationOffsetModifierAlt: boolean;
  39815. /**
  39816. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39817. */
  39818. keysRotationOffsetModifierCtrl: boolean;
  39819. /**
  39820. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39821. */
  39822. keysRotationOffsetModifierShift: boolean;
  39823. /**
  39824. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39825. */
  39826. keysRadiusIncr: number[];
  39827. /**
  39828. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39829. */
  39830. keysRadiusDecr: number[];
  39831. /**
  39832. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39833. */
  39834. keysRadiusModifierAlt: boolean;
  39835. /**
  39836. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39837. */
  39838. keysRadiusModifierCtrl: boolean;
  39839. /**
  39840. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39841. */
  39842. keysRadiusModifierShift: boolean;
  39843. /**
  39844. * Defines the rate of change of heightOffset.
  39845. */
  39846. heightSensibility: number;
  39847. /**
  39848. * Defines the rate of change of rotationOffset.
  39849. */
  39850. rotationSensibility: number;
  39851. /**
  39852. * Defines the rate of change of radius.
  39853. */
  39854. radiusSensibility: number;
  39855. private _keys;
  39856. private _ctrlPressed;
  39857. private _altPressed;
  39858. private _shiftPressed;
  39859. private _onCanvasBlurObserver;
  39860. private _onKeyboardObserver;
  39861. private _engine;
  39862. private _scene;
  39863. /**
  39864. * Attach the input controls to a specific dom element to get the input from.
  39865. * @param element Defines the element the controls should be listened from
  39866. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39867. */
  39868. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39869. /**
  39870. * Detach the current controls from the specified dom element.
  39871. * @param element Defines the element to stop listening the inputs from
  39872. */
  39873. detachControl(element: Nullable<HTMLElement>): void;
  39874. /**
  39875. * Update the current camera state depending on the inputs that have been used this frame.
  39876. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39877. */
  39878. checkInputs(): void;
  39879. /**
  39880. * Gets the class name of the current input.
  39881. * @returns the class name
  39882. */
  39883. getClassName(): string;
  39884. /**
  39885. * Get the friendly name associated with the input class.
  39886. * @returns the input friendly name
  39887. */
  39888. getSimpleName(): string;
  39889. /**
  39890. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39891. * allow modification of the heightOffset value.
  39892. */
  39893. private _modifierHeightOffset;
  39894. /**
  39895. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39896. * allow modification of the rotationOffset value.
  39897. */
  39898. private _modifierRotationOffset;
  39899. /**
  39900. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39901. * allow modification of the radius value.
  39902. */
  39903. private _modifierRadius;
  39904. }
  39905. }
  39906. declare module BABYLON {
  39907. interface FreeCameraInputsManager {
  39908. /**
  39909. * @hidden
  39910. */
  39911. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39912. /**
  39913. * Add orientation input support to the input manager.
  39914. * @returns the current input manager
  39915. */
  39916. addDeviceOrientation(): FreeCameraInputsManager;
  39917. }
  39918. /**
  39919. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39920. * Screen rotation is taken into account.
  39921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39922. */
  39923. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39924. private _camera;
  39925. private _screenOrientationAngle;
  39926. private _constantTranform;
  39927. private _screenQuaternion;
  39928. private _alpha;
  39929. private _beta;
  39930. private _gamma;
  39931. /**
  39932. * Can be used to detect if a device orientation sensor is available on a device
  39933. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39934. * @returns a promise that will resolve on orientation change
  39935. */
  39936. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39937. /**
  39938. * @hidden
  39939. */
  39940. _onDeviceOrientationChangedObservable: Observable<void>;
  39941. /**
  39942. * Instantiates a new input
  39943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39944. */
  39945. constructor();
  39946. /**
  39947. * Define the camera controlled by the input.
  39948. */
  39949. camera: FreeCamera;
  39950. /**
  39951. * Attach the input controls to a specific dom element to get the input from.
  39952. * @param element Defines the element the controls should be listened from
  39953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39954. */
  39955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39956. private _orientationChanged;
  39957. private _deviceOrientation;
  39958. /**
  39959. * Detach the current controls from the specified dom element.
  39960. * @param element Defines the element to stop listening the inputs from
  39961. */
  39962. detachControl(element: Nullable<HTMLElement>): void;
  39963. /**
  39964. * Update the current camera state depending on the inputs that have been used this frame.
  39965. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39966. */
  39967. checkInputs(): void;
  39968. /**
  39969. * Gets the class name of the current intput.
  39970. * @returns the class name
  39971. */
  39972. getClassName(): string;
  39973. /**
  39974. * Get the friendly name associated with the input class.
  39975. * @returns the input friendly name
  39976. */
  39977. getSimpleName(): string;
  39978. }
  39979. }
  39980. declare module BABYLON {
  39981. /**
  39982. * Manage the gamepad inputs to control a free camera.
  39983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39984. */
  39985. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39986. /**
  39987. * Define the camera the input is attached to.
  39988. */
  39989. camera: FreeCamera;
  39990. /**
  39991. * Define the Gamepad controlling the input
  39992. */
  39993. gamepad: Nullable<Gamepad>;
  39994. /**
  39995. * Defines the gamepad rotation sensiblity.
  39996. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39997. */
  39998. gamepadAngularSensibility: number;
  39999. /**
  40000. * Defines the gamepad move sensiblity.
  40001. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40002. */
  40003. gamepadMoveSensibility: number;
  40004. private _yAxisScale;
  40005. /**
  40006. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40007. */
  40008. invertYAxis: boolean;
  40009. private _onGamepadConnectedObserver;
  40010. private _onGamepadDisconnectedObserver;
  40011. private _cameraTransform;
  40012. private _deltaTransform;
  40013. private _vector3;
  40014. private _vector2;
  40015. /**
  40016. * Attach the input controls to a specific dom element to get the input from.
  40017. * @param element Defines the element the controls should be listened from
  40018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40019. */
  40020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40021. /**
  40022. * Detach the current controls from the specified dom element.
  40023. * @param element Defines the element to stop listening the inputs from
  40024. */
  40025. detachControl(element: Nullable<HTMLElement>): void;
  40026. /**
  40027. * Update the current camera state depending on the inputs that have been used this frame.
  40028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40029. */
  40030. checkInputs(): void;
  40031. /**
  40032. * Gets the class name of the current intput.
  40033. * @returns the class name
  40034. */
  40035. getClassName(): string;
  40036. /**
  40037. * Get the friendly name associated with the input class.
  40038. * @returns the input friendly name
  40039. */
  40040. getSimpleName(): string;
  40041. }
  40042. }
  40043. declare module BABYLON {
  40044. /**
  40045. * Defines the potential axis of a Joystick
  40046. */
  40047. export enum JoystickAxis {
  40048. /** X axis */
  40049. X = 0,
  40050. /** Y axis */
  40051. Y = 1,
  40052. /** Z axis */
  40053. Z = 2
  40054. }
  40055. /**
  40056. * Class used to define virtual joystick (used in touch mode)
  40057. */
  40058. export class VirtualJoystick {
  40059. /**
  40060. * Gets or sets a boolean indicating that left and right values must be inverted
  40061. */
  40062. reverseLeftRight: boolean;
  40063. /**
  40064. * Gets or sets a boolean indicating that up and down values must be inverted
  40065. */
  40066. reverseUpDown: boolean;
  40067. /**
  40068. * Gets the offset value for the position (ie. the change of the position value)
  40069. */
  40070. deltaPosition: Vector3;
  40071. /**
  40072. * Gets a boolean indicating if the virtual joystick was pressed
  40073. */
  40074. pressed: boolean;
  40075. /**
  40076. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40077. */
  40078. static Canvas: Nullable<HTMLCanvasElement>;
  40079. private static _globalJoystickIndex;
  40080. private static vjCanvasContext;
  40081. private static vjCanvasWidth;
  40082. private static vjCanvasHeight;
  40083. private static halfWidth;
  40084. private _action;
  40085. private _axisTargetedByLeftAndRight;
  40086. private _axisTargetedByUpAndDown;
  40087. private _joystickSensibility;
  40088. private _inversedSensibility;
  40089. private _joystickPointerID;
  40090. private _joystickColor;
  40091. private _joystickPointerPos;
  40092. private _joystickPreviousPointerPos;
  40093. private _joystickPointerStartPos;
  40094. private _deltaJoystickVector;
  40095. private _leftJoystick;
  40096. private _touches;
  40097. private _onPointerDownHandlerRef;
  40098. private _onPointerMoveHandlerRef;
  40099. private _onPointerUpHandlerRef;
  40100. private _onResize;
  40101. /**
  40102. * Creates a new virtual joystick
  40103. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40104. */
  40105. constructor(leftJoystick?: boolean);
  40106. /**
  40107. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40108. * @param newJoystickSensibility defines the new sensibility
  40109. */
  40110. setJoystickSensibility(newJoystickSensibility: number): void;
  40111. private _onPointerDown;
  40112. private _onPointerMove;
  40113. private _onPointerUp;
  40114. /**
  40115. * Change the color of the virtual joystick
  40116. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40117. */
  40118. setJoystickColor(newColor: string): void;
  40119. /**
  40120. * Defines a callback to call when the joystick is touched
  40121. * @param action defines the callback
  40122. */
  40123. setActionOnTouch(action: () => any): void;
  40124. /**
  40125. * Defines which axis you'd like to control for left & right
  40126. * @param axis defines the axis to use
  40127. */
  40128. setAxisForLeftRight(axis: JoystickAxis): void;
  40129. /**
  40130. * Defines which axis you'd like to control for up & down
  40131. * @param axis defines the axis to use
  40132. */
  40133. setAxisForUpDown(axis: JoystickAxis): void;
  40134. private _drawVirtualJoystick;
  40135. /**
  40136. * Release internal HTML canvas
  40137. */
  40138. releaseCanvas(): void;
  40139. }
  40140. }
  40141. declare module BABYLON {
  40142. interface FreeCameraInputsManager {
  40143. /**
  40144. * Add virtual joystick input support to the input manager.
  40145. * @returns the current input manager
  40146. */
  40147. addVirtualJoystick(): FreeCameraInputsManager;
  40148. }
  40149. /**
  40150. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40151. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40152. */
  40153. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40154. /**
  40155. * Defines the camera the input is attached to.
  40156. */
  40157. camera: FreeCamera;
  40158. private _leftjoystick;
  40159. private _rightjoystick;
  40160. /**
  40161. * Gets the left stick of the virtual joystick.
  40162. * @returns The virtual Joystick
  40163. */
  40164. getLeftJoystick(): VirtualJoystick;
  40165. /**
  40166. * Gets the right stick of the virtual joystick.
  40167. * @returns The virtual Joystick
  40168. */
  40169. getRightJoystick(): VirtualJoystick;
  40170. /**
  40171. * Update the current camera state depending on the inputs that have been used this frame.
  40172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40173. */
  40174. checkInputs(): void;
  40175. /**
  40176. * Attach the input controls to a specific dom element to get the input from.
  40177. * @param element Defines the element the controls should be listened from
  40178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40179. */
  40180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40181. /**
  40182. * Detach the current controls from the specified dom element.
  40183. * @param element Defines the element to stop listening the inputs from
  40184. */
  40185. detachControl(element: Nullable<HTMLElement>): void;
  40186. /**
  40187. * Gets the class name of the current intput.
  40188. * @returns the class name
  40189. */
  40190. getClassName(): string;
  40191. /**
  40192. * Get the friendly name associated with the input class.
  40193. * @returns the input friendly name
  40194. */
  40195. getSimpleName(): string;
  40196. }
  40197. }
  40198. declare module BABYLON {
  40199. /**
  40200. * This represents a FPS type of camera controlled by touch.
  40201. * This is like a universal camera minus the Gamepad controls.
  40202. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40203. */
  40204. export class TouchCamera extends FreeCamera {
  40205. /**
  40206. * Defines the touch sensibility for rotation.
  40207. * The higher the faster.
  40208. */
  40209. touchAngularSensibility: number;
  40210. /**
  40211. * Defines the touch sensibility for move.
  40212. * The higher the faster.
  40213. */
  40214. touchMoveSensibility: number;
  40215. /**
  40216. * Instantiates a new touch camera.
  40217. * This represents a FPS type of camera controlled by touch.
  40218. * This is like a universal camera minus the Gamepad controls.
  40219. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40220. * @param name Define the name of the camera in the scene
  40221. * @param position Define the start position of the camera in the scene
  40222. * @param scene Define the scene the camera belongs to
  40223. */
  40224. constructor(name: string, position: Vector3, scene: Scene);
  40225. /**
  40226. * Gets the current object class name.
  40227. * @return the class name
  40228. */
  40229. getClassName(): string;
  40230. /** @hidden */
  40231. _setupInputs(): void;
  40232. }
  40233. }
  40234. declare module BABYLON {
  40235. /**
  40236. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40237. * being tilted forward or back and left or right.
  40238. */
  40239. export class DeviceOrientationCamera extends FreeCamera {
  40240. private _initialQuaternion;
  40241. private _quaternionCache;
  40242. private _tmpDragQuaternion;
  40243. private _disablePointerInputWhenUsingDeviceOrientation;
  40244. /**
  40245. * Creates a new device orientation camera
  40246. * @param name The name of the camera
  40247. * @param position The start position camera
  40248. * @param scene The scene the camera belongs to
  40249. */
  40250. constructor(name: string, position: Vector3, scene: Scene);
  40251. /**
  40252. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40253. */
  40254. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40255. private _dragFactor;
  40256. /**
  40257. * Enabled turning on the y axis when the orientation sensor is active
  40258. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40259. */
  40260. enableHorizontalDragging(dragFactor?: number): void;
  40261. /**
  40262. * Gets the current instance class name ("DeviceOrientationCamera").
  40263. * This helps avoiding instanceof at run time.
  40264. * @returns the class name
  40265. */
  40266. getClassName(): string;
  40267. /**
  40268. * @hidden
  40269. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40270. */
  40271. _checkInputs(): void;
  40272. /**
  40273. * Reset the camera to its default orientation on the specified axis only.
  40274. * @param axis The axis to reset
  40275. */
  40276. resetToCurrentRotation(axis?: Axis): void;
  40277. }
  40278. }
  40279. declare module BABYLON {
  40280. /**
  40281. * Defines supported buttons for XBox360 compatible gamepads
  40282. */
  40283. export enum Xbox360Button {
  40284. /** A */
  40285. A = 0,
  40286. /** B */
  40287. B = 1,
  40288. /** X */
  40289. X = 2,
  40290. /** Y */
  40291. Y = 3,
  40292. /** Start */
  40293. Start = 4,
  40294. /** Back */
  40295. Back = 5,
  40296. /** Left button */
  40297. LB = 6,
  40298. /** Right button */
  40299. RB = 7,
  40300. /** Left stick */
  40301. LeftStick = 8,
  40302. /** Right stick */
  40303. RightStick = 9
  40304. }
  40305. /** Defines values for XBox360 DPad */
  40306. export enum Xbox360Dpad {
  40307. /** Up */
  40308. Up = 0,
  40309. /** Down */
  40310. Down = 1,
  40311. /** Left */
  40312. Left = 2,
  40313. /** Right */
  40314. Right = 3
  40315. }
  40316. /**
  40317. * Defines a XBox360 gamepad
  40318. */
  40319. export class Xbox360Pad extends Gamepad {
  40320. private _leftTrigger;
  40321. private _rightTrigger;
  40322. private _onlefttriggerchanged;
  40323. private _onrighttriggerchanged;
  40324. private _onbuttondown;
  40325. private _onbuttonup;
  40326. private _ondpaddown;
  40327. private _ondpadup;
  40328. /** Observable raised when a button is pressed */
  40329. onButtonDownObservable: Observable<Xbox360Button>;
  40330. /** Observable raised when a button is released */
  40331. onButtonUpObservable: Observable<Xbox360Button>;
  40332. /** Observable raised when a pad is pressed */
  40333. onPadDownObservable: Observable<Xbox360Dpad>;
  40334. /** Observable raised when a pad is released */
  40335. onPadUpObservable: Observable<Xbox360Dpad>;
  40336. private _buttonA;
  40337. private _buttonB;
  40338. private _buttonX;
  40339. private _buttonY;
  40340. private _buttonBack;
  40341. private _buttonStart;
  40342. private _buttonLB;
  40343. private _buttonRB;
  40344. private _buttonLeftStick;
  40345. private _buttonRightStick;
  40346. private _dPadUp;
  40347. private _dPadDown;
  40348. private _dPadLeft;
  40349. private _dPadRight;
  40350. private _isXboxOnePad;
  40351. /**
  40352. * Creates a new XBox360 gamepad object
  40353. * @param id defines the id of this gamepad
  40354. * @param index defines its index
  40355. * @param gamepad defines the internal HTML gamepad object
  40356. * @param xboxOne defines if it is a XBox One gamepad
  40357. */
  40358. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40359. /**
  40360. * Defines the callback to call when left trigger is pressed
  40361. * @param callback defines the callback to use
  40362. */
  40363. onlefttriggerchanged(callback: (value: number) => void): void;
  40364. /**
  40365. * Defines the callback to call when right trigger is pressed
  40366. * @param callback defines the callback to use
  40367. */
  40368. onrighttriggerchanged(callback: (value: number) => void): void;
  40369. /**
  40370. * Gets the left trigger value
  40371. */
  40372. /**
  40373. * Sets the left trigger value
  40374. */
  40375. leftTrigger: number;
  40376. /**
  40377. * Gets the right trigger value
  40378. */
  40379. /**
  40380. * Sets the right trigger value
  40381. */
  40382. rightTrigger: number;
  40383. /**
  40384. * Defines the callback to call when a button is pressed
  40385. * @param callback defines the callback to use
  40386. */
  40387. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40388. /**
  40389. * Defines the callback to call when a button is released
  40390. * @param callback defines the callback to use
  40391. */
  40392. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40393. /**
  40394. * Defines the callback to call when a pad is pressed
  40395. * @param callback defines the callback to use
  40396. */
  40397. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40398. /**
  40399. * Defines the callback to call when a pad is released
  40400. * @param callback defines the callback to use
  40401. */
  40402. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40403. private _setButtonValue;
  40404. private _setDPadValue;
  40405. /**
  40406. * Gets the value of the `A` button
  40407. */
  40408. /**
  40409. * Sets the value of the `A` button
  40410. */
  40411. buttonA: number;
  40412. /**
  40413. * Gets the value of the `B` button
  40414. */
  40415. /**
  40416. * Sets the value of the `B` button
  40417. */
  40418. buttonB: number;
  40419. /**
  40420. * Gets the value of the `X` button
  40421. */
  40422. /**
  40423. * Sets the value of the `X` button
  40424. */
  40425. buttonX: number;
  40426. /**
  40427. * Gets the value of the `Y` button
  40428. */
  40429. /**
  40430. * Sets the value of the `Y` button
  40431. */
  40432. buttonY: number;
  40433. /**
  40434. * Gets the value of the `Start` button
  40435. */
  40436. /**
  40437. * Sets the value of the `Start` button
  40438. */
  40439. buttonStart: number;
  40440. /**
  40441. * Gets the value of the `Back` button
  40442. */
  40443. /**
  40444. * Sets the value of the `Back` button
  40445. */
  40446. buttonBack: number;
  40447. /**
  40448. * Gets the value of the `Left` button
  40449. */
  40450. /**
  40451. * Sets the value of the `Left` button
  40452. */
  40453. buttonLB: number;
  40454. /**
  40455. * Gets the value of the `Right` button
  40456. */
  40457. /**
  40458. * Sets the value of the `Right` button
  40459. */
  40460. buttonRB: number;
  40461. /**
  40462. * Gets the value of the Left joystick
  40463. */
  40464. /**
  40465. * Sets the value of the Left joystick
  40466. */
  40467. buttonLeftStick: number;
  40468. /**
  40469. * Gets the value of the Right joystick
  40470. */
  40471. /**
  40472. * Sets the value of the Right joystick
  40473. */
  40474. buttonRightStick: number;
  40475. /**
  40476. * Gets the value of D-pad up
  40477. */
  40478. /**
  40479. * Sets the value of D-pad up
  40480. */
  40481. dPadUp: number;
  40482. /**
  40483. * Gets the value of D-pad down
  40484. */
  40485. /**
  40486. * Sets the value of D-pad down
  40487. */
  40488. dPadDown: number;
  40489. /**
  40490. * Gets the value of D-pad left
  40491. */
  40492. /**
  40493. * Sets the value of D-pad left
  40494. */
  40495. dPadLeft: number;
  40496. /**
  40497. * Gets the value of D-pad right
  40498. */
  40499. /**
  40500. * Sets the value of D-pad right
  40501. */
  40502. dPadRight: number;
  40503. /**
  40504. * Force the gamepad to synchronize with device values
  40505. */
  40506. update(): void;
  40507. /**
  40508. * Disposes the gamepad
  40509. */
  40510. dispose(): void;
  40511. }
  40512. }
  40513. declare module BABYLON {
  40514. /**
  40515. * Defines supported buttons for DualShock compatible gamepads
  40516. */
  40517. export enum DualShockButton {
  40518. /** Cross */
  40519. Cross = 0,
  40520. /** Circle */
  40521. Circle = 1,
  40522. /** Square */
  40523. Square = 2,
  40524. /** Triangle */
  40525. Triangle = 3,
  40526. /** Options */
  40527. Options = 4,
  40528. /** Share */
  40529. Share = 5,
  40530. /** L1 */
  40531. L1 = 6,
  40532. /** R1 */
  40533. R1 = 7,
  40534. /** Left stick */
  40535. LeftStick = 8,
  40536. /** Right stick */
  40537. RightStick = 9
  40538. }
  40539. /** Defines values for DualShock DPad */
  40540. export enum DualShockDpad {
  40541. /** Up */
  40542. Up = 0,
  40543. /** Down */
  40544. Down = 1,
  40545. /** Left */
  40546. Left = 2,
  40547. /** Right */
  40548. Right = 3
  40549. }
  40550. /**
  40551. * Defines a DualShock gamepad
  40552. */
  40553. export class DualShockPad extends Gamepad {
  40554. private _leftTrigger;
  40555. private _rightTrigger;
  40556. private _onlefttriggerchanged;
  40557. private _onrighttriggerchanged;
  40558. private _onbuttondown;
  40559. private _onbuttonup;
  40560. private _ondpaddown;
  40561. private _ondpadup;
  40562. /** Observable raised when a button is pressed */
  40563. onButtonDownObservable: Observable<DualShockButton>;
  40564. /** Observable raised when a button is released */
  40565. onButtonUpObservable: Observable<DualShockButton>;
  40566. /** Observable raised when a pad is pressed */
  40567. onPadDownObservable: Observable<DualShockDpad>;
  40568. /** Observable raised when a pad is released */
  40569. onPadUpObservable: Observable<DualShockDpad>;
  40570. private _buttonCross;
  40571. private _buttonCircle;
  40572. private _buttonSquare;
  40573. private _buttonTriangle;
  40574. private _buttonShare;
  40575. private _buttonOptions;
  40576. private _buttonL1;
  40577. private _buttonR1;
  40578. private _buttonLeftStick;
  40579. private _buttonRightStick;
  40580. private _dPadUp;
  40581. private _dPadDown;
  40582. private _dPadLeft;
  40583. private _dPadRight;
  40584. /**
  40585. * Creates a new DualShock gamepad object
  40586. * @param id defines the id of this gamepad
  40587. * @param index defines its index
  40588. * @param gamepad defines the internal HTML gamepad object
  40589. */
  40590. constructor(id: string, index: number, gamepad: any);
  40591. /**
  40592. * Defines the callback to call when left trigger is pressed
  40593. * @param callback defines the callback to use
  40594. */
  40595. onlefttriggerchanged(callback: (value: number) => void): void;
  40596. /**
  40597. * Defines the callback to call when right trigger is pressed
  40598. * @param callback defines the callback to use
  40599. */
  40600. onrighttriggerchanged(callback: (value: number) => void): void;
  40601. /**
  40602. * Gets the left trigger value
  40603. */
  40604. /**
  40605. * Sets the left trigger value
  40606. */
  40607. leftTrigger: number;
  40608. /**
  40609. * Gets the right trigger value
  40610. */
  40611. /**
  40612. * Sets the right trigger value
  40613. */
  40614. rightTrigger: number;
  40615. /**
  40616. * Defines the callback to call when a button is pressed
  40617. * @param callback defines the callback to use
  40618. */
  40619. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40620. /**
  40621. * Defines the callback to call when a button is released
  40622. * @param callback defines the callback to use
  40623. */
  40624. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40625. /**
  40626. * Defines the callback to call when a pad is pressed
  40627. * @param callback defines the callback to use
  40628. */
  40629. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40630. /**
  40631. * Defines the callback to call when a pad is released
  40632. * @param callback defines the callback to use
  40633. */
  40634. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40635. private _setButtonValue;
  40636. private _setDPadValue;
  40637. /**
  40638. * Gets the value of the `Cross` button
  40639. */
  40640. /**
  40641. * Sets the value of the `Cross` button
  40642. */
  40643. buttonCross: number;
  40644. /**
  40645. * Gets the value of the `Circle` button
  40646. */
  40647. /**
  40648. * Sets the value of the `Circle` button
  40649. */
  40650. buttonCircle: number;
  40651. /**
  40652. * Gets the value of the `Square` button
  40653. */
  40654. /**
  40655. * Sets the value of the `Square` button
  40656. */
  40657. buttonSquare: number;
  40658. /**
  40659. * Gets the value of the `Triangle` button
  40660. */
  40661. /**
  40662. * Sets the value of the `Triangle` button
  40663. */
  40664. buttonTriangle: number;
  40665. /**
  40666. * Gets the value of the `Options` button
  40667. */
  40668. /**
  40669. * Sets the value of the `Options` button
  40670. */
  40671. buttonOptions: number;
  40672. /**
  40673. * Gets the value of the `Share` button
  40674. */
  40675. /**
  40676. * Sets the value of the `Share` button
  40677. */
  40678. buttonShare: number;
  40679. /**
  40680. * Gets the value of the `L1` button
  40681. */
  40682. /**
  40683. * Sets the value of the `L1` button
  40684. */
  40685. buttonL1: number;
  40686. /**
  40687. * Gets the value of the `R1` button
  40688. */
  40689. /**
  40690. * Sets the value of the `R1` button
  40691. */
  40692. buttonR1: number;
  40693. /**
  40694. * Gets the value of the Left joystick
  40695. */
  40696. /**
  40697. * Sets the value of the Left joystick
  40698. */
  40699. buttonLeftStick: number;
  40700. /**
  40701. * Gets the value of the Right joystick
  40702. */
  40703. /**
  40704. * Sets the value of the Right joystick
  40705. */
  40706. buttonRightStick: number;
  40707. /**
  40708. * Gets the value of D-pad up
  40709. */
  40710. /**
  40711. * Sets the value of D-pad up
  40712. */
  40713. dPadUp: number;
  40714. /**
  40715. * Gets the value of D-pad down
  40716. */
  40717. /**
  40718. * Sets the value of D-pad down
  40719. */
  40720. dPadDown: number;
  40721. /**
  40722. * Gets the value of D-pad left
  40723. */
  40724. /**
  40725. * Sets the value of D-pad left
  40726. */
  40727. dPadLeft: number;
  40728. /**
  40729. * Gets the value of D-pad right
  40730. */
  40731. /**
  40732. * Sets the value of D-pad right
  40733. */
  40734. dPadRight: number;
  40735. /**
  40736. * Force the gamepad to synchronize with device values
  40737. */
  40738. update(): void;
  40739. /**
  40740. * Disposes the gamepad
  40741. */
  40742. dispose(): void;
  40743. }
  40744. }
  40745. declare module BABYLON {
  40746. /**
  40747. * Manager for handling gamepads
  40748. */
  40749. export class GamepadManager {
  40750. private _scene?;
  40751. private _babylonGamepads;
  40752. private _oneGamepadConnected;
  40753. /** @hidden */
  40754. _isMonitoring: boolean;
  40755. private _gamepadEventSupported;
  40756. private _gamepadSupport;
  40757. /**
  40758. * observable to be triggered when the gamepad controller has been connected
  40759. */
  40760. onGamepadConnectedObservable: Observable<Gamepad>;
  40761. /**
  40762. * observable to be triggered when the gamepad controller has been disconnected
  40763. */
  40764. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40765. private _onGamepadConnectedEvent;
  40766. private _onGamepadDisconnectedEvent;
  40767. /**
  40768. * Initializes the gamepad manager
  40769. * @param _scene BabylonJS scene
  40770. */
  40771. constructor(_scene?: Scene | undefined);
  40772. /**
  40773. * The gamepads in the game pad manager
  40774. */
  40775. readonly gamepads: Gamepad[];
  40776. /**
  40777. * Get the gamepad controllers based on type
  40778. * @param type The type of gamepad controller
  40779. * @returns Nullable gamepad
  40780. */
  40781. getGamepadByType(type?: number): Nullable<Gamepad>;
  40782. /**
  40783. * Disposes the gamepad manager
  40784. */
  40785. dispose(): void;
  40786. private _addNewGamepad;
  40787. private _startMonitoringGamepads;
  40788. private _stopMonitoringGamepads;
  40789. /** @hidden */
  40790. _checkGamepadsStatus(): void;
  40791. private _updateGamepadObjects;
  40792. }
  40793. }
  40794. declare module BABYLON {
  40795. interface Scene {
  40796. /** @hidden */
  40797. _gamepadManager: Nullable<GamepadManager>;
  40798. /**
  40799. * Gets the gamepad manager associated with the scene
  40800. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40801. */
  40802. gamepadManager: GamepadManager;
  40803. }
  40804. /**
  40805. * Interface representing a free camera inputs manager
  40806. */
  40807. interface FreeCameraInputsManager {
  40808. /**
  40809. * Adds gamepad input support to the FreeCameraInputsManager.
  40810. * @returns the FreeCameraInputsManager
  40811. */
  40812. addGamepad(): FreeCameraInputsManager;
  40813. }
  40814. /**
  40815. * Interface representing an arc rotate camera inputs manager
  40816. */
  40817. interface ArcRotateCameraInputsManager {
  40818. /**
  40819. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40820. * @returns the camera inputs manager
  40821. */
  40822. addGamepad(): ArcRotateCameraInputsManager;
  40823. }
  40824. /**
  40825. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40826. */
  40827. export class GamepadSystemSceneComponent implements ISceneComponent {
  40828. /**
  40829. * The component name helpfull to identify the component in the list of scene components.
  40830. */
  40831. readonly name: string;
  40832. /**
  40833. * The scene the component belongs to.
  40834. */
  40835. scene: Scene;
  40836. /**
  40837. * Creates a new instance of the component for the given scene
  40838. * @param scene Defines the scene to register the component in
  40839. */
  40840. constructor(scene: Scene);
  40841. /**
  40842. * Registers the component in a given scene
  40843. */
  40844. register(): void;
  40845. /**
  40846. * Rebuilds the elements related to this component in case of
  40847. * context lost for instance.
  40848. */
  40849. rebuild(): void;
  40850. /**
  40851. * Disposes the component and the associated ressources
  40852. */
  40853. dispose(): void;
  40854. private _beforeCameraUpdate;
  40855. }
  40856. }
  40857. declare module BABYLON {
  40858. /**
  40859. * 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,
  40860. * which still works and will still be found in many Playgrounds.
  40861. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40862. */
  40863. export class UniversalCamera extends TouchCamera {
  40864. /**
  40865. * Defines the gamepad rotation sensiblity.
  40866. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40867. */
  40868. gamepadAngularSensibility: number;
  40869. /**
  40870. * Defines the gamepad move sensiblity.
  40871. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40872. */
  40873. gamepadMoveSensibility: number;
  40874. /**
  40875. * 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,
  40876. * which still works and will still be found in many Playgrounds.
  40877. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40878. * @param name Define the name of the camera in the scene
  40879. * @param position Define the start position of the camera in the scene
  40880. * @param scene Define the scene the camera belongs to
  40881. */
  40882. constructor(name: string, position: Vector3, scene: Scene);
  40883. /**
  40884. * Gets the current object class name.
  40885. * @return the class name
  40886. */
  40887. getClassName(): string;
  40888. }
  40889. }
  40890. declare module BABYLON {
  40891. /**
  40892. * This represents a FPS type of camera. This is only here for back compat purpose.
  40893. * Please use the UniversalCamera instead as both are identical.
  40894. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40895. */
  40896. export class GamepadCamera extends UniversalCamera {
  40897. /**
  40898. * Instantiates a new Gamepad Camera
  40899. * This represents a FPS type of camera. This is only here for back compat purpose.
  40900. * Please use the UniversalCamera instead as both are identical.
  40901. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40902. * @param name Define the name of the camera in the scene
  40903. * @param position Define the start position of the camera in the scene
  40904. * @param scene Define the scene the camera belongs to
  40905. */
  40906. constructor(name: string, position: Vector3, scene: Scene);
  40907. /**
  40908. * Gets the current object class name.
  40909. * @return the class name
  40910. */
  40911. getClassName(): string;
  40912. }
  40913. }
  40914. declare module BABYLON {
  40915. /** @hidden */
  40916. export var passPixelShader: {
  40917. name: string;
  40918. shader: string;
  40919. };
  40920. }
  40921. declare module BABYLON {
  40922. /** @hidden */
  40923. export var passCubePixelShader: {
  40924. name: string;
  40925. shader: string;
  40926. };
  40927. }
  40928. declare module BABYLON {
  40929. /**
  40930. * PassPostProcess which produces an output the same as it's input
  40931. */
  40932. export class PassPostProcess extends PostProcess {
  40933. /**
  40934. * Creates the PassPostProcess
  40935. * @param name The name of the effect.
  40936. * @param options The required width/height ratio to downsize to before computing the render pass.
  40937. * @param camera The camera to apply the render pass to.
  40938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40939. * @param engine The engine which the post process will be applied. (default: current engine)
  40940. * @param reusable If the post process can be reused on the same frame. (default: false)
  40941. * @param textureType The type of texture to be used when performing the post processing.
  40942. * @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)
  40943. */
  40944. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40945. }
  40946. /**
  40947. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40948. */
  40949. export class PassCubePostProcess extends PostProcess {
  40950. private _face;
  40951. /**
  40952. * Gets or sets the cube face to display.
  40953. * * 0 is +X
  40954. * * 1 is -X
  40955. * * 2 is +Y
  40956. * * 3 is -Y
  40957. * * 4 is +Z
  40958. * * 5 is -Z
  40959. */
  40960. face: number;
  40961. /**
  40962. * Creates the PassCubePostProcess
  40963. * @param name The name of the effect.
  40964. * @param options The required width/height ratio to downsize to before computing the render pass.
  40965. * @param camera The camera to apply the render pass to.
  40966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40967. * @param engine The engine which the post process will be applied. (default: current engine)
  40968. * @param reusable If the post process can be reused on the same frame. (default: false)
  40969. * @param textureType The type of texture to be used when performing the post processing.
  40970. * @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)
  40971. */
  40972. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40973. }
  40974. }
  40975. declare module BABYLON {
  40976. /** @hidden */
  40977. export var anaglyphPixelShader: {
  40978. name: string;
  40979. shader: string;
  40980. };
  40981. }
  40982. declare module BABYLON {
  40983. /**
  40984. * Postprocess used to generate anaglyphic rendering
  40985. */
  40986. export class AnaglyphPostProcess extends PostProcess {
  40987. private _passedProcess;
  40988. /**
  40989. * Creates a new AnaglyphPostProcess
  40990. * @param name defines postprocess name
  40991. * @param options defines creation options or target ratio scale
  40992. * @param rigCameras defines cameras using this postprocess
  40993. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40994. * @param engine defines hosting engine
  40995. * @param reusable defines if the postprocess will be reused multiple times per frame
  40996. */
  40997. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40998. }
  40999. }
  41000. declare module BABYLON {
  41001. /**
  41002. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41003. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41004. */
  41005. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41006. /**
  41007. * Creates a new AnaglyphArcRotateCamera
  41008. * @param name defines camera name
  41009. * @param alpha defines alpha angle (in radians)
  41010. * @param beta defines beta angle (in radians)
  41011. * @param radius defines radius
  41012. * @param target defines camera target
  41013. * @param interaxialDistance defines distance between each color axis
  41014. * @param scene defines the hosting scene
  41015. */
  41016. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41017. /**
  41018. * Gets camera class name
  41019. * @returns AnaglyphArcRotateCamera
  41020. */
  41021. getClassName(): string;
  41022. }
  41023. }
  41024. declare module BABYLON {
  41025. /**
  41026. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41027. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41028. */
  41029. export class AnaglyphFreeCamera extends FreeCamera {
  41030. /**
  41031. * Creates a new AnaglyphFreeCamera
  41032. * @param name defines camera name
  41033. * @param position defines initial position
  41034. * @param interaxialDistance defines distance between each color axis
  41035. * @param scene defines the hosting scene
  41036. */
  41037. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41038. /**
  41039. * Gets camera class name
  41040. * @returns AnaglyphFreeCamera
  41041. */
  41042. getClassName(): string;
  41043. }
  41044. }
  41045. declare module BABYLON {
  41046. /**
  41047. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41048. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41049. */
  41050. export class AnaglyphGamepadCamera extends GamepadCamera {
  41051. /**
  41052. * Creates a new AnaglyphGamepadCamera
  41053. * @param name defines camera name
  41054. * @param position defines initial position
  41055. * @param interaxialDistance defines distance between each color axis
  41056. * @param scene defines the hosting scene
  41057. */
  41058. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41059. /**
  41060. * Gets camera class name
  41061. * @returns AnaglyphGamepadCamera
  41062. */
  41063. getClassName(): string;
  41064. }
  41065. }
  41066. declare module BABYLON {
  41067. /**
  41068. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41069. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41070. */
  41071. export class AnaglyphUniversalCamera extends UniversalCamera {
  41072. /**
  41073. * Creates a new AnaglyphUniversalCamera
  41074. * @param name defines camera name
  41075. * @param position defines initial position
  41076. * @param interaxialDistance defines distance between each color axis
  41077. * @param scene defines the hosting scene
  41078. */
  41079. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41080. /**
  41081. * Gets camera class name
  41082. * @returns AnaglyphUniversalCamera
  41083. */
  41084. getClassName(): string;
  41085. }
  41086. }
  41087. declare module BABYLON {
  41088. /** @hidden */
  41089. export var stereoscopicInterlacePixelShader: {
  41090. name: string;
  41091. shader: string;
  41092. };
  41093. }
  41094. declare module BABYLON {
  41095. /**
  41096. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41097. */
  41098. export class StereoscopicInterlacePostProcess extends PostProcess {
  41099. private _stepSize;
  41100. private _passedProcess;
  41101. /**
  41102. * Initializes a StereoscopicInterlacePostProcess
  41103. * @param name The name of the effect.
  41104. * @param rigCameras The rig cameras to be appled to the post process
  41105. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41107. * @param engine The engine which the post process will be applied. (default: current engine)
  41108. * @param reusable If the post process can be reused on the same frame. (default: false)
  41109. */
  41110. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41111. }
  41112. }
  41113. declare module BABYLON {
  41114. /**
  41115. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41116. * @see http://doc.babylonjs.com/features/cameras
  41117. */
  41118. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41119. /**
  41120. * Creates a new StereoscopicArcRotateCamera
  41121. * @param name defines camera name
  41122. * @param alpha defines alpha angle (in radians)
  41123. * @param beta defines beta angle (in radians)
  41124. * @param radius defines radius
  41125. * @param target defines camera target
  41126. * @param interaxialDistance defines distance between each color axis
  41127. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41128. * @param scene defines the hosting scene
  41129. */
  41130. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41131. /**
  41132. * Gets camera class name
  41133. * @returns StereoscopicArcRotateCamera
  41134. */
  41135. getClassName(): string;
  41136. }
  41137. }
  41138. declare module BABYLON {
  41139. /**
  41140. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41141. * @see http://doc.babylonjs.com/features/cameras
  41142. */
  41143. export class StereoscopicFreeCamera extends FreeCamera {
  41144. /**
  41145. * Creates a new StereoscopicFreeCamera
  41146. * @param name defines camera name
  41147. * @param position defines initial position
  41148. * @param interaxialDistance defines distance between each color axis
  41149. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41150. * @param scene defines the hosting scene
  41151. */
  41152. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41153. /**
  41154. * Gets camera class name
  41155. * @returns StereoscopicFreeCamera
  41156. */
  41157. getClassName(): string;
  41158. }
  41159. }
  41160. declare module BABYLON {
  41161. /**
  41162. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41163. * @see http://doc.babylonjs.com/features/cameras
  41164. */
  41165. export class StereoscopicGamepadCamera extends GamepadCamera {
  41166. /**
  41167. * Creates a new StereoscopicGamepadCamera
  41168. * @param name defines camera name
  41169. * @param position defines initial position
  41170. * @param interaxialDistance defines distance between each color axis
  41171. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41172. * @param scene defines the hosting scene
  41173. */
  41174. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41175. /**
  41176. * Gets camera class name
  41177. * @returns StereoscopicGamepadCamera
  41178. */
  41179. getClassName(): string;
  41180. }
  41181. }
  41182. declare module BABYLON {
  41183. /**
  41184. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41185. * @see http://doc.babylonjs.com/features/cameras
  41186. */
  41187. export class StereoscopicUniversalCamera extends UniversalCamera {
  41188. /**
  41189. * Creates a new StereoscopicUniversalCamera
  41190. * @param name defines camera name
  41191. * @param position defines initial position
  41192. * @param interaxialDistance defines distance between each color axis
  41193. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41194. * @param scene defines the hosting scene
  41195. */
  41196. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41197. /**
  41198. * Gets camera class name
  41199. * @returns StereoscopicUniversalCamera
  41200. */
  41201. getClassName(): string;
  41202. }
  41203. }
  41204. declare module BABYLON {
  41205. /**
  41206. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41207. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41208. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41209. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41210. */
  41211. export class VirtualJoysticksCamera extends FreeCamera {
  41212. /**
  41213. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41214. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41215. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41216. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41217. * @param name Define the name of the camera in the scene
  41218. * @param position Define the start position of the camera in the scene
  41219. * @param scene Define the scene the camera belongs to
  41220. */
  41221. constructor(name: string, position: Vector3, scene: Scene);
  41222. /**
  41223. * Gets the current object class name.
  41224. * @return the class name
  41225. */
  41226. getClassName(): string;
  41227. }
  41228. }
  41229. declare module BABYLON {
  41230. /**
  41231. * This represents all the required metrics to create a VR camera.
  41232. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41233. */
  41234. export class VRCameraMetrics {
  41235. /**
  41236. * Define the horizontal resolution off the screen.
  41237. */
  41238. hResolution: number;
  41239. /**
  41240. * Define the vertical resolution off the screen.
  41241. */
  41242. vResolution: number;
  41243. /**
  41244. * Define the horizontal screen size.
  41245. */
  41246. hScreenSize: number;
  41247. /**
  41248. * Define the vertical screen size.
  41249. */
  41250. vScreenSize: number;
  41251. /**
  41252. * Define the vertical screen center position.
  41253. */
  41254. vScreenCenter: number;
  41255. /**
  41256. * Define the distance of the eyes to the screen.
  41257. */
  41258. eyeToScreenDistance: number;
  41259. /**
  41260. * Define the distance between both lenses
  41261. */
  41262. lensSeparationDistance: number;
  41263. /**
  41264. * Define the distance between both viewer's eyes.
  41265. */
  41266. interpupillaryDistance: number;
  41267. /**
  41268. * Define the distortion factor of the VR postprocess.
  41269. * Please, touch with care.
  41270. */
  41271. distortionK: number[];
  41272. /**
  41273. * Define the chromatic aberration correction factors for the VR post process.
  41274. */
  41275. chromaAbCorrection: number[];
  41276. /**
  41277. * Define the scale factor of the post process.
  41278. * The smaller the better but the slower.
  41279. */
  41280. postProcessScaleFactor: number;
  41281. /**
  41282. * Define an offset for the lens center.
  41283. */
  41284. lensCenterOffset: number;
  41285. /**
  41286. * Define if the current vr camera should compensate the distortion of the lense or not.
  41287. */
  41288. compensateDistortion: boolean;
  41289. /**
  41290. * Defines if multiview should be enabled when rendering (Default: false)
  41291. */
  41292. multiviewEnabled: boolean;
  41293. /**
  41294. * Gets the rendering aspect ratio based on the provided resolutions.
  41295. */
  41296. readonly aspectRatio: number;
  41297. /**
  41298. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41299. */
  41300. readonly aspectRatioFov: number;
  41301. /**
  41302. * @hidden
  41303. */
  41304. readonly leftHMatrix: Matrix;
  41305. /**
  41306. * @hidden
  41307. */
  41308. readonly rightHMatrix: Matrix;
  41309. /**
  41310. * @hidden
  41311. */
  41312. readonly leftPreViewMatrix: Matrix;
  41313. /**
  41314. * @hidden
  41315. */
  41316. readonly rightPreViewMatrix: Matrix;
  41317. /**
  41318. * Get the default VRMetrics based on the most generic setup.
  41319. * @returns the default vr metrics
  41320. */
  41321. static GetDefault(): VRCameraMetrics;
  41322. }
  41323. }
  41324. declare module BABYLON {
  41325. /** @hidden */
  41326. export var vrDistortionCorrectionPixelShader: {
  41327. name: string;
  41328. shader: string;
  41329. };
  41330. }
  41331. declare module BABYLON {
  41332. /**
  41333. * VRDistortionCorrectionPostProcess used for mobile VR
  41334. */
  41335. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41336. private _isRightEye;
  41337. private _distortionFactors;
  41338. private _postProcessScaleFactor;
  41339. private _lensCenterOffset;
  41340. private _scaleIn;
  41341. private _scaleFactor;
  41342. private _lensCenter;
  41343. /**
  41344. * Initializes the VRDistortionCorrectionPostProcess
  41345. * @param name The name of the effect.
  41346. * @param camera The camera to apply the render pass to.
  41347. * @param isRightEye If this is for the right eye distortion
  41348. * @param vrMetrics All the required metrics for the VR camera
  41349. */
  41350. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41351. }
  41352. }
  41353. declare module BABYLON {
  41354. /**
  41355. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41356. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41357. */
  41358. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41359. /**
  41360. * Creates a new VRDeviceOrientationArcRotateCamera
  41361. * @param name defines camera name
  41362. * @param alpha defines the camera rotation along the logitudinal axis
  41363. * @param beta defines the camera rotation along the latitudinal axis
  41364. * @param radius defines the camera distance from its target
  41365. * @param target defines the camera target
  41366. * @param scene defines the scene the camera belongs to
  41367. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41368. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41369. */
  41370. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41371. /**
  41372. * Gets camera class name
  41373. * @returns VRDeviceOrientationArcRotateCamera
  41374. */
  41375. getClassName(): string;
  41376. }
  41377. }
  41378. declare module BABYLON {
  41379. /**
  41380. * Camera used to simulate VR rendering (based on FreeCamera)
  41381. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41382. */
  41383. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41384. /**
  41385. * Creates a new VRDeviceOrientationFreeCamera
  41386. * @param name defines camera name
  41387. * @param position defines the start position of the camera
  41388. * @param scene defines the scene the camera belongs to
  41389. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41390. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41391. */
  41392. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41393. /**
  41394. * Gets camera class name
  41395. * @returns VRDeviceOrientationFreeCamera
  41396. */
  41397. getClassName(): string;
  41398. }
  41399. }
  41400. declare module BABYLON {
  41401. /**
  41402. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41403. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41404. */
  41405. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41406. /**
  41407. * Creates a new VRDeviceOrientationGamepadCamera
  41408. * @param name defines camera name
  41409. * @param position defines the start position of the camera
  41410. * @param scene defines the scene the camera belongs to
  41411. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41412. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41413. */
  41414. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41415. /**
  41416. * Gets camera class name
  41417. * @returns VRDeviceOrientationGamepadCamera
  41418. */
  41419. getClassName(): string;
  41420. }
  41421. }
  41422. declare module BABYLON {
  41423. /** @hidden */
  41424. export var imageProcessingPixelShader: {
  41425. name: string;
  41426. shader: string;
  41427. };
  41428. }
  41429. declare module BABYLON {
  41430. /**
  41431. * ImageProcessingPostProcess
  41432. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41433. */
  41434. export class ImageProcessingPostProcess extends PostProcess {
  41435. /**
  41436. * Default configuration related to image processing available in the PBR Material.
  41437. */
  41438. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41439. /**
  41440. * Gets the image processing configuration used either in this material.
  41441. */
  41442. /**
  41443. * Sets the Default image processing configuration used either in the this material.
  41444. *
  41445. * If sets to null, the scene one is in use.
  41446. */
  41447. imageProcessingConfiguration: ImageProcessingConfiguration;
  41448. /**
  41449. * Keep track of the image processing observer to allow dispose and replace.
  41450. */
  41451. private _imageProcessingObserver;
  41452. /**
  41453. * Attaches a new image processing configuration to the PBR Material.
  41454. * @param configuration
  41455. */
  41456. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41457. /**
  41458. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41459. */
  41460. /**
  41461. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41462. */
  41463. colorCurves: Nullable<ColorCurves>;
  41464. /**
  41465. * Gets wether the color curves effect is enabled.
  41466. */
  41467. /**
  41468. * Sets wether the color curves effect is enabled.
  41469. */
  41470. colorCurvesEnabled: boolean;
  41471. /**
  41472. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41473. */
  41474. /**
  41475. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41476. */
  41477. colorGradingTexture: Nullable<BaseTexture>;
  41478. /**
  41479. * Gets wether the color grading effect is enabled.
  41480. */
  41481. /**
  41482. * Gets wether the color grading effect is enabled.
  41483. */
  41484. colorGradingEnabled: boolean;
  41485. /**
  41486. * Gets exposure used in the effect.
  41487. */
  41488. /**
  41489. * Sets exposure used in the effect.
  41490. */
  41491. exposure: number;
  41492. /**
  41493. * Gets wether tonemapping is enabled or not.
  41494. */
  41495. /**
  41496. * Sets wether tonemapping is enabled or not
  41497. */
  41498. toneMappingEnabled: boolean;
  41499. /**
  41500. * Gets the type of tone mapping effect.
  41501. */
  41502. /**
  41503. * Sets the type of tone mapping effect.
  41504. */
  41505. toneMappingType: number;
  41506. /**
  41507. * Gets contrast used in the effect.
  41508. */
  41509. /**
  41510. * Sets contrast used in the effect.
  41511. */
  41512. contrast: number;
  41513. /**
  41514. * Gets Vignette stretch size.
  41515. */
  41516. /**
  41517. * Sets Vignette stretch size.
  41518. */
  41519. vignetteStretch: number;
  41520. /**
  41521. * Gets Vignette centre X Offset.
  41522. */
  41523. /**
  41524. * Sets Vignette centre X Offset.
  41525. */
  41526. vignetteCentreX: number;
  41527. /**
  41528. * Gets Vignette centre Y Offset.
  41529. */
  41530. /**
  41531. * Sets Vignette centre Y Offset.
  41532. */
  41533. vignetteCentreY: number;
  41534. /**
  41535. * Gets Vignette weight or intensity of the vignette effect.
  41536. */
  41537. /**
  41538. * Sets Vignette weight or intensity of the vignette effect.
  41539. */
  41540. vignetteWeight: number;
  41541. /**
  41542. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41543. * if vignetteEnabled is set to true.
  41544. */
  41545. /**
  41546. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41547. * if vignetteEnabled is set to true.
  41548. */
  41549. vignetteColor: Color4;
  41550. /**
  41551. * Gets Camera field of view used by the Vignette effect.
  41552. */
  41553. /**
  41554. * Sets Camera field of view used by the Vignette effect.
  41555. */
  41556. vignetteCameraFov: number;
  41557. /**
  41558. * Gets the vignette blend mode allowing different kind of effect.
  41559. */
  41560. /**
  41561. * Sets the vignette blend mode allowing different kind of effect.
  41562. */
  41563. vignetteBlendMode: number;
  41564. /**
  41565. * Gets wether the vignette effect is enabled.
  41566. */
  41567. /**
  41568. * Sets wether the vignette effect is enabled.
  41569. */
  41570. vignetteEnabled: boolean;
  41571. private _fromLinearSpace;
  41572. /**
  41573. * Gets wether the input of the processing is in Gamma or Linear Space.
  41574. */
  41575. /**
  41576. * Sets wether the input of the processing is in Gamma or Linear Space.
  41577. */
  41578. fromLinearSpace: boolean;
  41579. /**
  41580. * Defines cache preventing GC.
  41581. */
  41582. private _defines;
  41583. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41584. /**
  41585. * "ImageProcessingPostProcess"
  41586. * @returns "ImageProcessingPostProcess"
  41587. */
  41588. getClassName(): string;
  41589. protected _updateParameters(): void;
  41590. dispose(camera?: Camera): void;
  41591. }
  41592. }
  41593. declare module BABYLON {
  41594. /**
  41595. * Class containing static functions to help procedurally build meshes
  41596. */
  41597. export class GroundBuilder {
  41598. /**
  41599. * Creates a ground mesh
  41600. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41601. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41603. * @param name defines the name of the mesh
  41604. * @param options defines the options used to create the mesh
  41605. * @param scene defines the hosting scene
  41606. * @returns the ground mesh
  41607. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41608. */
  41609. static CreateGround(name: string, options: {
  41610. width?: number;
  41611. height?: number;
  41612. subdivisions?: number;
  41613. subdivisionsX?: number;
  41614. subdivisionsY?: number;
  41615. updatable?: boolean;
  41616. }, scene: any): Mesh;
  41617. /**
  41618. * Creates a tiled ground mesh
  41619. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41620. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41621. * * 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
  41622. * * 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
  41623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41624. * @param name defines the name of the mesh
  41625. * @param options defines the options used to create the mesh
  41626. * @param scene defines the hosting scene
  41627. * @returns the tiled ground mesh
  41628. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41629. */
  41630. static CreateTiledGround(name: string, options: {
  41631. xmin: number;
  41632. zmin: number;
  41633. xmax: number;
  41634. zmax: number;
  41635. subdivisions?: {
  41636. w: number;
  41637. h: number;
  41638. };
  41639. precision?: {
  41640. w: number;
  41641. h: number;
  41642. };
  41643. updatable?: boolean;
  41644. }, scene?: Nullable<Scene>): Mesh;
  41645. /**
  41646. * Creates a ground mesh from a height map
  41647. * * The parameter `url` sets the URL of the height map image resource.
  41648. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41649. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41650. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41651. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41652. * * 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.
  41653. * * 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).
  41654. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41656. * @param name defines the name of the mesh
  41657. * @param url defines the url to the height map
  41658. * @param options defines the options used to create the mesh
  41659. * @param scene defines the hosting scene
  41660. * @returns the ground mesh
  41661. * @see https://doc.babylonjs.com/babylon101/height_map
  41662. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41663. */
  41664. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41665. width?: number;
  41666. height?: number;
  41667. subdivisions?: number;
  41668. minHeight?: number;
  41669. maxHeight?: number;
  41670. colorFilter?: Color3;
  41671. alphaFilter?: number;
  41672. updatable?: boolean;
  41673. onReady?: (mesh: GroundMesh) => void;
  41674. }, scene?: Nullable<Scene>): GroundMesh;
  41675. }
  41676. }
  41677. declare module BABYLON {
  41678. /**
  41679. * Class containing static functions to help procedurally build meshes
  41680. */
  41681. export class TorusBuilder {
  41682. /**
  41683. * Creates a torus mesh
  41684. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41685. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41686. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41688. * * 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
  41689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41690. * @param name defines the name of the mesh
  41691. * @param options defines the options used to create the mesh
  41692. * @param scene defines the hosting scene
  41693. * @returns the torus mesh
  41694. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41695. */
  41696. static CreateTorus(name: string, options: {
  41697. diameter?: number;
  41698. thickness?: number;
  41699. tessellation?: number;
  41700. updatable?: boolean;
  41701. sideOrientation?: number;
  41702. frontUVs?: Vector4;
  41703. backUVs?: Vector4;
  41704. }, scene: any): Mesh;
  41705. }
  41706. }
  41707. declare module BABYLON {
  41708. /**
  41709. * Class containing static functions to help procedurally build meshes
  41710. */
  41711. export class CylinderBuilder {
  41712. /**
  41713. * Creates a cylinder or a cone mesh
  41714. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41715. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41716. * * 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.
  41717. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41718. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41719. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41720. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41721. * * 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).
  41722. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41723. * * 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).
  41724. * * 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
  41725. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41726. * * 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
  41727. * * 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.
  41728. * * If `enclose` is false, a ring surface is one element.
  41729. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41730. * * 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
  41731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41732. * * 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
  41733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41734. * @param name defines the name of the mesh
  41735. * @param options defines the options used to create the mesh
  41736. * @param scene defines the hosting scene
  41737. * @returns the cylinder mesh
  41738. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41739. */
  41740. static CreateCylinder(name: string, options: {
  41741. height?: number;
  41742. diameterTop?: number;
  41743. diameterBottom?: number;
  41744. diameter?: number;
  41745. tessellation?: number;
  41746. subdivisions?: number;
  41747. arc?: number;
  41748. faceColors?: Color4[];
  41749. faceUV?: Vector4[];
  41750. updatable?: boolean;
  41751. hasRings?: boolean;
  41752. enclose?: boolean;
  41753. cap?: number;
  41754. sideOrientation?: number;
  41755. frontUVs?: Vector4;
  41756. backUVs?: Vector4;
  41757. }, scene: any): Mesh;
  41758. }
  41759. }
  41760. declare module BABYLON {
  41761. /**
  41762. * States of the webXR experience
  41763. */
  41764. export enum WebXRState {
  41765. /**
  41766. * Transitioning to being in XR mode
  41767. */
  41768. ENTERING_XR = 0,
  41769. /**
  41770. * Transitioning to non XR mode
  41771. */
  41772. EXITING_XR = 1,
  41773. /**
  41774. * In XR mode and presenting
  41775. */
  41776. IN_XR = 2,
  41777. /**
  41778. * Not entered XR mode
  41779. */
  41780. NOT_IN_XR = 3
  41781. }
  41782. /**
  41783. * Abstraction of the XR render target
  41784. */
  41785. export interface WebXRRenderTarget extends IDisposable {
  41786. /**
  41787. * xrpresent context of the canvas which can be used to display/mirror xr content
  41788. */
  41789. canvasContext: WebGLRenderingContext;
  41790. /**
  41791. * xr layer for the canvas
  41792. */
  41793. xrLayer: Nullable<XRWebGLLayer>;
  41794. /**
  41795. * Initializes the xr layer for the session
  41796. * @param xrSession xr session
  41797. * @returns a promise that will resolve once the XR Layer has been created
  41798. */
  41799. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41800. }
  41801. }
  41802. declare module BABYLON {
  41803. /**
  41804. * COnfiguration object for WebXR output canvas
  41805. */
  41806. export class WebXRManagedOutputCanvasOptions {
  41807. /**
  41808. * Options for this XR Layer output
  41809. */
  41810. canvasOptions: XRWebGLLayerOptions;
  41811. /**
  41812. * CSS styling for a newly created canvas (if not provided)
  41813. */
  41814. newCanvasCssStyle?: string;
  41815. /**
  41816. * Get the default values of the configuration object
  41817. * @returns default values of this configuration object
  41818. */
  41819. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  41820. }
  41821. /**
  41822. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41823. */
  41824. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41825. private configuration;
  41826. private _engine;
  41827. private _canvas;
  41828. /**
  41829. * xrpresent context of the canvas which can be used to display/mirror xr content
  41830. */
  41831. canvasContext: WebGLRenderingContext;
  41832. /**
  41833. * xr layer for the canvas
  41834. */
  41835. xrLayer: Nullable<XRWebGLLayer>;
  41836. /**
  41837. * Initializes the xr layer for the session
  41838. * @param xrSession xr session
  41839. * @returns a promise that will resolve once the XR Layer has been created
  41840. */
  41841. initializeXRLayerAsync(xrSession: any): any;
  41842. /**
  41843. * Initializes the canvas to be added/removed upon entering/exiting xr
  41844. * @param engine the Babylon engine
  41845. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41846. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41847. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  41848. */
  41849. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  41850. /**
  41851. * Disposes of the object
  41852. */
  41853. dispose(): void;
  41854. private _setManagedOutputCanvas;
  41855. private _addCanvas;
  41856. private _removeCanvas;
  41857. }
  41858. }
  41859. declare module BABYLON {
  41860. /**
  41861. * Manages an XRSession to work with Babylon's engine
  41862. * @see https://doc.babylonjs.com/how_to/webxr
  41863. */
  41864. export class WebXRSessionManager implements IDisposable {
  41865. /** The scene which the session should be created for */
  41866. scene: Scene;
  41867. /**
  41868. * Fires every time a new xrFrame arrives which can be used to update the camera
  41869. */
  41870. onXRFrameObservable: Observable<XRFrame>;
  41871. /**
  41872. * Fires when the xr session is ended either by the device or manually done
  41873. */
  41874. onXRSessionEnded: Observable<any>;
  41875. /**
  41876. * Fires when the xr session is ended either by the device or manually done
  41877. */
  41878. onXRSessionInit: Observable<XRSession>;
  41879. /**
  41880. * Underlying xr session
  41881. */
  41882. session: XRSession;
  41883. /**
  41884. * Type of reference space used when creating the session
  41885. */
  41886. referenceSpace: XRReferenceSpace;
  41887. /**
  41888. * Current XR frame
  41889. */
  41890. currentFrame: Nullable<XRFrame>;
  41891. /** WebXR timestamp updated every frame */
  41892. currentTimestamp: number;
  41893. private _xrNavigator;
  41894. private baseLayer;
  41895. private _rttProvider;
  41896. private _sessionEnded;
  41897. /**
  41898. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41899. * @param scene The scene which the session should be created for
  41900. */
  41901. constructor(
  41902. /** The scene which the session should be created for */
  41903. scene: Scene);
  41904. /**
  41905. * Initializes the manager
  41906. * After initialization enterXR can be called to start an XR session
  41907. * @returns Promise which resolves after it is initialized
  41908. */
  41909. initializeAsync(): Promise<void>;
  41910. /**
  41911. * Initializes an xr session
  41912. * @param xrSessionMode mode to initialize
  41913. * @param optionalFeatures defines optional values to pass to the session builder
  41914. * @returns a promise which will resolve once the session has been initialized
  41915. */
  41916. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  41917. /**
  41918. * Sets the reference space on the xr session
  41919. * @param referenceSpace space to set
  41920. * @returns a promise that will resolve once the reference space has been set
  41921. */
  41922. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41923. /**
  41924. * Updates the render state of the session
  41925. * @param state state to set
  41926. * @returns a promise that resolves once the render state has been updated
  41927. */
  41928. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41929. /**
  41930. * Starts rendering to the xr layer
  41931. * @returns a promise that will resolve once rendering has started
  41932. */
  41933. startRenderingToXRAsync(): Promise<void>;
  41934. /**
  41935. * Gets the correct render target texture to be rendered this frame for this eye
  41936. * @param eye the eye for which to get the render target
  41937. * @returns the render target for the specified eye
  41938. */
  41939. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41940. /**
  41941. * Stops the xrSession and restores the renderloop
  41942. * @returns Promise which resolves after it exits XR
  41943. */
  41944. exitXRAsync(): Promise<void>;
  41945. /**
  41946. * Checks if a session would be supported for the creation options specified
  41947. * @param sessionMode session mode to check if supported eg. immersive-vr
  41948. * @returns true if supported
  41949. */
  41950. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41951. /**
  41952. * Creates a WebXRRenderTarget object for the XR session
  41953. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41954. * @param options optional options to provide when creating a new render target
  41955. * @returns a WebXR render target to which the session can render
  41956. */
  41957. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  41958. /**
  41959. * @hidden
  41960. * Converts the render layer of xrSession to a render target
  41961. * @param session session to create render target for
  41962. * @param scene scene the new render target should be created for
  41963. * @param baseLayer the webgl layer to create the render target for
  41964. */
  41965. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41966. /**
  41967. * Disposes of the session manager
  41968. */
  41969. dispose(): void;
  41970. /**
  41971. * Gets a promise returning true when fullfiled if the given session mode is supported
  41972. * @param sessionMode defines the session to test
  41973. * @returns a promise
  41974. */
  41975. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  41976. }
  41977. }
  41978. declare module BABYLON {
  41979. /**
  41980. * WebXR Camera which holds the views for the xrSession
  41981. * @see https://doc.babylonjs.com/how_to/webxr
  41982. */
  41983. export class WebXRCamera extends FreeCamera {
  41984. /**
  41985. * Is the camera in debug mode. Used when using an emulator
  41986. */
  41987. debugMode: boolean;
  41988. /**
  41989. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41990. * @param name the name of the camera
  41991. * @param scene the scene to add the camera to
  41992. */
  41993. constructor(name: string, scene: Scene);
  41994. private _updateNumberOfRigCameras;
  41995. /** @hidden */
  41996. _updateForDualEyeDebugging(): void;
  41997. /**
  41998. * Updates the cameras position from the current pose information of the XR session
  41999. * @param xrSessionManager the session containing pose information
  42000. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42001. */
  42002. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42003. }
  42004. }
  42005. declare module BABYLON {
  42006. /**
  42007. * Defining the interface required for a (webxr) feature
  42008. */
  42009. export interface IWebXRFeature extends IDisposable {
  42010. /**
  42011. * Attach the feature to the session
  42012. * Will usually be called by the features manager
  42013. *
  42014. * @returns true if successful.
  42015. */
  42016. attach(): boolean;
  42017. /**
  42018. * Detach the feature from the session
  42019. * Will usually be called by the features manager
  42020. *
  42021. * @returns true if successful.
  42022. */
  42023. detach(): boolean;
  42024. }
  42025. /**
  42026. * Defining the constructor of a feature. Used to register the modules.
  42027. */
  42028. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42029. /**
  42030. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42031. * It is mainly used in AR sessions.
  42032. *
  42033. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42034. */
  42035. export class WebXRFeaturesManager implements IDisposable {
  42036. private _xrSessionManager;
  42037. private static readonly _AvailableFeatures;
  42038. /**
  42039. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42040. * Mainly used internally.
  42041. *
  42042. * @param featureName the name of the feature to register
  42043. * @param constructorFunction the function used to construct the module
  42044. * @param version the (babylon) version of the module
  42045. * @param stable is that a stable version of this module
  42046. */
  42047. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42048. /**
  42049. * Returns a constructor of a specific feature.
  42050. *
  42051. * @param featureName the name of the feature to construct
  42052. * @param version the version of the feature to load
  42053. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42054. * @param options optional options provided to the module.
  42055. * @returns a function that, when called, will return a new instance of this feature
  42056. */
  42057. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42058. /**
  42059. * Return the latest unstable version of this feature
  42060. * @param featureName the name of the feature to search
  42061. * @returns the version number. if not found will return -1
  42062. */
  42063. static GetLatestVersionOfFeature(featureName: string): number;
  42064. /**
  42065. * Return the latest stable version of this feature
  42066. * @param featureName the name of the feature to search
  42067. * @returns the version number. if not found will return -1
  42068. */
  42069. static GetStableVersionOfFeature(featureName: string): number;
  42070. /**
  42071. * Can be used to return the list of features currently registered
  42072. *
  42073. * @returns an Array of available features
  42074. */
  42075. static GetAvailableFeatures(): string[];
  42076. /**
  42077. * Gets the versions available for a specific feature
  42078. * @param featureName the name of the feature
  42079. * @returns an array with the available versions
  42080. */
  42081. static GetAvailableVersions(featureName: string): string[];
  42082. private _features;
  42083. /**
  42084. * constructs a new features manages.
  42085. *
  42086. * @param _xrSessionManager an instance of WebXRSessionManager
  42087. */
  42088. constructor(_xrSessionManager: WebXRSessionManager);
  42089. /**
  42090. * 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.
  42091. *
  42092. * @param featureName the name of the feature to load or the class of the feature
  42093. * @param version optional version to load. if not provided the latest version will be enabled
  42094. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42095. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42096. * @returns a new constructed feature or throws an error if feature not found.
  42097. */
  42098. enableFeature(featureName: string | {
  42099. Name: string;
  42100. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42101. /**
  42102. * Used to disable an already-enabled feature
  42103. * @param featureName the feature to disable
  42104. * @returns true if disable was successful
  42105. */
  42106. disableFeature(featureName: string | {
  42107. Name: string;
  42108. }): boolean;
  42109. /**
  42110. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42111. * Can be used during a session to start a feature
  42112. * @param featureName the name of feature to attach
  42113. */
  42114. attachFeature(featureName: string): void;
  42115. /**
  42116. * Can be used inside a session or when the session ends to detach a specific feature
  42117. * @param featureName the name of the feature to detach
  42118. */
  42119. detachFeature(featureName: string): void;
  42120. /**
  42121. * Get the list of enabled features
  42122. * @returns an array of enabled features
  42123. */
  42124. getEnabledFeatures(): string[];
  42125. /**
  42126. * get the implementation of an enabled feature.
  42127. * @param featureName the name of the feature to load
  42128. * @returns the feature class, if found
  42129. */
  42130. getEnabledFeature(featureName: string): IWebXRFeature;
  42131. /**
  42132. * dispose this features manager
  42133. */
  42134. dispose(): void;
  42135. }
  42136. }
  42137. declare module BABYLON {
  42138. /**
  42139. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42140. * @see https://doc.babylonjs.com/how_to/webxr
  42141. */
  42142. export class WebXRExperienceHelper implements IDisposable {
  42143. private scene;
  42144. /**
  42145. * 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
  42146. */
  42147. container: AbstractMesh;
  42148. /**
  42149. * Camera used to render xr content
  42150. */
  42151. camera: WebXRCamera;
  42152. /**
  42153. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42154. */
  42155. state: WebXRState;
  42156. private _setState;
  42157. private static _TmpVector;
  42158. /**
  42159. * Fires when the state of the experience helper has changed
  42160. */
  42161. onStateChangedObservable: Observable<WebXRState>;
  42162. /** Session manager used to keep track of xr session */
  42163. sessionManager: WebXRSessionManager;
  42164. /** A features manager for this xr session */
  42165. featuresManager: WebXRFeaturesManager;
  42166. private _nonVRCamera;
  42167. private _originalSceneAutoClear;
  42168. private _supported;
  42169. /**
  42170. * Creates the experience helper
  42171. * @param scene the scene to attach the experience helper to
  42172. * @returns a promise for the experience helper
  42173. */
  42174. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42175. /**
  42176. * Creates a WebXRExperienceHelper
  42177. * @param scene The scene the helper should be created in
  42178. */
  42179. private constructor();
  42180. /**
  42181. * Exits XR mode and returns the scene to its original state
  42182. * @returns promise that resolves after xr mode has exited
  42183. */
  42184. exitXRAsync(): Promise<void>;
  42185. /**
  42186. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42187. * @param sessionMode options for the XR session
  42188. * @param referenceSpaceType frame of reference of the XR session
  42189. * @param renderTarget the output canvas that will be used to enter XR mode
  42190. * @returns promise that resolves after xr mode has entered
  42191. */
  42192. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42193. /**
  42194. * Updates the global position of the camera by moving the camera's container
  42195. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42196. * @param position The desired global position of the camera
  42197. */
  42198. setPositionOfCameraUsingContainer(position: Vector3): void;
  42199. /**
  42200. * Rotates the xr camera by rotating the camera's container around the camera's position
  42201. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42202. * @param rotation the desired quaternion rotation to apply to the camera
  42203. */
  42204. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42205. /**
  42206. * Disposes of the experience helper
  42207. */
  42208. dispose(): void;
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * Represents an XR input
  42214. */
  42215. export class WebXRController {
  42216. private scene;
  42217. /** The underlying input source for the controller */
  42218. inputSource: XRInputSource;
  42219. private parentContainer;
  42220. /**
  42221. * 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
  42222. */
  42223. grip?: AbstractMesh;
  42224. /**
  42225. * Pointer which can be used to select objects or attach a visible laser to
  42226. */
  42227. pointer: AbstractMesh;
  42228. private _gamepadMode;
  42229. /**
  42230. * If available, this is the gamepad object related to this controller.
  42231. * Using this object it is possible to get click events and trackpad changes of the
  42232. * webxr controller that is currently being used.
  42233. */
  42234. gamepadController?: WebVRController;
  42235. /**
  42236. * Event that fires when the controller is removed/disposed
  42237. */
  42238. onDisposeObservable: Observable<{}>;
  42239. private _tmpQuaternion;
  42240. private _tmpVector;
  42241. /**
  42242. * Creates the controller
  42243. * @see https://doc.babylonjs.com/how_to/webxr
  42244. * @param scene the scene which the controller should be associated to
  42245. * @param inputSource the underlying input source for the controller
  42246. * @param parentContainer parent that the controller meshes should be children of
  42247. */
  42248. constructor(scene: Scene,
  42249. /** The underlying input source for the controller */
  42250. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42251. /**
  42252. * Updates the controller pose based on the given XRFrame
  42253. * @param xrFrame xr frame to update the pose with
  42254. * @param referenceSpace reference space to use
  42255. */
  42256. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42257. /**
  42258. * Gets a world space ray coming from the controller
  42259. * @param result the resulting ray
  42260. */
  42261. getWorldPointerRayToRef(result: Ray): void;
  42262. /**
  42263. * Get the scene associated with this controller
  42264. * @returns the scene object
  42265. */
  42266. getScene(): Scene;
  42267. /**
  42268. * Disposes of the object
  42269. */
  42270. dispose(): void;
  42271. }
  42272. }
  42273. declare module BABYLON {
  42274. /**
  42275. * XR input used to track XR inputs such as controllers/rays
  42276. */
  42277. export class WebXRInput implements IDisposable {
  42278. /**
  42279. * Base experience the input listens to
  42280. */
  42281. baseExperience: WebXRExperienceHelper;
  42282. /**
  42283. * XR controllers being tracked
  42284. */
  42285. controllers: Array<WebXRController>;
  42286. private _frameObserver;
  42287. private _stateObserver;
  42288. /**
  42289. * Event when a controller has been connected/added
  42290. */
  42291. onControllerAddedObservable: Observable<WebXRController>;
  42292. /**
  42293. * Event when a controller has been removed/disconnected
  42294. */
  42295. onControllerRemovedObservable: Observable<WebXRController>;
  42296. /**
  42297. * Initializes the WebXRInput
  42298. * @param baseExperience experience helper which the input should be created for
  42299. */
  42300. constructor(
  42301. /**
  42302. * Base experience the input listens to
  42303. */
  42304. baseExperience: WebXRExperienceHelper);
  42305. private _onInputSourcesChange;
  42306. private _addAndRemoveControllers;
  42307. /**
  42308. * Disposes of the object
  42309. */
  42310. dispose(): void;
  42311. }
  42312. }
  42313. declare module BABYLON {
  42314. /**
  42315. * Class used to represent data loading progression
  42316. */
  42317. export class SceneLoaderProgressEvent {
  42318. /** defines if data length to load can be evaluated */
  42319. readonly lengthComputable: boolean;
  42320. /** defines the loaded data length */
  42321. readonly loaded: number;
  42322. /** defines the data length to load */
  42323. readonly total: number;
  42324. /**
  42325. * Create a new progress event
  42326. * @param lengthComputable defines if data length to load can be evaluated
  42327. * @param loaded defines the loaded data length
  42328. * @param total defines the data length to load
  42329. */
  42330. constructor(
  42331. /** defines if data length to load can be evaluated */
  42332. lengthComputable: boolean,
  42333. /** defines the loaded data length */
  42334. loaded: number,
  42335. /** defines the data length to load */
  42336. total: number);
  42337. /**
  42338. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42339. * @param event defines the source event
  42340. * @returns a new SceneLoaderProgressEvent
  42341. */
  42342. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42343. }
  42344. /**
  42345. * Interface used by SceneLoader plugins to define supported file extensions
  42346. */
  42347. export interface ISceneLoaderPluginExtensions {
  42348. /**
  42349. * Defines the list of supported extensions
  42350. */
  42351. [extension: string]: {
  42352. isBinary: boolean;
  42353. };
  42354. }
  42355. /**
  42356. * Interface used by SceneLoader plugin factory
  42357. */
  42358. export interface ISceneLoaderPluginFactory {
  42359. /**
  42360. * Defines the name of the factory
  42361. */
  42362. name: string;
  42363. /**
  42364. * Function called to create a new plugin
  42365. * @return the new plugin
  42366. */
  42367. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42368. /**
  42369. * The callback that returns true if the data can be directly loaded.
  42370. * @param data string containing the file data
  42371. * @returns if the data can be loaded directly
  42372. */
  42373. canDirectLoad?(data: string): boolean;
  42374. }
  42375. /**
  42376. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42377. */
  42378. export interface ISceneLoaderPluginBase {
  42379. /**
  42380. * The friendly name of this plugin.
  42381. */
  42382. name: string;
  42383. /**
  42384. * The file extensions supported by this plugin.
  42385. */
  42386. extensions: string | ISceneLoaderPluginExtensions;
  42387. /**
  42388. * The callback called when loading from a url.
  42389. * @param scene scene loading this url
  42390. * @param url url to load
  42391. * @param onSuccess callback called when the file successfully loads
  42392. * @param onProgress callback called while file is loading (if the server supports this mode)
  42393. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42394. * @param onError callback called when the file fails to load
  42395. * @returns a file request object
  42396. */
  42397. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42398. /**
  42399. * The callback called when loading from a file object.
  42400. * @param scene scene loading this file
  42401. * @param file defines the file to load
  42402. * @param onSuccess defines the callback to call when data is loaded
  42403. * @param onProgress defines the callback to call during loading process
  42404. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42405. * @param onError defines the callback to call when an error occurs
  42406. * @returns a file request object
  42407. */
  42408. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42409. /**
  42410. * The callback that returns true if the data can be directly loaded.
  42411. * @param data string containing the file data
  42412. * @returns if the data can be loaded directly
  42413. */
  42414. canDirectLoad?(data: string): boolean;
  42415. /**
  42416. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42417. * @param scene scene loading this data
  42418. * @param data string containing the data
  42419. * @returns data to pass to the plugin
  42420. */
  42421. directLoad?(scene: Scene, data: string): any;
  42422. /**
  42423. * The callback that allows custom handling of the root url based on the response url.
  42424. * @param rootUrl the original root url
  42425. * @param responseURL the response url if available
  42426. * @returns the new root url
  42427. */
  42428. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42429. }
  42430. /**
  42431. * Interface used to define a SceneLoader plugin
  42432. */
  42433. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42434. /**
  42435. * Import meshes into a scene.
  42436. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42437. * @param scene The scene to import into
  42438. * @param data The data to import
  42439. * @param rootUrl The root url for scene and resources
  42440. * @param meshes The meshes array to import into
  42441. * @param particleSystems The particle systems array to import into
  42442. * @param skeletons The skeletons array to import into
  42443. * @param onError The callback when import fails
  42444. * @returns True if successful or false otherwise
  42445. */
  42446. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42447. /**
  42448. * Load into a scene.
  42449. * @param scene The scene to load into
  42450. * @param data The data to import
  42451. * @param rootUrl The root url for scene and resources
  42452. * @param onError The callback when import fails
  42453. * @returns True if successful or false otherwise
  42454. */
  42455. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42456. /**
  42457. * Load into an asset container.
  42458. * @param scene The scene to load into
  42459. * @param data The data to import
  42460. * @param rootUrl The root url for scene and resources
  42461. * @param onError The callback when import fails
  42462. * @returns The loaded asset container
  42463. */
  42464. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42465. }
  42466. /**
  42467. * Interface used to define an async SceneLoader plugin
  42468. */
  42469. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42470. /**
  42471. * Import meshes into a scene.
  42472. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42473. * @param scene The scene to import into
  42474. * @param data The data to import
  42475. * @param rootUrl The root url for scene and resources
  42476. * @param onProgress The callback when the load progresses
  42477. * @param fileName Defines the name of the file to load
  42478. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42479. */
  42480. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42481. meshes: AbstractMesh[];
  42482. particleSystems: IParticleSystem[];
  42483. skeletons: Skeleton[];
  42484. animationGroups: AnimationGroup[];
  42485. }>;
  42486. /**
  42487. * Load into a scene.
  42488. * @param scene The scene to load into
  42489. * @param data The data to import
  42490. * @param rootUrl The root url for scene and resources
  42491. * @param onProgress The callback when the load progresses
  42492. * @param fileName Defines the name of the file to load
  42493. * @returns Nothing
  42494. */
  42495. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42496. /**
  42497. * Load into an asset container.
  42498. * @param scene The scene to load into
  42499. * @param data The data to import
  42500. * @param rootUrl The root url for scene and resources
  42501. * @param onProgress The callback when the load progresses
  42502. * @param fileName Defines the name of the file to load
  42503. * @returns The loaded asset container
  42504. */
  42505. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42506. }
  42507. /**
  42508. * Mode that determines how to handle old animation groups before loading new ones.
  42509. */
  42510. export enum SceneLoaderAnimationGroupLoadingMode {
  42511. /**
  42512. * Reset all old animations to initial state then dispose them.
  42513. */
  42514. Clean = 0,
  42515. /**
  42516. * Stop all old animations.
  42517. */
  42518. Stop = 1,
  42519. /**
  42520. * Restart old animations from first frame.
  42521. */
  42522. Sync = 2,
  42523. /**
  42524. * Old animations remains untouched.
  42525. */
  42526. NoSync = 3
  42527. }
  42528. /**
  42529. * Class used to load scene from various file formats using registered plugins
  42530. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42531. */
  42532. export class SceneLoader {
  42533. /**
  42534. * No logging while loading
  42535. */
  42536. static readonly NO_LOGGING: number;
  42537. /**
  42538. * Minimal logging while loading
  42539. */
  42540. static readonly MINIMAL_LOGGING: number;
  42541. /**
  42542. * Summary logging while loading
  42543. */
  42544. static readonly SUMMARY_LOGGING: number;
  42545. /**
  42546. * Detailled logging while loading
  42547. */
  42548. static readonly DETAILED_LOGGING: number;
  42549. /**
  42550. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42551. */
  42552. static ForceFullSceneLoadingForIncremental: boolean;
  42553. /**
  42554. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42555. */
  42556. static ShowLoadingScreen: boolean;
  42557. /**
  42558. * Defines the current logging level (while loading the scene)
  42559. * @ignorenaming
  42560. */
  42561. static loggingLevel: number;
  42562. /**
  42563. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42564. */
  42565. static CleanBoneMatrixWeights: boolean;
  42566. /**
  42567. * Event raised when a plugin is used to load a scene
  42568. */
  42569. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42570. private static _registeredPlugins;
  42571. private static _getDefaultPlugin;
  42572. private static _getPluginForExtension;
  42573. private static _getPluginForDirectLoad;
  42574. private static _getPluginForFilename;
  42575. private static _getDirectLoad;
  42576. private static _loadData;
  42577. private static _getFileInfo;
  42578. /**
  42579. * Gets a plugin that can load the given extension
  42580. * @param extension defines the extension to load
  42581. * @returns a plugin or null if none works
  42582. */
  42583. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42584. /**
  42585. * Gets a boolean indicating that the given extension can be loaded
  42586. * @param extension defines the extension to load
  42587. * @returns true if the extension is supported
  42588. */
  42589. static IsPluginForExtensionAvailable(extension: string): boolean;
  42590. /**
  42591. * Adds a new plugin to the list of registered plugins
  42592. * @param plugin defines the plugin to add
  42593. */
  42594. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42595. /**
  42596. * Import meshes into a scene
  42597. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42598. * @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)
  42599. * @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)
  42600. * @param scene the instance of BABYLON.Scene to append to
  42601. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42602. * @param onProgress a callback with a progress event for each file being loaded
  42603. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42604. * @param pluginExtension the extension used to determine the plugin
  42605. * @returns The loaded plugin
  42606. */
  42607. 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>;
  42608. /**
  42609. * Import meshes into a scene
  42610. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42611. * @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)
  42612. * @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)
  42613. * @param scene the instance of BABYLON.Scene to append to
  42614. * @param onProgress a callback with a progress event for each file being loaded
  42615. * @param pluginExtension the extension used to determine the plugin
  42616. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42617. */
  42618. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42619. meshes: AbstractMesh[];
  42620. particleSystems: IParticleSystem[];
  42621. skeletons: Skeleton[];
  42622. animationGroups: AnimationGroup[];
  42623. }>;
  42624. /**
  42625. * Load a scene
  42626. * @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)
  42627. * @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)
  42628. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42629. * @param onSuccess a callback with the scene when import succeeds
  42630. * @param onProgress a callback with a progress event for each file being loaded
  42631. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42632. * @param pluginExtension the extension used to determine the plugin
  42633. * @returns The loaded plugin
  42634. */
  42635. 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>;
  42636. /**
  42637. * Load a scene
  42638. * @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)
  42639. * @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)
  42640. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42641. * @param onProgress a callback with a progress event for each file being loaded
  42642. * @param pluginExtension the extension used to determine the plugin
  42643. * @returns The loaded scene
  42644. */
  42645. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42646. /**
  42647. * Append a scene
  42648. * @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)
  42649. * @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)
  42650. * @param scene is the instance of BABYLON.Scene to append to
  42651. * @param onSuccess a callback with the scene when import succeeds
  42652. * @param onProgress a callback with a progress event for each file being loaded
  42653. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42654. * @param pluginExtension the extension used to determine the plugin
  42655. * @returns The loaded plugin
  42656. */
  42657. 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>;
  42658. /**
  42659. * Append a scene
  42660. * @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)
  42661. * @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)
  42662. * @param scene is the instance of BABYLON.Scene to append to
  42663. * @param onProgress a callback with a progress event for each file being loaded
  42664. * @param pluginExtension the extension used to determine the plugin
  42665. * @returns The given scene
  42666. */
  42667. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42668. /**
  42669. * Load a scene into an asset container
  42670. * @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)
  42671. * @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)
  42672. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42673. * @param onSuccess a callback with the scene when import succeeds
  42674. * @param onProgress a callback with a progress event for each file being loaded
  42675. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42676. * @param pluginExtension the extension used to determine the plugin
  42677. * @returns The loaded plugin
  42678. */
  42679. 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>;
  42680. /**
  42681. * Load a scene into an asset container
  42682. * @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)
  42683. * @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)
  42684. * @param scene is the instance of Scene to append to
  42685. * @param onProgress a callback with a progress event for each file being loaded
  42686. * @param pluginExtension the extension used to determine the plugin
  42687. * @returns The loaded asset container
  42688. */
  42689. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42690. /**
  42691. * Import animations from a file into a scene
  42692. * @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)
  42693. * @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)
  42694. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42695. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  42696. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  42697. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  42698. * @param onSuccess a callback with the scene when import succeeds
  42699. * @param onProgress a callback with a progress event for each file being loaded
  42700. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42701. */
  42702. 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;
  42703. /**
  42704. * Import animations from a file into a scene
  42705. * @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)
  42706. * @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)
  42707. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42708. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  42709. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  42710. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  42711. * @param onSuccess a callback with the scene when import succeeds
  42712. * @param onProgress a callback with a progress event for each file being loaded
  42713. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42714. * @returns the updated scene with imported animations
  42715. */
  42716. 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>;
  42717. }
  42718. }
  42719. declare module BABYLON {
  42720. /**
  42721. * Generic Controller
  42722. */
  42723. export class GenericController extends WebVRController {
  42724. /**
  42725. * Base Url for the controller model.
  42726. */
  42727. static readonly MODEL_BASE_URL: string;
  42728. /**
  42729. * File name for the controller model.
  42730. */
  42731. static readonly MODEL_FILENAME: string;
  42732. /**
  42733. * Creates a new GenericController from a gamepad
  42734. * @param vrGamepad the gamepad that the controller should be created from
  42735. */
  42736. constructor(vrGamepad: any);
  42737. /**
  42738. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42739. * @param scene scene in which to add meshes
  42740. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42741. */
  42742. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42743. /**
  42744. * Called once for each button that changed state since the last frame
  42745. * @param buttonIdx Which button index changed
  42746. * @param state New state of the button
  42747. * @param changes Which properties on the state changed since last frame
  42748. */
  42749. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42750. }
  42751. }
  42752. declare module BABYLON {
  42753. /**
  42754. * Defines the WindowsMotionController object that the state of the windows motion controller
  42755. */
  42756. export class WindowsMotionController extends WebVRController {
  42757. /**
  42758. * The base url used to load the left and right controller models
  42759. */
  42760. static MODEL_BASE_URL: string;
  42761. /**
  42762. * The name of the left controller model file
  42763. */
  42764. static MODEL_LEFT_FILENAME: string;
  42765. /**
  42766. * The name of the right controller model file
  42767. */
  42768. static MODEL_RIGHT_FILENAME: string;
  42769. /**
  42770. * The controller name prefix for this controller type
  42771. */
  42772. static readonly GAMEPAD_ID_PREFIX: string;
  42773. /**
  42774. * The controller id pattern for this controller type
  42775. */
  42776. private static readonly GAMEPAD_ID_PATTERN;
  42777. private _loadedMeshInfo;
  42778. protected readonly _mapping: {
  42779. buttons: string[];
  42780. buttonMeshNames: {
  42781. 'trigger': string;
  42782. 'menu': string;
  42783. 'grip': string;
  42784. 'thumbstick': string;
  42785. 'trackpad': string;
  42786. };
  42787. buttonObservableNames: {
  42788. 'trigger': string;
  42789. 'menu': string;
  42790. 'grip': string;
  42791. 'thumbstick': string;
  42792. 'trackpad': string;
  42793. };
  42794. axisMeshNames: string[];
  42795. pointingPoseMeshName: string;
  42796. };
  42797. /**
  42798. * Fired when the trackpad on this controller is clicked
  42799. */
  42800. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42801. /**
  42802. * Fired when the trackpad on this controller is modified
  42803. */
  42804. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42805. /**
  42806. * The current x and y values of this controller's trackpad
  42807. */
  42808. trackpad: StickValues;
  42809. /**
  42810. * Creates a new WindowsMotionController from a gamepad
  42811. * @param vrGamepad the gamepad that the controller should be created from
  42812. */
  42813. constructor(vrGamepad: any);
  42814. /**
  42815. * Fired when the trigger on this controller is modified
  42816. */
  42817. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42818. /**
  42819. * Fired when the menu button on this controller is modified
  42820. */
  42821. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42822. /**
  42823. * Fired when the grip button on this controller is modified
  42824. */
  42825. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42826. /**
  42827. * Fired when the thumbstick button on this controller is modified
  42828. */
  42829. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42830. /**
  42831. * Fired when the touchpad button on this controller is modified
  42832. */
  42833. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42834. /**
  42835. * Fired when the touchpad values on this controller are modified
  42836. */
  42837. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42838. protected _updateTrackpad(): void;
  42839. /**
  42840. * Called once per frame by the engine.
  42841. */
  42842. update(): void;
  42843. /**
  42844. * Called once for each button that changed state since the last frame
  42845. * @param buttonIdx Which button index changed
  42846. * @param state New state of the button
  42847. * @param changes Which properties on the state changed since last frame
  42848. */
  42849. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42850. /**
  42851. * Moves the buttons on the controller mesh based on their current state
  42852. * @param buttonName the name of the button to move
  42853. * @param buttonValue the value of the button which determines the buttons new position
  42854. */
  42855. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42856. /**
  42857. * Moves the axis on the controller mesh based on its current state
  42858. * @param axis the index of the axis
  42859. * @param axisValue the value of the axis which determines the meshes new position
  42860. * @hidden
  42861. */
  42862. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42863. /**
  42864. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42865. * @param scene scene in which to add meshes
  42866. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42867. */
  42868. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42869. /**
  42870. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42871. * can be transformed by button presses and axes values, based on this._mapping.
  42872. *
  42873. * @param scene scene in which the meshes exist
  42874. * @param meshes list of meshes that make up the controller model to process
  42875. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42876. */
  42877. private processModel;
  42878. private createMeshInfo;
  42879. /**
  42880. * Gets the ray of the controller in the direction the controller is pointing
  42881. * @param length the length the resulting ray should be
  42882. * @returns a ray in the direction the controller is pointing
  42883. */
  42884. getForwardRay(length?: number): Ray;
  42885. /**
  42886. * Disposes of the controller
  42887. */
  42888. dispose(): void;
  42889. }
  42890. /**
  42891. * This class represents a new windows motion controller in XR.
  42892. */
  42893. export class XRWindowsMotionController extends WindowsMotionController {
  42894. /**
  42895. * Changing the original WIndowsMotionController mapping to fir the new mapping
  42896. */
  42897. protected readonly _mapping: {
  42898. buttons: string[];
  42899. buttonMeshNames: {
  42900. 'trigger': string;
  42901. 'menu': string;
  42902. 'grip': string;
  42903. 'thumbstick': string;
  42904. 'trackpad': string;
  42905. };
  42906. buttonObservableNames: {
  42907. 'trigger': string;
  42908. 'menu': string;
  42909. 'grip': string;
  42910. 'thumbstick': string;
  42911. 'trackpad': string;
  42912. };
  42913. axisMeshNames: string[];
  42914. pointingPoseMeshName: string;
  42915. };
  42916. /**
  42917. * Construct a new XR-Based windows motion controller
  42918. *
  42919. * @param gamepadInfo the gamepad object from the browser
  42920. */
  42921. constructor(gamepadInfo: any);
  42922. /**
  42923. * holds the thumbstick values (X,Y)
  42924. */
  42925. thumbstickValues: StickValues;
  42926. /**
  42927. * Fired when the thumbstick on this controller is clicked
  42928. */
  42929. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  42930. /**
  42931. * Fired when the thumbstick on this controller is modified
  42932. */
  42933. onThumbstickValuesChangedObservable: Observable<StickValues>;
  42934. /**
  42935. * Fired when the touchpad button on this controller is modified
  42936. */
  42937. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42938. /**
  42939. * Fired when the touchpad values on this controller are modified
  42940. */
  42941. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42942. /**
  42943. * Fired when the thumbstick button on this controller is modified
  42944. * here to prevent breaking changes
  42945. */
  42946. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42947. /**
  42948. * updating the thumbstick(!) and not the trackpad.
  42949. * This is named this way due to the difference between WebVR and XR and to avoid
  42950. * changing the parent class.
  42951. */
  42952. protected _updateTrackpad(): void;
  42953. /**
  42954. * Disposes the class with joy
  42955. */
  42956. dispose(): void;
  42957. }
  42958. }
  42959. declare module BABYLON {
  42960. /**
  42961. * Oculus Touch Controller
  42962. */
  42963. export class OculusTouchController extends WebVRController {
  42964. /**
  42965. * Base Url for the controller model.
  42966. */
  42967. static MODEL_BASE_URL: string;
  42968. /**
  42969. * File name for the left controller model.
  42970. */
  42971. static MODEL_LEFT_FILENAME: string;
  42972. /**
  42973. * File name for the right controller model.
  42974. */
  42975. static MODEL_RIGHT_FILENAME: string;
  42976. /**
  42977. * Base Url for the Quest controller model.
  42978. */
  42979. static QUEST_MODEL_BASE_URL: string;
  42980. /**
  42981. * @hidden
  42982. * If the controllers are running on a device that needs the updated Quest controller models
  42983. */
  42984. static _IsQuest: boolean;
  42985. /**
  42986. * Fired when the secondary trigger on this controller is modified
  42987. */
  42988. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42989. /**
  42990. * Fired when the thumb rest on this controller is modified
  42991. */
  42992. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42993. /**
  42994. * Creates a new OculusTouchController from a gamepad
  42995. * @param vrGamepad the gamepad that the controller should be created from
  42996. */
  42997. constructor(vrGamepad: any);
  42998. /**
  42999. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43000. * @param scene scene in which to add meshes
  43001. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43002. */
  43003. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43004. /**
  43005. * Fired when the A button on this controller is modified
  43006. */
  43007. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43008. /**
  43009. * Fired when the B button on this controller is modified
  43010. */
  43011. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43012. /**
  43013. * Fired when the X button on this controller is modified
  43014. */
  43015. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43016. /**
  43017. * Fired when the Y button on this controller is modified
  43018. */
  43019. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43020. /**
  43021. * Called once for each button that changed state since the last frame
  43022. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43023. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43024. * 2) secondary trigger (same)
  43025. * 3) A (right) X (left), touch, pressed = value
  43026. * 4) B / Y
  43027. * 5) thumb rest
  43028. * @param buttonIdx Which button index changed
  43029. * @param state New state of the button
  43030. * @param changes Which properties on the state changed since last frame
  43031. */
  43032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43033. }
  43034. }
  43035. declare module BABYLON {
  43036. /**
  43037. * Vive Controller
  43038. */
  43039. export class ViveController extends WebVRController {
  43040. /**
  43041. * Base Url for the controller model.
  43042. */
  43043. static MODEL_BASE_URL: string;
  43044. /**
  43045. * File name for the controller model.
  43046. */
  43047. static MODEL_FILENAME: string;
  43048. /**
  43049. * Creates a new ViveController from a gamepad
  43050. * @param vrGamepad the gamepad that the controller should be created from
  43051. */
  43052. constructor(vrGamepad: any);
  43053. /**
  43054. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43055. * @param scene scene in which to add meshes
  43056. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43057. */
  43058. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43059. /**
  43060. * Fired when the left button on this controller is modified
  43061. */
  43062. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43063. /**
  43064. * Fired when the right button on this controller is modified
  43065. */
  43066. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43067. /**
  43068. * Fired when the menu button on this controller is modified
  43069. */
  43070. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43071. /**
  43072. * Called once for each button that changed state since the last frame
  43073. * Vive mapping:
  43074. * 0: touchpad
  43075. * 1: trigger
  43076. * 2: left AND right buttons
  43077. * 3: menu button
  43078. * @param buttonIdx Which button index changed
  43079. * @param state New state of the button
  43080. * @param changes Which properties on the state changed since last frame
  43081. */
  43082. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43083. }
  43084. }
  43085. declare module BABYLON {
  43086. /**
  43087. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43088. */
  43089. export class WebXRControllerModelLoader {
  43090. /**
  43091. * an observable that triggers when a new model (the mesh itself) was initialized.
  43092. * To know when the mesh was loaded use the controller's own modelLoaded() method
  43093. */
  43094. onControllerModelLoaded: Observable<WebXRController>;
  43095. /**
  43096. * Creates the WebXRControllerModelLoader
  43097. * @param input xr input that creates the controllers
  43098. */
  43099. constructor(input: WebXRInput);
  43100. }
  43101. }
  43102. declare module BABYLON {
  43103. /**
  43104. * Handles pointer input automatically for the pointer of XR controllers
  43105. */
  43106. export class WebXRControllerPointerSelection {
  43107. private static _idCounter;
  43108. private _tmpRay;
  43109. /**
  43110. * Creates a WebXRControllerPointerSelection
  43111. * @param input input manager to setup pointer selection
  43112. */
  43113. constructor(input: WebXRInput);
  43114. private _convertNormalToDirectionOfRay;
  43115. private _updatePointerDistance;
  43116. }
  43117. }
  43118. declare module BABYLON {
  43119. /**
  43120. * Enables teleportation
  43121. */
  43122. export class WebXRControllerTeleportation {
  43123. private _teleportationFillColor;
  43124. private _teleportationBorderColor;
  43125. private _tmpRay;
  43126. private _tmpVector;
  43127. /**
  43128. * when set to true (default) teleportation will wait for thumbstick changes.
  43129. * When set to false teleportation will be disabled.
  43130. *
  43131. * If set to false while teleporting results can be unexpected.
  43132. */
  43133. enabled: boolean;
  43134. /**
  43135. * Creates a WebXRControllerTeleportation
  43136. * @param input input manager to add teleportation to
  43137. * @param floorMeshes floormeshes which can be teleported to
  43138. */
  43139. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43140. }
  43141. }
  43142. declare module BABYLON {
  43143. /**
  43144. * Button which can be used to enter a different mode of XR
  43145. */
  43146. export class WebXREnterExitUIButton {
  43147. /** button element */
  43148. element: HTMLElement;
  43149. /** XR initialization options for the button */
  43150. sessionMode: XRSessionMode;
  43151. /** Reference space type */
  43152. referenceSpaceType: XRReferenceSpaceType;
  43153. /**
  43154. * Creates a WebXREnterExitUIButton
  43155. * @param element button element
  43156. * @param sessionMode XR initialization session mode
  43157. * @param referenceSpaceType the type of reference space to be used
  43158. */
  43159. constructor(
  43160. /** button element */
  43161. element: HTMLElement,
  43162. /** XR initialization options for the button */
  43163. sessionMode: XRSessionMode,
  43164. /** Reference space type */
  43165. referenceSpaceType: XRReferenceSpaceType);
  43166. /**
  43167. * Overwritable function which can be used to update the button's visuals when the state changes
  43168. * @param activeButton the current active button in the UI
  43169. */
  43170. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43171. }
  43172. /**
  43173. * Options to create the webXR UI
  43174. */
  43175. export class WebXREnterExitUIOptions {
  43176. /**
  43177. * Context to enter xr with
  43178. */
  43179. renderTarget?: Nullable<WebXRRenderTarget>;
  43180. /**
  43181. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43182. */
  43183. customButtons?: Array<WebXREnterExitUIButton>;
  43184. /**
  43185. * A session mode to use when creating the default button.
  43186. * Default is immersive-vr
  43187. */
  43188. sessionMode?: XRSessionMode;
  43189. /**
  43190. * A reference space type to use when creating the default button.
  43191. * Default is local-floor
  43192. */
  43193. referenceSpaceType?: XRReferenceSpaceType;
  43194. }
  43195. /**
  43196. * UI to allow the user to enter/exit XR mode
  43197. */
  43198. export class WebXREnterExitUI implements IDisposable {
  43199. private scene;
  43200. /** version of the options passed to this UI */
  43201. options: WebXREnterExitUIOptions;
  43202. private _overlay;
  43203. private _buttons;
  43204. private _activeButton;
  43205. /**
  43206. * Fired every time the active button is changed.
  43207. *
  43208. * When xr is entered via a button that launches xr that button will be the callback parameter
  43209. *
  43210. * When exiting xr the callback parameter will be null)
  43211. */
  43212. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43213. /**
  43214. * Creates UI to allow the user to enter/exit XR mode
  43215. * @param scene the scene to add the ui to
  43216. * @param helper the xr experience helper to enter/exit xr with
  43217. * @param options options to configure the UI
  43218. * @returns the created ui
  43219. */
  43220. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43221. /**
  43222. *
  43223. * @param scene babylon scene object to use
  43224. * @param options (read-only) version of the options passed to this UI
  43225. */
  43226. private constructor();
  43227. private _updateButtons;
  43228. /**
  43229. * Disposes of the object
  43230. */
  43231. dispose(): void;
  43232. }
  43233. }
  43234. declare module BABYLON {
  43235. /**
  43236. * Options for the default xr helper
  43237. */
  43238. export class WebXRDefaultExperienceOptions {
  43239. /**
  43240. * Floor meshes that should be used for teleporting
  43241. */
  43242. floorMeshes: Array<AbstractMesh>;
  43243. /**
  43244. * Enable or disable default UI to enter XR
  43245. */
  43246. disableDefaultUI?: boolean;
  43247. /**
  43248. * optional configuration for the output canvas
  43249. */
  43250. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43251. /**
  43252. * optional UI options. This can be used among other to change session mode and reference space type
  43253. */
  43254. uiOptions?: WebXREnterExitUIOptions;
  43255. }
  43256. /**
  43257. * Default experience which provides a similar setup to the previous webVRExperience
  43258. */
  43259. export class WebXRDefaultExperience {
  43260. /**
  43261. * Base experience
  43262. */
  43263. baseExperience: WebXRExperienceHelper;
  43264. /**
  43265. * Input experience extension
  43266. */
  43267. input: WebXRInput;
  43268. /**
  43269. * Loads the controller models
  43270. */
  43271. controllerModelLoader: WebXRControllerModelLoader;
  43272. /**
  43273. * Enables laser pointer and selection
  43274. */
  43275. pointerSelection: WebXRControllerPointerSelection;
  43276. /**
  43277. * Enables teleportation
  43278. */
  43279. teleportation: WebXRControllerTeleportation;
  43280. /**
  43281. * Enables ui for entering/exiting xr
  43282. */
  43283. enterExitUI: WebXREnterExitUI;
  43284. /**
  43285. * Default target xr should render to
  43286. */
  43287. renderTarget: WebXRRenderTarget;
  43288. /**
  43289. * Creates the default xr experience
  43290. * @param scene scene
  43291. * @param options options for basic configuration
  43292. * @returns resulting WebXRDefaultExperience
  43293. */
  43294. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43295. private constructor();
  43296. /**
  43297. * DIsposes of the experience helper
  43298. */
  43299. dispose(): void;
  43300. }
  43301. }
  43302. declare module BABYLON {
  43303. /**
  43304. * Options to modify the vr teleportation behavior.
  43305. */
  43306. export interface VRTeleportationOptions {
  43307. /**
  43308. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43309. */
  43310. floorMeshName?: string;
  43311. /**
  43312. * A list of meshes to be used as the teleportation floor. (default: empty)
  43313. */
  43314. floorMeshes?: Mesh[];
  43315. /**
  43316. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43317. */
  43318. teleportationMode?: number;
  43319. /**
  43320. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43321. */
  43322. teleportationTime?: number;
  43323. /**
  43324. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43325. */
  43326. teleportationSpeed?: number;
  43327. /**
  43328. * The easing function used in the animation or null for Linear. (default CircleEase)
  43329. */
  43330. easingFunction?: EasingFunction;
  43331. }
  43332. /**
  43333. * Options to modify the vr experience helper's behavior.
  43334. */
  43335. export interface VRExperienceHelperOptions extends WebVROptions {
  43336. /**
  43337. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43338. */
  43339. createDeviceOrientationCamera?: boolean;
  43340. /**
  43341. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43342. */
  43343. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43344. /**
  43345. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43346. */
  43347. laserToggle?: boolean;
  43348. /**
  43349. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43350. */
  43351. floorMeshes?: Mesh[];
  43352. /**
  43353. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43354. */
  43355. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43356. /**
  43357. * Defines if WebXR should be used instead of WebVR (if available)
  43358. */
  43359. useXR?: boolean;
  43360. }
  43361. /**
  43362. * Event containing information after VR has been entered
  43363. */
  43364. export class OnAfterEnteringVRObservableEvent {
  43365. /**
  43366. * If entering vr was successful
  43367. */
  43368. success: boolean;
  43369. }
  43370. /**
  43371. * Helps to quickly add VR support to an existing scene.
  43372. * See http://doc.babylonjs.com/how_to/webvr_helper
  43373. */
  43374. export class VRExperienceHelper {
  43375. /** Options to modify the vr experience helper's behavior. */
  43376. webVROptions: VRExperienceHelperOptions;
  43377. private _scene;
  43378. private _position;
  43379. private _btnVR;
  43380. private _btnVRDisplayed;
  43381. private _webVRsupported;
  43382. private _webVRready;
  43383. private _webVRrequesting;
  43384. private _webVRpresenting;
  43385. private _hasEnteredVR;
  43386. private _fullscreenVRpresenting;
  43387. private _inputElement;
  43388. private _webVRCamera;
  43389. private _vrDeviceOrientationCamera;
  43390. private _deviceOrientationCamera;
  43391. private _existingCamera;
  43392. private _onKeyDown;
  43393. private _onVrDisplayPresentChange;
  43394. private _onVRDisplayChanged;
  43395. private _onVRRequestPresentStart;
  43396. private _onVRRequestPresentComplete;
  43397. /**
  43398. * 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)
  43399. */
  43400. enableGazeEvenWhenNoPointerLock: boolean;
  43401. /**
  43402. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43403. */
  43404. exitVROnDoubleTap: boolean;
  43405. /**
  43406. * Observable raised right before entering VR.
  43407. */
  43408. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43409. /**
  43410. * Observable raised when entering VR has completed.
  43411. */
  43412. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43413. /**
  43414. * Observable raised when exiting VR.
  43415. */
  43416. onExitingVRObservable: Observable<VRExperienceHelper>;
  43417. /**
  43418. * Observable raised when controller mesh is loaded.
  43419. */
  43420. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43421. /** Return this.onEnteringVRObservable
  43422. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43423. */
  43424. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43425. /** Return this.onExitingVRObservable
  43426. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43427. */
  43428. readonly onExitingVR: Observable<VRExperienceHelper>;
  43429. /** Return this.onControllerMeshLoadedObservable
  43430. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43431. */
  43432. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43433. private _rayLength;
  43434. private _useCustomVRButton;
  43435. private _teleportationRequested;
  43436. private _teleportActive;
  43437. private _floorMeshName;
  43438. private _floorMeshesCollection;
  43439. private _teleportationMode;
  43440. private _teleportationTime;
  43441. private _teleportationSpeed;
  43442. private _teleportationEasing;
  43443. private _rotationAllowed;
  43444. private _teleportBackwardsVector;
  43445. private _teleportationTarget;
  43446. private _isDefaultTeleportationTarget;
  43447. private _postProcessMove;
  43448. private _teleportationFillColor;
  43449. private _teleportationBorderColor;
  43450. private _rotationAngle;
  43451. private _haloCenter;
  43452. private _cameraGazer;
  43453. private _padSensibilityUp;
  43454. private _padSensibilityDown;
  43455. private _leftController;
  43456. private _rightController;
  43457. /**
  43458. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43459. */
  43460. onNewMeshSelected: Observable<AbstractMesh>;
  43461. /**
  43462. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43463. * This observable will provide the mesh and the controller used to select the mesh
  43464. */
  43465. onMeshSelectedWithController: Observable<{
  43466. mesh: AbstractMesh;
  43467. controller: WebVRController;
  43468. }>;
  43469. /**
  43470. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43471. */
  43472. onNewMeshPicked: Observable<PickingInfo>;
  43473. private _circleEase;
  43474. /**
  43475. * Observable raised before camera teleportation
  43476. */
  43477. onBeforeCameraTeleport: Observable<Vector3>;
  43478. /**
  43479. * Observable raised after camera teleportation
  43480. */
  43481. onAfterCameraTeleport: Observable<Vector3>;
  43482. /**
  43483. * Observable raised when current selected mesh gets unselected
  43484. */
  43485. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43486. private _raySelectionPredicate;
  43487. /**
  43488. * To be optionaly changed by user to define custom ray selection
  43489. */
  43490. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43491. /**
  43492. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43493. */
  43494. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43495. /**
  43496. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43497. */
  43498. teleportationEnabled: boolean;
  43499. private _defaultHeight;
  43500. private _teleportationInitialized;
  43501. private _interactionsEnabled;
  43502. private _interactionsRequested;
  43503. private _displayGaze;
  43504. private _displayLaserPointer;
  43505. /**
  43506. * The mesh used to display where the user is going to teleport.
  43507. */
  43508. /**
  43509. * Sets the mesh to be used to display where the user is going to teleport.
  43510. */
  43511. teleportationTarget: Mesh;
  43512. /**
  43513. * 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
  43514. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43515. * See http://doc.babylonjs.com/resources/baking_transformations
  43516. */
  43517. gazeTrackerMesh: Mesh;
  43518. /**
  43519. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43520. */
  43521. updateGazeTrackerScale: boolean;
  43522. /**
  43523. * If the gaze trackers color should be updated when selecting meshes
  43524. */
  43525. updateGazeTrackerColor: boolean;
  43526. /**
  43527. * If the controller laser color should be updated when selecting meshes
  43528. */
  43529. updateControllerLaserColor: boolean;
  43530. /**
  43531. * The gaze tracking mesh corresponding to the left controller
  43532. */
  43533. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43534. /**
  43535. * The gaze tracking mesh corresponding to the right controller
  43536. */
  43537. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43538. /**
  43539. * If the ray of the gaze should be displayed.
  43540. */
  43541. /**
  43542. * Sets if the ray of the gaze should be displayed.
  43543. */
  43544. displayGaze: boolean;
  43545. /**
  43546. * If the ray of the LaserPointer should be displayed.
  43547. */
  43548. /**
  43549. * Sets if the ray of the LaserPointer should be displayed.
  43550. */
  43551. displayLaserPointer: boolean;
  43552. /**
  43553. * The deviceOrientationCamera used as the camera when not in VR.
  43554. */
  43555. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43556. /**
  43557. * Based on the current WebVR support, returns the current VR camera used.
  43558. */
  43559. readonly currentVRCamera: Nullable<Camera>;
  43560. /**
  43561. * The webVRCamera which is used when in VR.
  43562. */
  43563. readonly webVRCamera: WebVRFreeCamera;
  43564. /**
  43565. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43566. */
  43567. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43568. /**
  43569. * The html button that is used to trigger entering into VR.
  43570. */
  43571. readonly vrButton: Nullable<HTMLButtonElement>;
  43572. private readonly _teleportationRequestInitiated;
  43573. /**
  43574. * Defines wether or not Pointer lock should be requested when switching to
  43575. * full screen.
  43576. */
  43577. requestPointerLockOnFullScreen: boolean;
  43578. /**
  43579. * If asking to force XR, this will be populated with the default xr experience
  43580. */
  43581. xr: WebXRDefaultExperience;
  43582. /**
  43583. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  43584. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  43585. */
  43586. xrTestDone: boolean;
  43587. /**
  43588. * Instantiates a VRExperienceHelper.
  43589. * Helps to quickly add VR support to an existing scene.
  43590. * @param scene The scene the VRExperienceHelper belongs to.
  43591. * @param webVROptions Options to modify the vr experience helper's behavior.
  43592. */
  43593. constructor(scene: Scene,
  43594. /** Options to modify the vr experience helper's behavior. */
  43595. webVROptions?: VRExperienceHelperOptions);
  43596. private completeVRInit;
  43597. private _onDefaultMeshLoaded;
  43598. private _onResize;
  43599. private _onFullscreenChange;
  43600. /**
  43601. * Gets a value indicating if we are currently in VR mode.
  43602. */
  43603. readonly isInVRMode: boolean;
  43604. private onVrDisplayPresentChange;
  43605. private onVRDisplayChanged;
  43606. private moveButtonToBottomRight;
  43607. private displayVRButton;
  43608. private updateButtonVisibility;
  43609. private _cachedAngularSensibility;
  43610. /**
  43611. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43612. * Otherwise, will use the fullscreen API.
  43613. */
  43614. enterVR(): void;
  43615. /**
  43616. * Attempt to exit VR, or fullscreen.
  43617. */
  43618. exitVR(): void;
  43619. /**
  43620. * The position of the vr experience helper.
  43621. */
  43622. /**
  43623. * Sets the position of the vr experience helper.
  43624. */
  43625. position: Vector3;
  43626. /**
  43627. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43628. */
  43629. enableInteractions(): void;
  43630. private readonly _noControllerIsActive;
  43631. private beforeRender;
  43632. private _isTeleportationFloor;
  43633. /**
  43634. * Adds a floor mesh to be used for teleportation.
  43635. * @param floorMesh the mesh to be used for teleportation.
  43636. */
  43637. addFloorMesh(floorMesh: Mesh): void;
  43638. /**
  43639. * Removes a floor mesh from being used for teleportation.
  43640. * @param floorMesh the mesh to be removed.
  43641. */
  43642. removeFloorMesh(floorMesh: Mesh): void;
  43643. /**
  43644. * Enables interactions and teleportation using the VR controllers and gaze.
  43645. * @param vrTeleportationOptions options to modify teleportation behavior.
  43646. */
  43647. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43648. private _onNewGamepadConnected;
  43649. private _tryEnableInteractionOnController;
  43650. private _onNewGamepadDisconnected;
  43651. private _enableInteractionOnController;
  43652. private _checkTeleportWithRay;
  43653. private _checkRotate;
  43654. private _checkTeleportBackwards;
  43655. private _enableTeleportationOnController;
  43656. private _createTeleportationCircles;
  43657. private _displayTeleportationTarget;
  43658. private _hideTeleportationTarget;
  43659. private _rotateCamera;
  43660. private _moveTeleportationSelectorTo;
  43661. private _workingVector;
  43662. private _workingQuaternion;
  43663. private _workingMatrix;
  43664. /**
  43665. * Time Constant Teleportation Mode
  43666. */
  43667. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  43668. /**
  43669. * Speed Constant Teleportation Mode
  43670. */
  43671. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  43672. /**
  43673. * Teleports the users feet to the desired location
  43674. * @param location The location where the user's feet should be placed
  43675. */
  43676. teleportCamera(location: Vector3): void;
  43677. private _convertNormalToDirectionOfRay;
  43678. private _castRayAndSelectObject;
  43679. private _notifySelectedMeshUnselected;
  43680. /**
  43681. * Sets the color of the laser ray from the vr controllers.
  43682. * @param color new color for the ray.
  43683. */
  43684. changeLaserColor(color: Color3): void;
  43685. /**
  43686. * Sets the color of the ray from the vr headsets gaze.
  43687. * @param color new color for the ray.
  43688. */
  43689. changeGazeColor(color: Color3): void;
  43690. /**
  43691. * Exits VR and disposes of the vr experience helper
  43692. */
  43693. dispose(): void;
  43694. /**
  43695. * Gets the name of the VRExperienceHelper class
  43696. * @returns "VRExperienceHelper"
  43697. */
  43698. getClassName(): string;
  43699. }
  43700. }
  43701. declare module BABYLON {
  43702. /**
  43703. * Options used for hit testing
  43704. */
  43705. export interface IWebXRHitTestOptions {
  43706. /**
  43707. * Only test when user interacted with the scene. Default - hit test every frame
  43708. */
  43709. testOnPointerDownOnly?: boolean;
  43710. /**
  43711. * The node to use to transform the local results to world coordinates
  43712. */
  43713. worldParentNode?: TransformNode;
  43714. }
  43715. /**
  43716. * Interface defining the babylon result of raycasting/hit-test
  43717. */
  43718. export interface IWebXRHitResult {
  43719. /**
  43720. * The native hit test result
  43721. */
  43722. xrHitResult: XRHitResult;
  43723. /**
  43724. * Transformation matrix that can be applied to a node that will put it in the hit point location
  43725. */
  43726. transformationMatrix: Matrix;
  43727. }
  43728. /**
  43729. * The currently-working hit-test module.
  43730. * Hit test (or raycasting) is used to interact with the real world.
  43731. * For further information read here - https://github.com/immersive-web/hit-test
  43732. */
  43733. export class WebXRHitTestLegacy implements IWebXRFeature {
  43734. private _xrSessionManager;
  43735. /**
  43736. * options to use when constructing this feature
  43737. */
  43738. readonly options: IWebXRHitTestOptions;
  43739. /**
  43740. * The module's name
  43741. */
  43742. static readonly Name: string;
  43743. /**
  43744. * The (Babylon) version of this module.
  43745. * This is an integer representing the implementation version.
  43746. * This number does not correspond to the webxr specs version
  43747. */
  43748. static readonly Version: number;
  43749. /**
  43750. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  43751. * @param event the (select) event to use to select with
  43752. * @param referenceSpace the reference space to use for this hit test
  43753. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  43754. */
  43755. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  43756. /**
  43757. * execute a hit test with an XR Ray
  43758. *
  43759. * @param xrSession a native xrSession that will execute this hit test
  43760. * @param xrRay the ray (position and direction) to use for raycasting
  43761. * @param referenceSpace native XR reference space to use for the hit-test
  43762. * @param filter filter function that will filter the results
  43763. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  43764. */
  43765. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  43766. /**
  43767. * Triggered when new babylon (transformed) hit test results are available
  43768. */
  43769. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  43770. /**
  43771. * Creates a new instance of the (legacy version) hit test feature
  43772. * @param _xrSessionManager an instance of WebXRSessionManager
  43773. * @param options options to use when constructing this feature
  43774. */
  43775. constructor(_xrSessionManager: WebXRSessionManager,
  43776. /**
  43777. * options to use when constructing this feature
  43778. */
  43779. options?: IWebXRHitTestOptions);
  43780. private _onSelectEnabled;
  43781. private _xrFrameObserver;
  43782. private _attached;
  43783. /**
  43784. * Populated with the last native XR Hit Results
  43785. */
  43786. lastNativeXRHitResults: XRHitResult[];
  43787. /**
  43788. * attach this feature
  43789. * Will usually be called by the features manager
  43790. *
  43791. * @returns true if successful.
  43792. */
  43793. attach(): boolean;
  43794. /**
  43795. * detach this feature.
  43796. * Will usually be called by the features manager
  43797. *
  43798. * @returns true if successful.
  43799. */
  43800. detach(): boolean;
  43801. private _onHitTestResults;
  43802. private _onSelect;
  43803. /**
  43804. * Dispose this feature and all of the resources attached
  43805. */
  43806. dispose(): void;
  43807. }
  43808. }
  43809. declare module BABYLON {
  43810. /**
  43811. * Options used in the plane detector module
  43812. */
  43813. export interface IWebXRPlaneDetectorOptions {
  43814. /**
  43815. * The node to use to transform the local results to world coordinates
  43816. */
  43817. worldParentNode?: TransformNode;
  43818. }
  43819. /**
  43820. * A babylon interface for a webxr plane.
  43821. * A Plane is actually a polygon, built from N points in space
  43822. */
  43823. export interface IWebXRPlane {
  43824. /**
  43825. * a babylon-assigned ID for this polygon
  43826. */
  43827. id: number;
  43828. /**
  43829. * the native xr-plane object
  43830. */
  43831. xrPlane: XRPlane;
  43832. /**
  43833. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  43834. */
  43835. polygonDefinition: Array<Vector3>;
  43836. /**
  43837. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  43838. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  43839. */
  43840. transformationMatrix: Matrix;
  43841. }
  43842. /**
  43843. * The plane detector is used to detect planes in the real world when in AR
  43844. * For more information see https://github.com/immersive-web/real-world-geometry/
  43845. */
  43846. export class WebXRPlaneDetector implements IWebXRFeature {
  43847. private _xrSessionManager;
  43848. private _options;
  43849. /**
  43850. * The module's name
  43851. */
  43852. static readonly Name: string;
  43853. /**
  43854. * The (Babylon) version of this module.
  43855. * This is an integer representing the implementation version.
  43856. * This number does not correspond to the webxr specs version
  43857. */
  43858. static readonly Version: number;
  43859. /**
  43860. * Observers registered here will be executed when a new plane was added to the session
  43861. */
  43862. onPlaneAddedObservable: Observable<IWebXRPlane>;
  43863. /**
  43864. * Observers registered here will be executed when a plane is no longer detected in the session
  43865. */
  43866. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  43867. /**
  43868. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  43869. * This can execute N times every frame
  43870. */
  43871. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  43872. private _enabled;
  43873. private _attached;
  43874. private _detectedPlanes;
  43875. private _lastFrameDetected;
  43876. private _observerTracked;
  43877. /**
  43878. * construct a new Plane Detector
  43879. * @param _xrSessionManager an instance of xr Session manager
  43880. * @param _options configuration to use when constructing this feature
  43881. */
  43882. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  43883. /**
  43884. * attach this feature
  43885. * Will usually be called by the features manager
  43886. *
  43887. * @returns true if successful.
  43888. */
  43889. attach(): boolean;
  43890. /**
  43891. * detach this feature.
  43892. * Will usually be called by the features manager
  43893. *
  43894. * @returns true if successful.
  43895. */
  43896. detach(): boolean;
  43897. /**
  43898. * Dispose this feature and all of the resources attached
  43899. */
  43900. dispose(): void;
  43901. private _updatePlaneWithXRPlane;
  43902. /**
  43903. * avoiding using Array.find for global support.
  43904. * @param xrPlane the plane to find in the array
  43905. */
  43906. private findIndexInPlaneArray;
  43907. }
  43908. }
  43909. declare module BABYLON {
  43910. /**
  43911. * Configuration options of the anchor system
  43912. */
  43913. export interface IWebXRAnchorSystemOptions {
  43914. /**
  43915. * a node that will be used to convert local to world coordinates
  43916. */
  43917. worldParentNode?: TransformNode;
  43918. /**
  43919. * should the anchor system use plane detection.
  43920. * If set to true, the plane-detection feature should be set using setPlaneDetector
  43921. */
  43922. usePlaneDetection?: boolean;
  43923. /**
  43924. * Should a new anchor be added every time a select event is triggered
  43925. */
  43926. addAnchorOnSelect?: boolean;
  43927. }
  43928. /**
  43929. * A babylon container for an XR Anchor
  43930. */
  43931. export interface IWebXRAnchor {
  43932. /**
  43933. * A babylon-assigned ID for this anchor
  43934. */
  43935. id: number;
  43936. /**
  43937. * The native anchor object
  43938. */
  43939. xrAnchor: XRAnchor;
  43940. /**
  43941. * Transformation matrix to apply to an object attached to this anchor
  43942. */
  43943. transformationMatrix: Matrix;
  43944. }
  43945. /**
  43946. * An implementation of the anchor system of WebXR.
  43947. * Note that the current documented implementation is not available in any browser. Future implementations
  43948. * will use the frame to create an anchor and not the session or a detected plane
  43949. * For further information see https://github.com/immersive-web/anchors/
  43950. */
  43951. export class WebXRAnchorSystem implements IWebXRFeature {
  43952. private _xrSessionManager;
  43953. private _options;
  43954. /**
  43955. * The module's name
  43956. */
  43957. static readonly Name: string;
  43958. /**
  43959. * The (Babylon) version of this module.
  43960. * This is an integer representing the implementation version.
  43961. * This number does not correspond to the webxr specs version
  43962. */
  43963. static readonly Version: number;
  43964. /**
  43965. * Observers registered here will be executed when a new anchor was added to the session
  43966. */
  43967. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  43968. /**
  43969. * Observers registered here will be executed when an existing anchor updates
  43970. * This can execute N times every frame
  43971. */
  43972. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  43973. /**
  43974. * Observers registered here will be executed when an anchor was removed from the session
  43975. */
  43976. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  43977. private _planeDetector;
  43978. private _hitTestModule;
  43979. private _enabled;
  43980. private _attached;
  43981. private _trackedAnchors;
  43982. private _lastFrameDetected;
  43983. private _observerTracked;
  43984. /**
  43985. * constructs a new anchor system
  43986. * @param _xrSessionManager an instance of WebXRSessionManager
  43987. * @param _options configuration object for this feature
  43988. */
  43989. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  43990. /**
  43991. * set the plane detector to use in order to create anchors from frames
  43992. * @param planeDetector the plane-detector module to use
  43993. * @param enable enable plane-anchors. default is true
  43994. */
  43995. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  43996. /**
  43997. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  43998. * @param hitTestModule the hit-test module to use.
  43999. */
  44000. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  44001. /**
  44002. * attach this feature
  44003. * Will usually be called by the features manager
  44004. *
  44005. * @returns true if successful.
  44006. */
  44007. attach(): boolean;
  44008. /**
  44009. * detach this feature.
  44010. * Will usually be called by the features manager
  44011. *
  44012. * @returns true if successful.
  44013. */
  44014. detach(): boolean;
  44015. /**
  44016. * Dispose this feature and all of the resources attached
  44017. */
  44018. dispose(): void;
  44019. private _onSelect;
  44020. /**
  44021. * Add anchor at a specific XR point.
  44022. *
  44023. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  44024. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  44025. * @returns a promise the fulfills when the anchor was created
  44026. */
  44027. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  44028. private _updateAnchorWithXRFrame;
  44029. /**
  44030. * avoiding using Array.find for global support.
  44031. * @param xrAnchor the plane to find in the array
  44032. */
  44033. private _findIndexInAnchorArray;
  44034. }
  44035. }
  44036. declare module BABYLON {
  44037. /**
  44038. * Options interface for the background remover plugin
  44039. */
  44040. export interface IWebXRBackgroundRemoverOptions {
  44041. /**
  44042. * don't disable the environment helper
  44043. */
  44044. ignoreEnvironmentHelper?: boolean;
  44045. /**
  44046. * flags to configure the removal of the environment helper.
  44047. * If not set, the entire background will be removed. If set, flags should be set as well.
  44048. */
  44049. environmentHelperRemovalFlags?: {
  44050. /**
  44051. * Should the skybox be removed (default false)
  44052. */
  44053. skyBox?: boolean;
  44054. /**
  44055. * Should the ground be removed (default false)
  44056. */
  44057. ground?: boolean;
  44058. };
  44059. /**
  44060. * Further background meshes to disable when entering AR
  44061. */
  44062. backgroundMeshes?: AbstractMesh[];
  44063. }
  44064. /**
  44065. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  44066. */
  44067. export class WebXRBackgroundRemover implements IWebXRFeature {
  44068. private _xrSessionManager;
  44069. /**
  44070. * read-only options to be used in this module
  44071. */
  44072. readonly options: IWebXRBackgroundRemoverOptions;
  44073. /**
  44074. * The module's name
  44075. */
  44076. static readonly Name: string;
  44077. /**
  44078. * The (Babylon) version of this module.
  44079. * This is an integer representing the implementation version.
  44080. * This number does not correspond to the webxr specs version
  44081. */
  44082. static readonly Version: number;
  44083. /**
  44084. * registered observers will be triggered when the background state changes
  44085. */
  44086. onBackgroundStateChangedObservable: Observable<boolean>;
  44087. /**
  44088. * constructs a new background remover module
  44089. * @param _xrSessionManager the session manager for this module
  44090. * @param options read-only options to be used in this module
  44091. */
  44092. constructor(_xrSessionManager: WebXRSessionManager,
  44093. /**
  44094. * read-only options to be used in this module
  44095. */
  44096. options?: IWebXRBackgroundRemoverOptions);
  44097. /**
  44098. * attach this feature
  44099. * Will usually be called by the features manager
  44100. *
  44101. * @returns true if successful.
  44102. */
  44103. attach(): boolean;
  44104. /**
  44105. * detach this feature.
  44106. * Will usually be called by the features manager
  44107. *
  44108. * @returns true if successful.
  44109. */
  44110. detach(): boolean;
  44111. private _setBackgroundState;
  44112. /**
  44113. * Dispose this feature and all of the resources attached
  44114. */
  44115. dispose(): void;
  44116. }
  44117. }
  44118. declare module BABYLON {
  44119. /**
  44120. * Contains an array of blocks representing the octree
  44121. */
  44122. export interface IOctreeContainer<T> {
  44123. /**
  44124. * Blocks within the octree
  44125. */
  44126. blocks: Array<OctreeBlock<T>>;
  44127. }
  44128. /**
  44129. * Class used to store a cell in an octree
  44130. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44131. */
  44132. export class OctreeBlock<T> {
  44133. /**
  44134. * Gets the content of the current block
  44135. */
  44136. entries: T[];
  44137. /**
  44138. * Gets the list of block children
  44139. */
  44140. blocks: Array<OctreeBlock<T>>;
  44141. private _depth;
  44142. private _maxDepth;
  44143. private _capacity;
  44144. private _minPoint;
  44145. private _maxPoint;
  44146. private _boundingVectors;
  44147. private _creationFunc;
  44148. /**
  44149. * Creates a new block
  44150. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44151. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44152. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44153. * @param depth defines the current depth of this block in the octree
  44154. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44155. * @param creationFunc defines a callback to call when an element is added to the block
  44156. */
  44157. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44158. /**
  44159. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44160. */
  44161. readonly capacity: number;
  44162. /**
  44163. * Gets the minimum vector (in world space) of the block's bounding box
  44164. */
  44165. readonly minPoint: Vector3;
  44166. /**
  44167. * Gets the maximum vector (in world space) of the block's bounding box
  44168. */
  44169. readonly maxPoint: Vector3;
  44170. /**
  44171. * Add a new element to this block
  44172. * @param entry defines the element to add
  44173. */
  44174. addEntry(entry: T): void;
  44175. /**
  44176. * Remove an element from this block
  44177. * @param entry defines the element to remove
  44178. */
  44179. removeEntry(entry: T): void;
  44180. /**
  44181. * Add an array of elements to this block
  44182. * @param entries defines the array of elements to add
  44183. */
  44184. addEntries(entries: T[]): void;
  44185. /**
  44186. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44187. * @param frustumPlanes defines the frustum planes to test
  44188. * @param selection defines the array to store current content if selection is positive
  44189. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44190. */
  44191. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44192. /**
  44193. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44194. * @param sphereCenter defines the bounding sphere center
  44195. * @param sphereRadius defines the bounding sphere radius
  44196. * @param selection defines the array to store current content if selection is positive
  44197. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44198. */
  44199. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44200. /**
  44201. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44202. * @param ray defines the ray to test with
  44203. * @param selection defines the array to store current content if selection is positive
  44204. */
  44205. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44206. /**
  44207. * Subdivide the content into child blocks (this block will then be empty)
  44208. */
  44209. createInnerBlocks(): void;
  44210. /**
  44211. * @hidden
  44212. */
  44213. 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;
  44214. }
  44215. }
  44216. declare module BABYLON {
  44217. /**
  44218. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44219. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44220. */
  44221. export class Octree<T> {
  44222. /** 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.) */
  44223. maxDepth: number;
  44224. /**
  44225. * Blocks within the octree containing objects
  44226. */
  44227. blocks: Array<OctreeBlock<T>>;
  44228. /**
  44229. * Content stored in the octree
  44230. */
  44231. dynamicContent: T[];
  44232. private _maxBlockCapacity;
  44233. private _selectionContent;
  44234. private _creationFunc;
  44235. /**
  44236. * Creates a octree
  44237. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44238. * @param creationFunc function to be used to instatiate the octree
  44239. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44240. * @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.)
  44241. */
  44242. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44243. /** 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.) */
  44244. maxDepth?: number);
  44245. /**
  44246. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44247. * @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);
  44248. * @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);
  44249. * @param entries meshes to be added to the octree blocks
  44250. */
  44251. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44252. /**
  44253. * Adds a mesh to the octree
  44254. * @param entry Mesh to add to the octree
  44255. */
  44256. addMesh(entry: T): void;
  44257. /**
  44258. * Remove an element from the octree
  44259. * @param entry defines the element to remove
  44260. */
  44261. removeMesh(entry: T): void;
  44262. /**
  44263. * Selects an array of meshes within the frustum
  44264. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44265. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44266. * @returns array of meshes within the frustum
  44267. */
  44268. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44269. /**
  44270. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44271. * @param sphereCenter defines the bounding sphere center
  44272. * @param sphereRadius defines the bounding sphere radius
  44273. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44274. * @returns an array of objects that intersect the sphere
  44275. */
  44276. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44277. /**
  44278. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44279. * @param ray defines the ray to test with
  44280. * @returns array of intersected objects
  44281. */
  44282. intersectsRay(ray: Ray): SmartArray<T>;
  44283. /**
  44284. * Adds a mesh into the octree block if it intersects the block
  44285. */
  44286. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44287. /**
  44288. * Adds a submesh into the octree block if it intersects the block
  44289. */
  44290. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44291. }
  44292. }
  44293. declare module BABYLON {
  44294. interface Scene {
  44295. /**
  44296. * @hidden
  44297. * Backing Filed
  44298. */
  44299. _selectionOctree: Octree<AbstractMesh>;
  44300. /**
  44301. * Gets the octree used to boost mesh selection (picking)
  44302. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44303. */
  44304. selectionOctree: Octree<AbstractMesh>;
  44305. /**
  44306. * Creates or updates the octree used to boost selection (picking)
  44307. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44308. * @param maxCapacity defines the maximum capacity per leaf
  44309. * @param maxDepth defines the maximum depth of the octree
  44310. * @returns an octree of AbstractMesh
  44311. */
  44312. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44313. }
  44314. interface AbstractMesh {
  44315. /**
  44316. * @hidden
  44317. * Backing Field
  44318. */
  44319. _submeshesOctree: Octree<SubMesh>;
  44320. /**
  44321. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44322. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44323. * @param maxCapacity defines the maximum size of each block (64 by default)
  44324. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44325. * @returns the new octree
  44326. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44327. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44328. */
  44329. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44330. }
  44331. /**
  44332. * Defines the octree scene component responsible to manage any octrees
  44333. * in a given scene.
  44334. */
  44335. export class OctreeSceneComponent {
  44336. /**
  44337. * The component name help to identify the component in the list of scene components.
  44338. */
  44339. readonly name: string;
  44340. /**
  44341. * The scene the component belongs to.
  44342. */
  44343. scene: Scene;
  44344. /**
  44345. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44346. */
  44347. readonly checksIsEnabled: boolean;
  44348. /**
  44349. * Creates a new instance of the component for the given scene
  44350. * @param scene Defines the scene to register the component in
  44351. */
  44352. constructor(scene: Scene);
  44353. /**
  44354. * Registers the component in a given scene
  44355. */
  44356. register(): void;
  44357. /**
  44358. * Return the list of active meshes
  44359. * @returns the list of active meshes
  44360. */
  44361. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44362. /**
  44363. * Return the list of active sub meshes
  44364. * @param mesh The mesh to get the candidates sub meshes from
  44365. * @returns the list of active sub meshes
  44366. */
  44367. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44368. private _tempRay;
  44369. /**
  44370. * Return the list of sub meshes intersecting with a given local ray
  44371. * @param mesh defines the mesh to find the submesh for
  44372. * @param localRay defines the ray in local space
  44373. * @returns the list of intersecting sub meshes
  44374. */
  44375. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44376. /**
  44377. * Return the list of sub meshes colliding with a collider
  44378. * @param mesh defines the mesh to find the submesh for
  44379. * @param collider defines the collider to evaluate the collision against
  44380. * @returns the list of colliding sub meshes
  44381. */
  44382. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44383. /**
  44384. * Rebuilds the elements related to this component in case of
  44385. * context lost for instance.
  44386. */
  44387. rebuild(): void;
  44388. /**
  44389. * Disposes the component and the associated ressources.
  44390. */
  44391. dispose(): void;
  44392. }
  44393. }
  44394. declare module BABYLON {
  44395. /**
  44396. * Renders a layer on top of an existing scene
  44397. */
  44398. export class UtilityLayerRenderer implements IDisposable {
  44399. /** the original scene that will be rendered on top of */
  44400. originalScene: Scene;
  44401. private _pointerCaptures;
  44402. private _lastPointerEvents;
  44403. private static _DefaultUtilityLayer;
  44404. private static _DefaultKeepDepthUtilityLayer;
  44405. private _sharedGizmoLight;
  44406. private _renderCamera;
  44407. /**
  44408. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44409. * @returns the camera that is used when rendering the utility layer
  44410. */
  44411. getRenderCamera(): Nullable<Camera>;
  44412. /**
  44413. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44414. * @param cam the camera that should be used when rendering the utility layer
  44415. */
  44416. setRenderCamera(cam: Nullable<Camera>): void;
  44417. /**
  44418. * @hidden
  44419. * Light which used by gizmos to get light shading
  44420. */
  44421. _getSharedGizmoLight(): HemisphericLight;
  44422. /**
  44423. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44424. */
  44425. pickUtilitySceneFirst: boolean;
  44426. /**
  44427. * 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)
  44428. */
  44429. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44430. /**
  44431. * 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)
  44432. */
  44433. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44434. /**
  44435. * The scene that is rendered on top of the original scene
  44436. */
  44437. utilityLayerScene: Scene;
  44438. /**
  44439. * If the utility layer should automatically be rendered on top of existing scene
  44440. */
  44441. shouldRender: boolean;
  44442. /**
  44443. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44444. */
  44445. onlyCheckPointerDownEvents: boolean;
  44446. /**
  44447. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44448. */
  44449. processAllEvents: boolean;
  44450. /**
  44451. * Observable raised when the pointer move from the utility layer scene to the main scene
  44452. */
  44453. onPointerOutObservable: Observable<number>;
  44454. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44455. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44456. private _afterRenderObserver;
  44457. private _sceneDisposeObserver;
  44458. private _originalPointerObserver;
  44459. /**
  44460. * Instantiates a UtilityLayerRenderer
  44461. * @param originalScene the original scene that will be rendered on top of
  44462. * @param handleEvents boolean indicating if the utility layer should handle events
  44463. */
  44464. constructor(
  44465. /** the original scene that will be rendered on top of */
  44466. originalScene: Scene, handleEvents?: boolean);
  44467. private _notifyObservers;
  44468. /**
  44469. * Renders the utility layers scene on top of the original scene
  44470. */
  44471. render(): void;
  44472. /**
  44473. * Disposes of the renderer
  44474. */
  44475. dispose(): void;
  44476. private _updateCamera;
  44477. }
  44478. }
  44479. declare module BABYLON {
  44480. /**
  44481. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44482. */
  44483. export class Gizmo implements IDisposable {
  44484. /** The utility layer the gizmo will be added to */
  44485. gizmoLayer: UtilityLayerRenderer;
  44486. /**
  44487. * The root mesh of the gizmo
  44488. */
  44489. _rootMesh: Mesh;
  44490. private _attachedMesh;
  44491. /**
  44492. * Ratio for the scale of the gizmo (Default: 1)
  44493. */
  44494. scaleRatio: number;
  44495. /**
  44496. * If a custom mesh has been set (Default: false)
  44497. */
  44498. protected _customMeshSet: boolean;
  44499. /**
  44500. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44501. * * When set, interactions will be enabled
  44502. */
  44503. attachedMesh: Nullable<AbstractMesh>;
  44504. /**
  44505. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44506. * @param mesh The mesh to replace the default mesh of the gizmo
  44507. */
  44508. setCustomMesh(mesh: Mesh): void;
  44509. /**
  44510. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44511. */
  44512. updateGizmoRotationToMatchAttachedMesh: boolean;
  44513. /**
  44514. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44515. */
  44516. updateGizmoPositionToMatchAttachedMesh: boolean;
  44517. /**
  44518. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44519. */
  44520. updateScale: boolean;
  44521. protected _interactionsEnabled: boolean;
  44522. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44523. private _beforeRenderObserver;
  44524. private _tempVector;
  44525. /**
  44526. * Creates a gizmo
  44527. * @param gizmoLayer The utility layer the gizmo will be added to
  44528. */
  44529. constructor(
  44530. /** The utility layer the gizmo will be added to */
  44531. gizmoLayer?: UtilityLayerRenderer);
  44532. /**
  44533. * Updates the gizmo to match the attached mesh's position/rotation
  44534. */
  44535. protected _update(): void;
  44536. /**
  44537. * Disposes of the gizmo
  44538. */
  44539. dispose(): void;
  44540. }
  44541. }
  44542. declare module BABYLON {
  44543. /**
  44544. * Single plane drag gizmo
  44545. */
  44546. export class PlaneDragGizmo extends Gizmo {
  44547. /**
  44548. * Drag behavior responsible for the gizmos dragging interactions
  44549. */
  44550. dragBehavior: PointerDragBehavior;
  44551. private _pointerObserver;
  44552. /**
  44553. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44554. */
  44555. snapDistance: number;
  44556. /**
  44557. * Event that fires each time the gizmo snaps to a new location.
  44558. * * snapDistance is the the change in distance
  44559. */
  44560. onSnapObservable: Observable<{
  44561. snapDistance: number;
  44562. }>;
  44563. private _plane;
  44564. private _coloredMaterial;
  44565. private _hoverMaterial;
  44566. private _isEnabled;
  44567. private _parent;
  44568. /** @hidden */
  44569. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44570. /** @hidden */
  44571. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44572. /**
  44573. * Creates a PlaneDragGizmo
  44574. * @param gizmoLayer The utility layer the gizmo will be added to
  44575. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44576. * @param color The color of the gizmo
  44577. */
  44578. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44579. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44580. /**
  44581. * If the gizmo is enabled
  44582. */
  44583. isEnabled: boolean;
  44584. /**
  44585. * Disposes of the gizmo
  44586. */
  44587. dispose(): void;
  44588. }
  44589. }
  44590. declare module BABYLON {
  44591. /**
  44592. * Gizmo that enables dragging a mesh along 3 axis
  44593. */
  44594. export class PositionGizmo extends Gizmo {
  44595. /**
  44596. * Internal gizmo used for interactions on the x axis
  44597. */
  44598. xGizmo: AxisDragGizmo;
  44599. /**
  44600. * Internal gizmo used for interactions on the y axis
  44601. */
  44602. yGizmo: AxisDragGizmo;
  44603. /**
  44604. * Internal gizmo used for interactions on the z axis
  44605. */
  44606. zGizmo: AxisDragGizmo;
  44607. /**
  44608. * Internal gizmo used for interactions on the yz plane
  44609. */
  44610. xPlaneGizmo: PlaneDragGizmo;
  44611. /**
  44612. * Internal gizmo used for interactions on the xz plane
  44613. */
  44614. yPlaneGizmo: PlaneDragGizmo;
  44615. /**
  44616. * Internal gizmo used for interactions on the xy plane
  44617. */
  44618. zPlaneGizmo: PlaneDragGizmo;
  44619. /**
  44620. * private variables
  44621. */
  44622. private _meshAttached;
  44623. private _updateGizmoRotationToMatchAttachedMesh;
  44624. private _snapDistance;
  44625. private _scaleRatio;
  44626. /** Fires an event when any of it's sub gizmos are dragged */
  44627. onDragStartObservable: Observable<unknown>;
  44628. /** Fires an event when any of it's sub gizmos are released from dragging */
  44629. onDragEndObservable: Observable<unknown>;
  44630. /**
  44631. * If set to true, planar drag is enabled
  44632. */
  44633. private _planarGizmoEnabled;
  44634. attachedMesh: Nullable<AbstractMesh>;
  44635. /**
  44636. * Creates a PositionGizmo
  44637. * @param gizmoLayer The utility layer the gizmo will be added to
  44638. */
  44639. constructor(gizmoLayer?: UtilityLayerRenderer);
  44640. /**
  44641. * If the planar drag gizmo is enabled
  44642. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44643. */
  44644. planarGizmoEnabled: boolean;
  44645. updateGizmoRotationToMatchAttachedMesh: boolean;
  44646. /**
  44647. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44648. */
  44649. snapDistance: number;
  44650. /**
  44651. * Ratio for the scale of the gizmo (Default: 1)
  44652. */
  44653. scaleRatio: number;
  44654. /**
  44655. * Disposes of the gizmo
  44656. */
  44657. dispose(): void;
  44658. /**
  44659. * CustomMeshes are not supported by this gizmo
  44660. * @param mesh The mesh to replace the default mesh of the gizmo
  44661. */
  44662. setCustomMesh(mesh: Mesh): void;
  44663. }
  44664. }
  44665. declare module BABYLON {
  44666. /**
  44667. * Single axis drag gizmo
  44668. */
  44669. export class AxisDragGizmo extends Gizmo {
  44670. /**
  44671. * Drag behavior responsible for the gizmos dragging interactions
  44672. */
  44673. dragBehavior: PointerDragBehavior;
  44674. private _pointerObserver;
  44675. /**
  44676. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44677. */
  44678. snapDistance: number;
  44679. /**
  44680. * Event that fires each time the gizmo snaps to a new location.
  44681. * * snapDistance is the the change in distance
  44682. */
  44683. onSnapObservable: Observable<{
  44684. snapDistance: number;
  44685. }>;
  44686. private _isEnabled;
  44687. private _parent;
  44688. private _arrow;
  44689. private _coloredMaterial;
  44690. private _hoverMaterial;
  44691. /** @hidden */
  44692. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44693. /** @hidden */
  44694. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44695. /**
  44696. * Creates an AxisDragGizmo
  44697. * @param gizmoLayer The utility layer the gizmo will be added to
  44698. * @param dragAxis The axis which the gizmo will be able to drag on
  44699. * @param color The color of the gizmo
  44700. */
  44701. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44702. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44703. /**
  44704. * If the gizmo is enabled
  44705. */
  44706. isEnabled: boolean;
  44707. /**
  44708. * Disposes of the gizmo
  44709. */
  44710. dispose(): void;
  44711. }
  44712. }
  44713. declare module BABYLON.Debug {
  44714. /**
  44715. * The Axes viewer will show 3 axes in a specific point in space
  44716. */
  44717. export class AxesViewer {
  44718. private _xAxis;
  44719. private _yAxis;
  44720. private _zAxis;
  44721. private _scaleLinesFactor;
  44722. private _instanced;
  44723. /**
  44724. * Gets the hosting scene
  44725. */
  44726. scene: Scene;
  44727. /**
  44728. * Gets or sets a number used to scale line length
  44729. */
  44730. scaleLines: number;
  44731. /** Gets the node hierarchy used to render x-axis */
  44732. readonly xAxis: TransformNode;
  44733. /** Gets the node hierarchy used to render y-axis */
  44734. readonly yAxis: TransformNode;
  44735. /** Gets the node hierarchy used to render z-axis */
  44736. readonly zAxis: TransformNode;
  44737. /**
  44738. * Creates a new AxesViewer
  44739. * @param scene defines the hosting scene
  44740. * @param scaleLines defines a number used to scale line length (1 by default)
  44741. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44742. * @param xAxis defines the node hierarchy used to render the x-axis
  44743. * @param yAxis defines the node hierarchy used to render the y-axis
  44744. * @param zAxis defines the node hierarchy used to render the z-axis
  44745. */
  44746. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44747. /**
  44748. * Force the viewer to update
  44749. * @param position defines the position of the viewer
  44750. * @param xaxis defines the x axis of the viewer
  44751. * @param yaxis defines the y axis of the viewer
  44752. * @param zaxis defines the z axis of the viewer
  44753. */
  44754. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44755. /**
  44756. * Creates an instance of this axes viewer.
  44757. * @returns a new axes viewer with instanced meshes
  44758. */
  44759. createInstance(): AxesViewer;
  44760. /** Releases resources */
  44761. dispose(): void;
  44762. private static _SetRenderingGroupId;
  44763. }
  44764. }
  44765. declare module BABYLON.Debug {
  44766. /**
  44767. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44768. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44769. */
  44770. export class BoneAxesViewer extends AxesViewer {
  44771. /**
  44772. * Gets or sets the target mesh where to display the axes viewer
  44773. */
  44774. mesh: Nullable<Mesh>;
  44775. /**
  44776. * Gets or sets the target bone where to display the axes viewer
  44777. */
  44778. bone: Nullable<Bone>;
  44779. /** Gets current position */
  44780. pos: Vector3;
  44781. /** Gets direction of X axis */
  44782. xaxis: Vector3;
  44783. /** Gets direction of Y axis */
  44784. yaxis: Vector3;
  44785. /** Gets direction of Z axis */
  44786. zaxis: Vector3;
  44787. /**
  44788. * Creates a new BoneAxesViewer
  44789. * @param scene defines the hosting scene
  44790. * @param bone defines the target bone
  44791. * @param mesh defines the target mesh
  44792. * @param scaleLines defines a scaling factor for line length (1 by default)
  44793. */
  44794. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44795. /**
  44796. * Force the viewer to update
  44797. */
  44798. update(): void;
  44799. /** Releases resources */
  44800. dispose(): void;
  44801. }
  44802. }
  44803. declare module BABYLON {
  44804. /**
  44805. * Interface used to define scene explorer extensibility option
  44806. */
  44807. export interface IExplorerExtensibilityOption {
  44808. /**
  44809. * Define the option label
  44810. */
  44811. label: string;
  44812. /**
  44813. * Defines the action to execute on click
  44814. */
  44815. action: (entity: any) => void;
  44816. }
  44817. /**
  44818. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44819. */
  44820. export interface IExplorerExtensibilityGroup {
  44821. /**
  44822. * Defines a predicate to test if a given type mut be extended
  44823. */
  44824. predicate: (entity: any) => boolean;
  44825. /**
  44826. * Gets the list of options added to a type
  44827. */
  44828. entries: IExplorerExtensibilityOption[];
  44829. }
  44830. /**
  44831. * Interface used to define the options to use to create the Inspector
  44832. */
  44833. export interface IInspectorOptions {
  44834. /**
  44835. * Display in overlay mode (default: false)
  44836. */
  44837. overlay?: boolean;
  44838. /**
  44839. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44840. */
  44841. globalRoot?: HTMLElement;
  44842. /**
  44843. * Display the Scene explorer
  44844. */
  44845. showExplorer?: boolean;
  44846. /**
  44847. * Display the property inspector
  44848. */
  44849. showInspector?: boolean;
  44850. /**
  44851. * Display in embed mode (both panes on the right)
  44852. */
  44853. embedMode?: boolean;
  44854. /**
  44855. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44856. */
  44857. handleResize?: boolean;
  44858. /**
  44859. * Allow the panes to popup (default: true)
  44860. */
  44861. enablePopup?: boolean;
  44862. /**
  44863. * Allow the panes to be closed by users (default: true)
  44864. */
  44865. enableClose?: boolean;
  44866. /**
  44867. * Optional list of extensibility entries
  44868. */
  44869. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44870. /**
  44871. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44872. */
  44873. inspectorURL?: string;
  44874. /**
  44875. * Optional initial tab (default to DebugLayerTab.Properties)
  44876. */
  44877. initialTab?: DebugLayerTab;
  44878. }
  44879. interface Scene {
  44880. /**
  44881. * @hidden
  44882. * Backing field
  44883. */
  44884. _debugLayer: DebugLayer;
  44885. /**
  44886. * Gets the debug layer (aka Inspector) associated with the scene
  44887. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44888. */
  44889. debugLayer: DebugLayer;
  44890. }
  44891. /**
  44892. * Enum of inspector action tab
  44893. */
  44894. export enum DebugLayerTab {
  44895. /**
  44896. * Properties tag (default)
  44897. */
  44898. Properties = 0,
  44899. /**
  44900. * Debug tab
  44901. */
  44902. Debug = 1,
  44903. /**
  44904. * Statistics tab
  44905. */
  44906. Statistics = 2,
  44907. /**
  44908. * Tools tab
  44909. */
  44910. Tools = 3,
  44911. /**
  44912. * Settings tab
  44913. */
  44914. Settings = 4
  44915. }
  44916. /**
  44917. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44918. * what is happening in your scene
  44919. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44920. */
  44921. export class DebugLayer {
  44922. /**
  44923. * Define the url to get the inspector script from.
  44924. * By default it uses the babylonjs CDN.
  44925. * @ignoreNaming
  44926. */
  44927. static InspectorURL: string;
  44928. private _scene;
  44929. private BJSINSPECTOR;
  44930. private _onPropertyChangedObservable?;
  44931. /**
  44932. * Observable triggered when a property is changed through the inspector.
  44933. */
  44934. readonly onPropertyChangedObservable: any;
  44935. /**
  44936. * Instantiates a new debug layer.
  44937. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44938. * what is happening in your scene
  44939. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44940. * @param scene Defines the scene to inspect
  44941. */
  44942. constructor(scene: Scene);
  44943. /** Creates the inspector window. */
  44944. private _createInspector;
  44945. /**
  44946. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44947. * @param entity defines the entity to select
  44948. * @param lineContainerTitle defines the specific block to highlight
  44949. */
  44950. select(entity: any, lineContainerTitle?: string): void;
  44951. /** Get the inspector from bundle or global */
  44952. private _getGlobalInspector;
  44953. /**
  44954. * Get if the inspector is visible or not.
  44955. * @returns true if visible otherwise, false
  44956. */
  44957. isVisible(): boolean;
  44958. /**
  44959. * Hide the inspector and close its window.
  44960. */
  44961. hide(): void;
  44962. /**
  44963. * Launch the debugLayer.
  44964. * @param config Define the configuration of the inspector
  44965. * @return a promise fulfilled when the debug layer is visible
  44966. */
  44967. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44968. }
  44969. }
  44970. declare module BABYLON {
  44971. /**
  44972. * Class containing static functions to help procedurally build meshes
  44973. */
  44974. export class BoxBuilder {
  44975. /**
  44976. * Creates a box mesh
  44977. * * The parameter `size` sets the size (float) of each box side (default 1)
  44978. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44979. * * 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)
  44980. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44982. * * 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
  44983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44984. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44985. * @param name defines the name of the mesh
  44986. * @param options defines the options used to create the mesh
  44987. * @param scene defines the hosting scene
  44988. * @returns the box mesh
  44989. */
  44990. static CreateBox(name: string, options: {
  44991. size?: number;
  44992. width?: number;
  44993. height?: number;
  44994. depth?: number;
  44995. faceUV?: Vector4[];
  44996. faceColors?: Color4[];
  44997. sideOrientation?: number;
  44998. frontUVs?: Vector4;
  44999. backUVs?: Vector4;
  45000. wrap?: boolean;
  45001. topBaseAt?: number;
  45002. bottomBaseAt?: number;
  45003. updatable?: boolean;
  45004. }, scene?: Nullable<Scene>): Mesh;
  45005. }
  45006. }
  45007. declare module BABYLON {
  45008. /**
  45009. * Class containing static functions to help procedurally build meshes
  45010. */
  45011. export class SphereBuilder {
  45012. /**
  45013. * Creates a sphere mesh
  45014. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45015. * * 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`)
  45016. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45017. * * 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
  45018. * * 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)
  45019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45020. * * 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
  45021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45022. * @param name defines the name of the mesh
  45023. * @param options defines the options used to create the mesh
  45024. * @param scene defines the hosting scene
  45025. * @returns the sphere mesh
  45026. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45027. */
  45028. static CreateSphere(name: string, options: {
  45029. segments?: number;
  45030. diameter?: number;
  45031. diameterX?: number;
  45032. diameterY?: number;
  45033. diameterZ?: number;
  45034. arc?: number;
  45035. slice?: number;
  45036. sideOrientation?: number;
  45037. frontUVs?: Vector4;
  45038. backUVs?: Vector4;
  45039. updatable?: boolean;
  45040. }, scene?: Nullable<Scene>): Mesh;
  45041. }
  45042. }
  45043. declare module BABYLON.Debug {
  45044. /**
  45045. * Used to show the physics impostor around the specific mesh
  45046. */
  45047. export class PhysicsViewer {
  45048. /** @hidden */
  45049. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45050. /** @hidden */
  45051. protected _meshes: Array<Nullable<AbstractMesh>>;
  45052. /** @hidden */
  45053. protected _scene: Nullable<Scene>;
  45054. /** @hidden */
  45055. protected _numMeshes: number;
  45056. /** @hidden */
  45057. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45058. private _renderFunction;
  45059. private _utilityLayer;
  45060. private _debugBoxMesh;
  45061. private _debugSphereMesh;
  45062. private _debugCylinderMesh;
  45063. private _debugMaterial;
  45064. private _debugMeshMeshes;
  45065. /**
  45066. * Creates a new PhysicsViewer
  45067. * @param scene defines the hosting scene
  45068. */
  45069. constructor(scene: Scene);
  45070. /** @hidden */
  45071. protected _updateDebugMeshes(): void;
  45072. /**
  45073. * Renders a specified physic impostor
  45074. * @param impostor defines the impostor to render
  45075. * @param targetMesh defines the mesh represented by the impostor
  45076. * @returns the new debug mesh used to render the impostor
  45077. */
  45078. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45079. /**
  45080. * Hides a specified physic impostor
  45081. * @param impostor defines the impostor to hide
  45082. */
  45083. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45084. private _getDebugMaterial;
  45085. private _getDebugBoxMesh;
  45086. private _getDebugSphereMesh;
  45087. private _getDebugCylinderMesh;
  45088. private _getDebugMeshMesh;
  45089. private _getDebugMesh;
  45090. /** Releases all resources */
  45091. dispose(): void;
  45092. }
  45093. }
  45094. declare module BABYLON {
  45095. /**
  45096. * Class containing static functions to help procedurally build meshes
  45097. */
  45098. export class LinesBuilder {
  45099. /**
  45100. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45101. * * 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
  45102. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45103. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45104. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45105. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45106. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45107. * * 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
  45108. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45111. * @param name defines the name of the new line system
  45112. * @param options defines the options used to create the line system
  45113. * @param scene defines the hosting scene
  45114. * @returns a new line system mesh
  45115. */
  45116. static CreateLineSystem(name: string, options: {
  45117. lines: Vector3[][];
  45118. updatable?: boolean;
  45119. instance?: Nullable<LinesMesh>;
  45120. colors?: Nullable<Color4[][]>;
  45121. useVertexAlpha?: boolean;
  45122. }, scene: Nullable<Scene>): LinesMesh;
  45123. /**
  45124. * Creates a line mesh
  45125. * 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
  45126. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45127. * * The parameter `points` is an array successive Vector3
  45128. * * 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
  45129. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45130. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45131. * * When updating an instance, remember that only point positions can change, not the number of points
  45132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45133. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45134. * @param name defines the name of the new line system
  45135. * @param options defines the options used to create the line system
  45136. * @param scene defines the hosting scene
  45137. * @returns a new line mesh
  45138. */
  45139. static CreateLines(name: string, options: {
  45140. points: Vector3[];
  45141. updatable?: boolean;
  45142. instance?: Nullable<LinesMesh>;
  45143. colors?: Color4[];
  45144. useVertexAlpha?: boolean;
  45145. }, scene?: Nullable<Scene>): LinesMesh;
  45146. /**
  45147. * Creates a dashed line mesh
  45148. * * 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
  45149. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45150. * * The parameter `points` is an array successive Vector3
  45151. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45152. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45153. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45154. * * 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
  45155. * * When updating an instance, remember that only point positions can change, not the number of points
  45156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45157. * @param name defines the name of the mesh
  45158. * @param options defines the options used to create the mesh
  45159. * @param scene defines the hosting scene
  45160. * @returns the dashed line mesh
  45161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45162. */
  45163. static CreateDashedLines(name: string, options: {
  45164. points: Vector3[];
  45165. dashSize?: number;
  45166. gapSize?: number;
  45167. dashNb?: number;
  45168. updatable?: boolean;
  45169. instance?: LinesMesh;
  45170. }, scene?: Nullable<Scene>): LinesMesh;
  45171. }
  45172. }
  45173. declare module BABYLON {
  45174. /**
  45175. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45176. * in order to better appreciate the issue one might have.
  45177. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45178. */
  45179. export class RayHelper {
  45180. /**
  45181. * Defines the ray we are currently tryin to visualize.
  45182. */
  45183. ray: Nullable<Ray>;
  45184. private _renderPoints;
  45185. private _renderLine;
  45186. private _renderFunction;
  45187. private _scene;
  45188. private _updateToMeshFunction;
  45189. private _attachedToMesh;
  45190. private _meshSpaceDirection;
  45191. private _meshSpaceOrigin;
  45192. /**
  45193. * Helper function to create a colored helper in a scene in one line.
  45194. * @param ray Defines the ray we are currently tryin to visualize
  45195. * @param scene Defines the scene the ray is used in
  45196. * @param color Defines the color we want to see the ray in
  45197. * @returns The newly created ray helper.
  45198. */
  45199. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45200. /**
  45201. * Instantiate a new ray helper.
  45202. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45203. * in order to better appreciate the issue one might have.
  45204. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45205. * @param ray Defines the ray we are currently tryin to visualize
  45206. */
  45207. constructor(ray: Ray);
  45208. /**
  45209. * Shows the ray we are willing to debug.
  45210. * @param scene Defines the scene the ray needs to be rendered in
  45211. * @param color Defines the color the ray needs to be rendered in
  45212. */
  45213. show(scene: Scene, color?: Color3): void;
  45214. /**
  45215. * Hides the ray we are debugging.
  45216. */
  45217. hide(): void;
  45218. private _render;
  45219. /**
  45220. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45221. * @param mesh Defines the mesh we want the helper attached to
  45222. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45223. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45224. * @param length Defines the length of the ray
  45225. */
  45226. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45227. /**
  45228. * Detach the ray helper from the mesh it has previously been attached to.
  45229. */
  45230. detachFromMesh(): void;
  45231. private _updateToMesh;
  45232. /**
  45233. * Dispose the helper and release its associated resources.
  45234. */
  45235. dispose(): void;
  45236. }
  45237. }
  45238. declare module BABYLON.Debug {
  45239. /**
  45240. * Class used to render a debug view of a given skeleton
  45241. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45242. */
  45243. export class SkeletonViewer {
  45244. /** defines the skeleton to render */
  45245. skeleton: Skeleton;
  45246. /** defines the mesh attached to the skeleton */
  45247. mesh: AbstractMesh;
  45248. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45249. autoUpdateBonesMatrices: boolean;
  45250. /** defines the rendering group id to use with the viewer */
  45251. renderingGroupId: number;
  45252. /** Gets or sets the color used to render the skeleton */
  45253. color: Color3;
  45254. private _scene;
  45255. private _debugLines;
  45256. private _debugMesh;
  45257. private _isEnabled;
  45258. private _renderFunction;
  45259. private _utilityLayer;
  45260. /**
  45261. * Returns the mesh used to render the bones
  45262. */
  45263. readonly debugMesh: Nullable<LinesMesh>;
  45264. /**
  45265. * Creates a new SkeletonViewer
  45266. * @param skeleton defines the skeleton to render
  45267. * @param mesh defines the mesh attached to the skeleton
  45268. * @param scene defines the hosting scene
  45269. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45270. * @param renderingGroupId defines the rendering group id to use with the viewer
  45271. */
  45272. constructor(
  45273. /** defines the skeleton to render */
  45274. skeleton: Skeleton,
  45275. /** defines the mesh attached to the skeleton */
  45276. mesh: AbstractMesh, scene: Scene,
  45277. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45278. autoUpdateBonesMatrices?: boolean,
  45279. /** defines the rendering group id to use with the viewer */
  45280. renderingGroupId?: number);
  45281. /** Gets or sets a boolean indicating if the viewer is enabled */
  45282. isEnabled: boolean;
  45283. private _getBonePosition;
  45284. private _getLinesForBonesWithLength;
  45285. private _getLinesForBonesNoLength;
  45286. /** Update the viewer to sync with current skeleton state */
  45287. update(): void;
  45288. /** Release associated resources */
  45289. dispose(): void;
  45290. }
  45291. }
  45292. declare module BABYLON {
  45293. /**
  45294. * Options to create the null engine
  45295. */
  45296. export class NullEngineOptions {
  45297. /**
  45298. * Render width (Default: 512)
  45299. */
  45300. renderWidth: number;
  45301. /**
  45302. * Render height (Default: 256)
  45303. */
  45304. renderHeight: number;
  45305. /**
  45306. * Texture size (Default: 512)
  45307. */
  45308. textureSize: number;
  45309. /**
  45310. * If delta time between frames should be constant
  45311. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45312. */
  45313. deterministicLockstep: boolean;
  45314. /**
  45315. * Maximum about of steps between frames (Default: 4)
  45316. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45317. */
  45318. lockstepMaxSteps: number;
  45319. }
  45320. /**
  45321. * The null engine class provides support for headless version of babylon.js.
  45322. * This can be used in server side scenario or for testing purposes
  45323. */
  45324. export class NullEngine extends Engine {
  45325. private _options;
  45326. /**
  45327. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45328. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45329. * @returns true if engine is in deterministic lock step mode
  45330. */
  45331. isDeterministicLockStep(): boolean;
  45332. /**
  45333. * Gets the max steps when engine is running in deterministic lock step
  45334. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45335. * @returns the max steps
  45336. */
  45337. getLockstepMaxSteps(): number;
  45338. /**
  45339. * Gets the current hardware scaling level.
  45340. * By default the hardware scaling level is computed from the window device ratio.
  45341. * 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.
  45342. * @returns a number indicating the current hardware scaling level
  45343. */
  45344. getHardwareScalingLevel(): number;
  45345. constructor(options?: NullEngineOptions);
  45346. /**
  45347. * Creates a vertex buffer
  45348. * @param vertices the data for the vertex buffer
  45349. * @returns the new WebGL static buffer
  45350. */
  45351. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45352. /**
  45353. * Creates a new index buffer
  45354. * @param indices defines the content of the index buffer
  45355. * @param updatable defines if the index buffer must be updatable
  45356. * @returns a new webGL buffer
  45357. */
  45358. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45359. /**
  45360. * Clear the current render buffer or the current render target (if any is set up)
  45361. * @param color defines the color to use
  45362. * @param backBuffer defines if the back buffer must be cleared
  45363. * @param depth defines if the depth buffer must be cleared
  45364. * @param stencil defines if the stencil buffer must be cleared
  45365. */
  45366. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45367. /**
  45368. * Gets the current render width
  45369. * @param useScreen defines if screen size must be used (or the current render target if any)
  45370. * @returns a number defining the current render width
  45371. */
  45372. getRenderWidth(useScreen?: boolean): number;
  45373. /**
  45374. * Gets the current render height
  45375. * @param useScreen defines if screen size must be used (or the current render target if any)
  45376. * @returns a number defining the current render height
  45377. */
  45378. getRenderHeight(useScreen?: boolean): number;
  45379. /**
  45380. * Set the WebGL's viewport
  45381. * @param viewport defines the viewport element to be used
  45382. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45383. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45384. */
  45385. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45386. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45387. /**
  45388. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45389. * @param pipelineContext defines the pipeline context to use
  45390. * @param uniformsNames defines the list of uniform names
  45391. * @returns an array of webGL uniform locations
  45392. */
  45393. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45394. /**
  45395. * Gets the lsit of active attributes for a given webGL program
  45396. * @param pipelineContext defines the pipeline context to use
  45397. * @param attributesNames defines the list of attribute names to get
  45398. * @returns an array of indices indicating the offset of each attribute
  45399. */
  45400. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45401. /**
  45402. * Binds an effect to the webGL context
  45403. * @param effect defines the effect to bind
  45404. */
  45405. bindSamplers(effect: Effect): void;
  45406. /**
  45407. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45408. * @param effect defines the effect to activate
  45409. */
  45410. enableEffect(effect: Effect): void;
  45411. /**
  45412. * Set various states to the webGL context
  45413. * @param culling defines backface culling state
  45414. * @param zOffset defines the value to apply to zOffset (0 by default)
  45415. * @param force defines if states must be applied even if cache is up to date
  45416. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45417. */
  45418. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45419. /**
  45420. * Set the value of an uniform to an array of int32
  45421. * @param uniform defines the webGL uniform location where to store the value
  45422. * @param array defines the array of int32 to store
  45423. */
  45424. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45425. /**
  45426. * Set the value of an uniform to an array of int32 (stored as vec2)
  45427. * @param uniform defines the webGL uniform location where to store the value
  45428. * @param array defines the array of int32 to store
  45429. */
  45430. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45431. /**
  45432. * Set the value of an uniform to an array of int32 (stored as vec3)
  45433. * @param uniform defines the webGL uniform location where to store the value
  45434. * @param array defines the array of int32 to store
  45435. */
  45436. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45437. /**
  45438. * Set the value of an uniform to an array of int32 (stored as vec4)
  45439. * @param uniform defines the webGL uniform location where to store the value
  45440. * @param array defines the array of int32 to store
  45441. */
  45442. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45443. /**
  45444. * Set the value of an uniform to an array of float32
  45445. * @param uniform defines the webGL uniform location where to store the value
  45446. * @param array defines the array of float32 to store
  45447. */
  45448. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45449. /**
  45450. * Set the value of an uniform to an array of float32 (stored as vec2)
  45451. * @param uniform defines the webGL uniform location where to store the value
  45452. * @param array defines the array of float32 to store
  45453. */
  45454. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45455. /**
  45456. * Set the value of an uniform to an array of float32 (stored as vec3)
  45457. * @param uniform defines the webGL uniform location where to store the value
  45458. * @param array defines the array of float32 to store
  45459. */
  45460. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45461. /**
  45462. * Set the value of an uniform to an array of float32 (stored as vec4)
  45463. * @param uniform defines the webGL uniform location where to store the value
  45464. * @param array defines the array of float32 to store
  45465. */
  45466. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45467. /**
  45468. * Set the value of an uniform to an array of number
  45469. * @param uniform defines the webGL uniform location where to store the value
  45470. * @param array defines the array of number to store
  45471. */
  45472. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45473. /**
  45474. * Set the value of an uniform to an array of number (stored as vec2)
  45475. * @param uniform defines the webGL uniform location where to store the value
  45476. * @param array defines the array of number to store
  45477. */
  45478. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45479. /**
  45480. * Set the value of an uniform to an array of number (stored as vec3)
  45481. * @param uniform defines the webGL uniform location where to store the value
  45482. * @param array defines the array of number to store
  45483. */
  45484. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45485. /**
  45486. * Set the value of an uniform to an array of number (stored as vec4)
  45487. * @param uniform defines the webGL uniform location where to store the value
  45488. * @param array defines the array of number to store
  45489. */
  45490. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45491. /**
  45492. * Set the value of an uniform to an array of float32 (stored as matrices)
  45493. * @param uniform defines the webGL uniform location where to store the value
  45494. * @param matrices defines the array of float32 to store
  45495. */
  45496. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45497. /**
  45498. * Set the value of an uniform to a matrix (3x3)
  45499. * @param uniform defines the webGL uniform location where to store the value
  45500. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45501. */
  45502. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45503. /**
  45504. * Set the value of an uniform to a matrix (2x2)
  45505. * @param uniform defines the webGL uniform location where to store the value
  45506. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45507. */
  45508. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45509. /**
  45510. * Set the value of an uniform to a number (float)
  45511. * @param uniform defines the webGL uniform location where to store the value
  45512. * @param value defines the float number to store
  45513. */
  45514. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45515. /**
  45516. * Set the value of an uniform to a vec2
  45517. * @param uniform defines the webGL uniform location where to store the value
  45518. * @param x defines the 1st component of the value
  45519. * @param y defines the 2nd component of the value
  45520. */
  45521. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45522. /**
  45523. * Set the value of an uniform to a vec3
  45524. * @param uniform defines the webGL uniform location where to store the value
  45525. * @param x defines the 1st component of the value
  45526. * @param y defines the 2nd component of the value
  45527. * @param z defines the 3rd component of the value
  45528. */
  45529. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45530. /**
  45531. * Set the value of an uniform to a boolean
  45532. * @param uniform defines the webGL uniform location where to store the value
  45533. * @param bool defines the boolean to store
  45534. */
  45535. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45536. /**
  45537. * Set the value of an uniform to a vec4
  45538. * @param uniform defines the webGL uniform location where to store the value
  45539. * @param x defines the 1st component of the value
  45540. * @param y defines the 2nd component of the value
  45541. * @param z defines the 3rd component of the value
  45542. * @param w defines the 4th component of the value
  45543. */
  45544. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45545. /**
  45546. * Sets the current alpha mode
  45547. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45548. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45549. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45550. */
  45551. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45552. /**
  45553. * Bind webGl buffers directly to the webGL context
  45554. * @param vertexBuffers defines the vertex buffer to bind
  45555. * @param indexBuffer defines the index buffer to bind
  45556. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45557. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45558. * @param effect defines the effect associated with the vertex buffer
  45559. */
  45560. bindBuffers(vertexBuffers: {
  45561. [key: string]: VertexBuffer;
  45562. }, indexBuffer: DataBuffer, effect: Effect): void;
  45563. /**
  45564. * Force the entire cache to be cleared
  45565. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45566. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45567. */
  45568. wipeCaches(bruteForce?: boolean): void;
  45569. /**
  45570. * Send a draw order
  45571. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45572. * @param indexStart defines the starting index
  45573. * @param indexCount defines the number of index to draw
  45574. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45575. */
  45576. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45577. /**
  45578. * Draw a list of indexed primitives
  45579. * @param fillMode defines the primitive to use
  45580. * @param indexStart defines the starting index
  45581. * @param indexCount defines the number of index to draw
  45582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45583. */
  45584. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45585. /**
  45586. * Draw a list of unindexed primitives
  45587. * @param fillMode defines the primitive to use
  45588. * @param verticesStart defines the index of first vertex to draw
  45589. * @param verticesCount defines the count of vertices to draw
  45590. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45591. */
  45592. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45593. /** @hidden */
  45594. _createTexture(): WebGLTexture;
  45595. /** @hidden */
  45596. _releaseTexture(texture: InternalTexture): void;
  45597. /**
  45598. * Usually called from Texture.ts.
  45599. * Passed information to create a WebGLTexture
  45600. * @param urlArg defines a value which contains one of the following:
  45601. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45602. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45603. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45604. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45605. * @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)
  45606. * @param scene needed for loading to the correct scene
  45607. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45608. * @param onLoad optional callback to be called upon successful completion
  45609. * @param onError optional callback to be called upon failure
  45610. * @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
  45611. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45612. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45613. * @param forcedExtension defines the extension to use to pick the right loader
  45614. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45615. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45616. */
  45617. 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;
  45618. /**
  45619. * Creates a new render target texture
  45620. * @param size defines the size of the texture
  45621. * @param options defines the options used to create the texture
  45622. * @returns a new render target texture stored in an InternalTexture
  45623. */
  45624. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45625. /**
  45626. * Update the sampling mode of a given texture
  45627. * @param samplingMode defines the required sampling mode
  45628. * @param texture defines the texture to update
  45629. */
  45630. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45631. /**
  45632. * Binds the frame buffer to the specified texture.
  45633. * @param texture The texture to render to or null for the default canvas
  45634. * @param faceIndex The face of the texture to render to in case of cube texture
  45635. * @param requiredWidth The width of the target to render to
  45636. * @param requiredHeight The height of the target to render to
  45637. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45638. * @param depthStencilTexture The depth stencil texture to use to render
  45639. * @param lodLevel defines le lod level to bind to the frame buffer
  45640. */
  45641. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45642. /**
  45643. * Unbind the current render target texture from the webGL context
  45644. * @param texture defines the render target texture to unbind
  45645. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45646. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45647. */
  45648. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45649. /**
  45650. * Creates a dynamic vertex buffer
  45651. * @param vertices the data for the dynamic vertex buffer
  45652. * @returns the new WebGL dynamic buffer
  45653. */
  45654. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45655. /**
  45656. * Update the content of a dynamic texture
  45657. * @param texture defines the texture to update
  45658. * @param canvas defines the canvas containing the source
  45659. * @param invertY defines if data must be stored with Y axis inverted
  45660. * @param premulAlpha defines if alpha is stored as premultiplied
  45661. * @param format defines the format of the data
  45662. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45663. */
  45664. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45665. /**
  45666. * Gets a boolean indicating if all created effects are ready
  45667. * @returns true if all effects are ready
  45668. */
  45669. areAllEffectsReady(): boolean;
  45670. /**
  45671. * @hidden
  45672. * Get the current error code of the webGL context
  45673. * @returns the error code
  45674. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45675. */
  45676. getError(): number;
  45677. /** @hidden */
  45678. _getUnpackAlignement(): number;
  45679. /** @hidden */
  45680. _unpackFlipY(value: boolean): void;
  45681. /**
  45682. * Update a dynamic index buffer
  45683. * @param indexBuffer defines the target index buffer
  45684. * @param indices defines the data to update
  45685. * @param offset defines the offset in the target index buffer where update should start
  45686. */
  45687. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45688. /**
  45689. * Updates a dynamic vertex buffer.
  45690. * @param vertexBuffer the vertex buffer to update
  45691. * @param vertices the data used to update the vertex buffer
  45692. * @param byteOffset the byte offset of the data (optional)
  45693. * @param byteLength the byte length of the data (optional)
  45694. */
  45695. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45696. /** @hidden */
  45697. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45698. /** @hidden */
  45699. _bindTexture(channel: number, texture: InternalTexture): void;
  45700. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45701. /**
  45702. * 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
  45703. */
  45704. releaseEffects(): void;
  45705. displayLoadingUI(): void;
  45706. hideLoadingUI(): void;
  45707. /** @hidden */
  45708. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45709. /** @hidden */
  45710. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45711. /** @hidden */
  45712. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45713. /** @hidden */
  45714. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45715. }
  45716. }
  45717. declare module BABYLON {
  45718. /** @hidden */
  45719. export class _OcclusionDataStorage {
  45720. /** @hidden */
  45721. occlusionInternalRetryCounter: number;
  45722. /** @hidden */
  45723. isOcclusionQueryInProgress: boolean;
  45724. /** @hidden */
  45725. isOccluded: boolean;
  45726. /** @hidden */
  45727. occlusionRetryCount: number;
  45728. /** @hidden */
  45729. occlusionType: number;
  45730. /** @hidden */
  45731. occlusionQueryAlgorithmType: number;
  45732. }
  45733. interface Engine {
  45734. /**
  45735. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45736. * @return the new query
  45737. */
  45738. createQuery(): WebGLQuery;
  45739. /**
  45740. * Delete and release a webGL query
  45741. * @param query defines the query to delete
  45742. * @return the current engine
  45743. */
  45744. deleteQuery(query: WebGLQuery): Engine;
  45745. /**
  45746. * Check if a given query has resolved and got its value
  45747. * @param query defines the query to check
  45748. * @returns true if the query got its value
  45749. */
  45750. isQueryResultAvailable(query: WebGLQuery): boolean;
  45751. /**
  45752. * Gets the value of a given query
  45753. * @param query defines the query to check
  45754. * @returns the value of the query
  45755. */
  45756. getQueryResult(query: WebGLQuery): number;
  45757. /**
  45758. * Initiates an occlusion query
  45759. * @param algorithmType defines the algorithm to use
  45760. * @param query defines the query to use
  45761. * @returns the current engine
  45762. * @see http://doc.babylonjs.com/features/occlusionquery
  45763. */
  45764. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45765. /**
  45766. * Ends an occlusion query
  45767. * @see http://doc.babylonjs.com/features/occlusionquery
  45768. * @param algorithmType defines the algorithm to use
  45769. * @returns the current engine
  45770. */
  45771. endOcclusionQuery(algorithmType: number): Engine;
  45772. /**
  45773. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45774. * Please note that only one query can be issued at a time
  45775. * @returns a time token used to track the time span
  45776. */
  45777. startTimeQuery(): Nullable<_TimeToken>;
  45778. /**
  45779. * Ends a time query
  45780. * @param token defines the token used to measure the time span
  45781. * @returns the time spent (in ns)
  45782. */
  45783. endTimeQuery(token: _TimeToken): int;
  45784. /** @hidden */
  45785. _currentNonTimestampToken: Nullable<_TimeToken>;
  45786. /** @hidden */
  45787. _createTimeQuery(): WebGLQuery;
  45788. /** @hidden */
  45789. _deleteTimeQuery(query: WebGLQuery): void;
  45790. /** @hidden */
  45791. _getGlAlgorithmType(algorithmType: number): number;
  45792. /** @hidden */
  45793. _getTimeQueryResult(query: WebGLQuery): any;
  45794. /** @hidden */
  45795. _getTimeQueryAvailability(query: WebGLQuery): any;
  45796. }
  45797. interface AbstractMesh {
  45798. /**
  45799. * Backing filed
  45800. * @hidden
  45801. */
  45802. __occlusionDataStorage: _OcclusionDataStorage;
  45803. /**
  45804. * Access property
  45805. * @hidden
  45806. */
  45807. _occlusionDataStorage: _OcclusionDataStorage;
  45808. /**
  45809. * 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.
  45810. * The default value is -1 which means don't break the query and wait till the result
  45811. * @see http://doc.babylonjs.com/features/occlusionquery
  45812. */
  45813. occlusionRetryCount: number;
  45814. /**
  45815. * 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:
  45816. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45817. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45818. * * 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.
  45819. * @see http://doc.babylonjs.com/features/occlusionquery
  45820. */
  45821. occlusionType: number;
  45822. /**
  45823. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45824. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45825. * * 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.
  45826. * @see http://doc.babylonjs.com/features/occlusionquery
  45827. */
  45828. occlusionQueryAlgorithmType: number;
  45829. /**
  45830. * 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
  45831. * @see http://doc.babylonjs.com/features/occlusionquery
  45832. */
  45833. isOccluded: boolean;
  45834. /**
  45835. * Flag to check the progress status of the query
  45836. * @see http://doc.babylonjs.com/features/occlusionquery
  45837. */
  45838. isOcclusionQueryInProgress: boolean;
  45839. }
  45840. }
  45841. declare module BABYLON {
  45842. /** @hidden */
  45843. export var _forceTransformFeedbackToBundle: boolean;
  45844. interface Engine {
  45845. /**
  45846. * Creates a webGL transform feedback object
  45847. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45848. * @returns the webGL transform feedback object
  45849. */
  45850. createTransformFeedback(): WebGLTransformFeedback;
  45851. /**
  45852. * Delete a webGL transform feedback object
  45853. * @param value defines the webGL transform feedback object to delete
  45854. */
  45855. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45856. /**
  45857. * Bind a webGL transform feedback object to the webgl context
  45858. * @param value defines the webGL transform feedback object to bind
  45859. */
  45860. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45861. /**
  45862. * Begins a transform feedback operation
  45863. * @param usePoints defines if points or triangles must be used
  45864. */
  45865. beginTransformFeedback(usePoints: boolean): void;
  45866. /**
  45867. * Ends a transform feedback operation
  45868. */
  45869. endTransformFeedback(): void;
  45870. /**
  45871. * Specify the varyings to use with transform feedback
  45872. * @param program defines the associated webGL program
  45873. * @param value defines the list of strings representing the varying names
  45874. */
  45875. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45876. /**
  45877. * Bind a webGL buffer for a transform feedback operation
  45878. * @param value defines the webGL buffer to bind
  45879. */
  45880. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45881. }
  45882. }
  45883. declare module BABYLON {
  45884. /**
  45885. * Creation options of the multi render target texture.
  45886. */
  45887. export interface IMultiRenderTargetOptions {
  45888. /**
  45889. * Define if the texture needs to create mip maps after render.
  45890. */
  45891. generateMipMaps?: boolean;
  45892. /**
  45893. * Define the types of all the draw buffers we want to create
  45894. */
  45895. types?: number[];
  45896. /**
  45897. * Define the sampling modes of all the draw buffers we want to create
  45898. */
  45899. samplingModes?: number[];
  45900. /**
  45901. * Define if a depth buffer is required
  45902. */
  45903. generateDepthBuffer?: boolean;
  45904. /**
  45905. * Define if a stencil buffer is required
  45906. */
  45907. generateStencilBuffer?: boolean;
  45908. /**
  45909. * Define if a depth texture is required instead of a depth buffer
  45910. */
  45911. generateDepthTexture?: boolean;
  45912. /**
  45913. * Define the number of desired draw buffers
  45914. */
  45915. textureCount?: number;
  45916. /**
  45917. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45918. */
  45919. doNotChangeAspectRatio?: boolean;
  45920. /**
  45921. * Define the default type of the buffers we are creating
  45922. */
  45923. defaultType?: number;
  45924. }
  45925. /**
  45926. * A multi render target, like a render target provides the ability to render to a texture.
  45927. * Unlike the render target, it can render to several draw buffers in one draw.
  45928. * This is specially interesting in deferred rendering or for any effects requiring more than
  45929. * just one color from a single pass.
  45930. */
  45931. export class MultiRenderTarget extends RenderTargetTexture {
  45932. private _internalTextures;
  45933. private _textures;
  45934. private _multiRenderTargetOptions;
  45935. /**
  45936. * Get if draw buffers are currently supported by the used hardware and browser.
  45937. */
  45938. readonly isSupported: boolean;
  45939. /**
  45940. * Get the list of textures generated by the multi render target.
  45941. */
  45942. readonly textures: Texture[];
  45943. /**
  45944. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45945. */
  45946. readonly depthTexture: Texture;
  45947. /**
  45948. * Set the wrapping mode on U of all the textures we are rendering to.
  45949. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45950. */
  45951. wrapU: number;
  45952. /**
  45953. * Set the wrapping mode on V of all the textures we are rendering to.
  45954. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45955. */
  45956. wrapV: number;
  45957. /**
  45958. * Instantiate a new multi render target texture.
  45959. * A multi render target, like a render target provides the ability to render to a texture.
  45960. * Unlike the render target, it can render to several draw buffers in one draw.
  45961. * This is specially interesting in deferred rendering or for any effects requiring more than
  45962. * just one color from a single pass.
  45963. * @param name Define the name of the texture
  45964. * @param size Define the size of the buffers to render to
  45965. * @param count Define the number of target we are rendering into
  45966. * @param scene Define the scene the texture belongs to
  45967. * @param options Define the options used to create the multi render target
  45968. */
  45969. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45970. /** @hidden */
  45971. _rebuild(): void;
  45972. private _createInternalTextures;
  45973. private _createTextures;
  45974. /**
  45975. * Define the number of samples used if MSAA is enabled.
  45976. */
  45977. samples: number;
  45978. /**
  45979. * Resize all the textures in the multi render target.
  45980. * Be carrefull as it will recreate all the data in the new texture.
  45981. * @param size Define the new size
  45982. */
  45983. resize(size: any): void;
  45984. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45985. /**
  45986. * Dispose the render targets and their associated resources
  45987. */
  45988. dispose(): void;
  45989. /**
  45990. * Release all the underlying texture used as draw buffers.
  45991. */
  45992. releaseInternalTextures(): void;
  45993. }
  45994. }
  45995. declare module BABYLON {
  45996. interface ThinEngine {
  45997. /**
  45998. * Unbind a list of render target textures from the webGL context
  45999. * This is used only when drawBuffer extension or webGL2 are active
  46000. * @param textures defines the render target textures to unbind
  46001. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46002. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46003. */
  46004. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46005. /**
  46006. * Create a multi render target texture
  46007. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46008. * @param size defines the size of the texture
  46009. * @param options defines the creation options
  46010. * @returns the cube texture as an InternalTexture
  46011. */
  46012. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46013. /**
  46014. * Update the sample count for a given multiple render target texture
  46015. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46016. * @param textures defines the textures to update
  46017. * @param samples defines the sample count to set
  46018. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46019. */
  46020. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46021. }
  46022. }
  46023. declare module BABYLON {
  46024. /**
  46025. * Class used to define an additional view for the engine
  46026. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46027. */
  46028. export class EngineView {
  46029. /** Defines the canvas where to render the view */
  46030. target: HTMLCanvasElement;
  46031. /** Defines an optional camera used to render the view (will use active camera else) */
  46032. camera?: Camera;
  46033. }
  46034. interface Engine {
  46035. /**
  46036. * Gets or sets the HTML element to use for attaching events
  46037. */
  46038. inputElement: Nullable<HTMLElement>;
  46039. /**
  46040. * Gets the current engine view
  46041. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46042. */
  46043. activeView: Nullable<EngineView>;
  46044. /** Gets or sets the list of views */
  46045. views: EngineView[];
  46046. /**
  46047. * Register a new child canvas
  46048. * @param canvas defines the canvas to register
  46049. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46050. * @returns the associated view
  46051. */
  46052. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46053. /**
  46054. * Remove a registered child canvas
  46055. * @param canvas defines the canvas to remove
  46056. * @returns the current engine
  46057. */
  46058. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46059. }
  46060. }
  46061. declare module BABYLON {
  46062. /**
  46063. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46064. */
  46065. export interface CubeMapInfo {
  46066. /**
  46067. * The pixel array for the front face.
  46068. * This is stored in format, left to right, up to down format.
  46069. */
  46070. front: Nullable<ArrayBufferView>;
  46071. /**
  46072. * The pixel array for the back face.
  46073. * This is stored in format, left to right, up to down format.
  46074. */
  46075. back: Nullable<ArrayBufferView>;
  46076. /**
  46077. * The pixel array for the left face.
  46078. * This is stored in format, left to right, up to down format.
  46079. */
  46080. left: Nullable<ArrayBufferView>;
  46081. /**
  46082. * The pixel array for the right face.
  46083. * This is stored in format, left to right, up to down format.
  46084. */
  46085. right: Nullable<ArrayBufferView>;
  46086. /**
  46087. * The pixel array for the up face.
  46088. * This is stored in format, left to right, up to down format.
  46089. */
  46090. up: Nullable<ArrayBufferView>;
  46091. /**
  46092. * The pixel array for the down face.
  46093. * This is stored in format, left to right, up to down format.
  46094. */
  46095. down: Nullable<ArrayBufferView>;
  46096. /**
  46097. * The size of the cubemap stored.
  46098. *
  46099. * Each faces will be size * size pixels.
  46100. */
  46101. size: number;
  46102. /**
  46103. * The format of the texture.
  46104. *
  46105. * RGBA, RGB.
  46106. */
  46107. format: number;
  46108. /**
  46109. * The type of the texture data.
  46110. *
  46111. * UNSIGNED_INT, FLOAT.
  46112. */
  46113. type: number;
  46114. /**
  46115. * Specifies whether the texture is in gamma space.
  46116. */
  46117. gammaSpace: boolean;
  46118. }
  46119. /**
  46120. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46121. */
  46122. export class PanoramaToCubeMapTools {
  46123. private static FACE_FRONT;
  46124. private static FACE_BACK;
  46125. private static FACE_RIGHT;
  46126. private static FACE_LEFT;
  46127. private static FACE_DOWN;
  46128. private static FACE_UP;
  46129. /**
  46130. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46131. *
  46132. * @param float32Array The source data.
  46133. * @param inputWidth The width of the input panorama.
  46134. * @param inputHeight The height of the input panorama.
  46135. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46136. * @return The cubemap data
  46137. */
  46138. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46139. private static CreateCubemapTexture;
  46140. private static CalcProjectionSpherical;
  46141. }
  46142. }
  46143. declare module BABYLON {
  46144. /**
  46145. * Helper class dealing with the extraction of spherical polynomial dataArray
  46146. * from a cube map.
  46147. */
  46148. export class CubeMapToSphericalPolynomialTools {
  46149. private static FileFaces;
  46150. /**
  46151. * Converts a texture to the according Spherical Polynomial data.
  46152. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46153. *
  46154. * @param texture The texture to extract the information from.
  46155. * @return The Spherical Polynomial data.
  46156. */
  46157. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46158. /**
  46159. * Converts a cubemap to the according Spherical Polynomial data.
  46160. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46161. *
  46162. * @param cubeInfo The Cube map to extract the information from.
  46163. * @return The Spherical Polynomial data.
  46164. */
  46165. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46166. }
  46167. }
  46168. declare module BABYLON {
  46169. interface BaseTexture {
  46170. /**
  46171. * Get the polynomial representation of the texture data.
  46172. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46173. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46174. */
  46175. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46176. }
  46177. }
  46178. declare module BABYLON {
  46179. /** @hidden */
  46180. export var rgbdEncodePixelShader: {
  46181. name: string;
  46182. shader: string;
  46183. };
  46184. }
  46185. declare module BABYLON {
  46186. /** @hidden */
  46187. export var rgbdDecodePixelShader: {
  46188. name: string;
  46189. shader: string;
  46190. };
  46191. }
  46192. declare module BABYLON {
  46193. /**
  46194. * Raw texture data and descriptor sufficient for WebGL texture upload
  46195. */
  46196. export interface EnvironmentTextureInfo {
  46197. /**
  46198. * Version of the environment map
  46199. */
  46200. version: number;
  46201. /**
  46202. * Width of image
  46203. */
  46204. width: number;
  46205. /**
  46206. * Irradiance information stored in the file.
  46207. */
  46208. irradiance: any;
  46209. /**
  46210. * Specular information stored in the file.
  46211. */
  46212. specular: any;
  46213. }
  46214. /**
  46215. * Defines One Image in the file. It requires only the position in the file
  46216. * as well as the length.
  46217. */
  46218. interface BufferImageData {
  46219. /**
  46220. * Length of the image data.
  46221. */
  46222. length: number;
  46223. /**
  46224. * Position of the data from the null terminator delimiting the end of the JSON.
  46225. */
  46226. position: number;
  46227. }
  46228. /**
  46229. * Defines the specular data enclosed in the file.
  46230. * This corresponds to the version 1 of the data.
  46231. */
  46232. export interface EnvironmentTextureSpecularInfoV1 {
  46233. /**
  46234. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46235. */
  46236. specularDataPosition?: number;
  46237. /**
  46238. * This contains all the images data needed to reconstruct the cubemap.
  46239. */
  46240. mipmaps: Array<BufferImageData>;
  46241. /**
  46242. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46243. */
  46244. lodGenerationScale: number;
  46245. }
  46246. /**
  46247. * Sets of helpers addressing the serialization and deserialization of environment texture
  46248. * stored in a BabylonJS env file.
  46249. * Those files are usually stored as .env files.
  46250. */
  46251. export class EnvironmentTextureTools {
  46252. /**
  46253. * Magic number identifying the env file.
  46254. */
  46255. private static _MagicBytes;
  46256. /**
  46257. * Gets the environment info from an env file.
  46258. * @param data The array buffer containing the .env bytes.
  46259. * @returns the environment file info (the json header) if successfully parsed.
  46260. */
  46261. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46262. /**
  46263. * Creates an environment texture from a loaded cube texture.
  46264. * @param texture defines the cube texture to convert in env file
  46265. * @return a promise containing the environment data if succesfull.
  46266. */
  46267. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46268. /**
  46269. * Creates a JSON representation of the spherical data.
  46270. * @param texture defines the texture containing the polynomials
  46271. * @return the JSON representation of the spherical info
  46272. */
  46273. private static _CreateEnvTextureIrradiance;
  46274. /**
  46275. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46276. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46277. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46278. * @return the views described by info providing access to the underlying buffer
  46279. */
  46280. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46281. /**
  46282. * Uploads the texture info contained in the env file to the GPU.
  46283. * @param texture defines the internal texture to upload to
  46284. * @param arrayBuffer defines the buffer cotaining the data to load
  46285. * @param info defines the texture info retrieved through the GetEnvInfo method
  46286. * @returns a promise
  46287. */
  46288. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46289. private static _OnImageReadyAsync;
  46290. /**
  46291. * Uploads the levels of image data to the GPU.
  46292. * @param texture defines the internal texture to upload to
  46293. * @param imageData defines the array buffer views of image data [mipmap][face]
  46294. * @returns a promise
  46295. */
  46296. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46297. /**
  46298. * Uploads spherical polynomials information to the texture.
  46299. * @param texture defines the texture we are trying to upload the information to
  46300. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46301. */
  46302. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46303. /** @hidden */
  46304. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46305. }
  46306. }
  46307. declare module BABYLON {
  46308. /**
  46309. * Contains position and normal vectors for a vertex
  46310. */
  46311. export class PositionNormalVertex {
  46312. /** the position of the vertex (defaut: 0,0,0) */
  46313. position: Vector3;
  46314. /** the normal of the vertex (defaut: 0,1,0) */
  46315. normal: Vector3;
  46316. /**
  46317. * Creates a PositionNormalVertex
  46318. * @param position the position of the vertex (defaut: 0,0,0)
  46319. * @param normal the normal of the vertex (defaut: 0,1,0)
  46320. */
  46321. constructor(
  46322. /** the position of the vertex (defaut: 0,0,0) */
  46323. position?: Vector3,
  46324. /** the normal of the vertex (defaut: 0,1,0) */
  46325. normal?: Vector3);
  46326. /**
  46327. * Clones the PositionNormalVertex
  46328. * @returns the cloned PositionNormalVertex
  46329. */
  46330. clone(): PositionNormalVertex;
  46331. }
  46332. /**
  46333. * Contains position, normal and uv vectors for a vertex
  46334. */
  46335. export class PositionNormalTextureVertex {
  46336. /** the position of the vertex (defaut: 0,0,0) */
  46337. position: Vector3;
  46338. /** the normal of the vertex (defaut: 0,1,0) */
  46339. normal: Vector3;
  46340. /** the uv of the vertex (default: 0,0) */
  46341. uv: Vector2;
  46342. /**
  46343. * Creates a PositionNormalTextureVertex
  46344. * @param position the position of the vertex (defaut: 0,0,0)
  46345. * @param normal the normal of the vertex (defaut: 0,1,0)
  46346. * @param uv the uv of the vertex (default: 0,0)
  46347. */
  46348. constructor(
  46349. /** the position of the vertex (defaut: 0,0,0) */
  46350. position?: Vector3,
  46351. /** the normal of the vertex (defaut: 0,1,0) */
  46352. normal?: Vector3,
  46353. /** the uv of the vertex (default: 0,0) */
  46354. uv?: Vector2);
  46355. /**
  46356. * Clones the PositionNormalTextureVertex
  46357. * @returns the cloned PositionNormalTextureVertex
  46358. */
  46359. clone(): PositionNormalTextureVertex;
  46360. }
  46361. }
  46362. declare module BABYLON {
  46363. /** @hidden */
  46364. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46365. private _genericAttributeLocation;
  46366. private _varyingLocationCount;
  46367. private _varyingLocationMap;
  46368. private _replacements;
  46369. private _textureCount;
  46370. private _uniforms;
  46371. lineProcessor(line: string): string;
  46372. attributeProcessor(attribute: string): string;
  46373. varyingProcessor(varying: string, isFragment: boolean): string;
  46374. uniformProcessor(uniform: string): string;
  46375. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46376. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46377. }
  46378. }
  46379. declare module BABYLON {
  46380. /**
  46381. * Container for accessors for natively-stored mesh data buffers.
  46382. */
  46383. class NativeDataBuffer extends DataBuffer {
  46384. /**
  46385. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46386. */
  46387. nativeIndexBuffer?: any;
  46388. /**
  46389. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46390. */
  46391. nativeVertexBuffer?: any;
  46392. }
  46393. /** @hidden */
  46394. class NativeTexture extends InternalTexture {
  46395. getInternalTexture(): InternalTexture;
  46396. getViewCount(): number;
  46397. }
  46398. /** @hidden */
  46399. export class NativeEngine extends Engine {
  46400. private readonly _native;
  46401. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  46402. private readonly INVALID_HANDLE;
  46403. getHardwareScalingLevel(): number;
  46404. constructor();
  46405. /**
  46406. * Can be used to override the current requestAnimationFrame requester.
  46407. * @hidden
  46408. */
  46409. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46410. /**
  46411. * Override default engine behavior.
  46412. * @param color
  46413. * @param backBuffer
  46414. * @param depth
  46415. * @param stencil
  46416. */
  46417. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46418. /**
  46419. * Gets host document
  46420. * @returns the host document object
  46421. */
  46422. getHostDocument(): Nullable<Document>;
  46423. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46424. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46425. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46426. recordVertexArrayObject(vertexBuffers: {
  46427. [key: string]: VertexBuffer;
  46428. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46429. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46430. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46431. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46432. /**
  46433. * Draw a list of indexed primitives
  46434. * @param fillMode defines the primitive to use
  46435. * @param indexStart defines the starting index
  46436. * @param indexCount defines the number of index to draw
  46437. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46438. */
  46439. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46440. /**
  46441. * Draw a list of unindexed primitives
  46442. * @param fillMode defines the primitive to use
  46443. * @param verticesStart defines the index of first vertex to draw
  46444. * @param verticesCount defines the count of vertices to draw
  46445. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46446. */
  46447. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46448. createPipelineContext(): IPipelineContext;
  46449. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46450. /** @hidden */
  46451. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46452. /** @hidden */
  46453. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46454. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46455. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46456. protected _setProgram(program: WebGLProgram): void;
  46457. _releaseEffect(effect: Effect): void;
  46458. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46459. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46460. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46461. bindSamplers(effect: Effect): void;
  46462. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46463. getRenderWidth(useScreen?: boolean): number;
  46464. getRenderHeight(useScreen?: boolean): number;
  46465. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46466. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46467. /**
  46468. * Set the z offset to apply to current rendering
  46469. * @param value defines the offset to apply
  46470. */
  46471. setZOffset(value: number): void;
  46472. /**
  46473. * Gets the current value of the zOffset
  46474. * @returns the current zOffset state
  46475. */
  46476. getZOffset(): number;
  46477. /**
  46478. * Enable or disable depth buffering
  46479. * @param enable defines the state to set
  46480. */
  46481. setDepthBuffer(enable: boolean): void;
  46482. /**
  46483. * Gets a boolean indicating if depth writing is enabled
  46484. * @returns the current depth writing state
  46485. */
  46486. getDepthWrite(): boolean;
  46487. /**
  46488. * Enable or disable depth writing
  46489. * @param enable defines the state to set
  46490. */
  46491. setDepthWrite(enable: boolean): void;
  46492. /**
  46493. * Enable or disable color writing
  46494. * @param enable defines the state to set
  46495. */
  46496. setColorWrite(enable: boolean): void;
  46497. /**
  46498. * Gets a boolean indicating if color writing is enabled
  46499. * @returns the current color writing state
  46500. */
  46501. getColorWrite(): boolean;
  46502. /**
  46503. * Sets alpha constants used by some alpha blending modes
  46504. * @param r defines the red component
  46505. * @param g defines the green component
  46506. * @param b defines the blue component
  46507. * @param a defines the alpha component
  46508. */
  46509. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46510. /**
  46511. * Sets the current alpha mode
  46512. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46513. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46514. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46515. */
  46516. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46517. /**
  46518. * Gets the current alpha mode
  46519. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46520. * @returns the current alpha mode
  46521. */
  46522. getAlphaMode(): number;
  46523. setInt(uniform: WebGLUniformLocation, int: number): void;
  46524. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46525. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46526. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46527. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46528. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46529. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46530. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46531. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46532. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46533. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46534. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46535. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46536. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46537. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46538. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46539. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46540. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46541. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46542. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46543. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46544. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46545. wipeCaches(bruteForce?: boolean): void;
  46546. _createTexture(): WebGLTexture;
  46547. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46548. /**
  46549. * Usually called from BABYLON.Texture.ts.
  46550. * Passed information to create a WebGLTexture
  46551. * @param urlArg defines a value which contains one of the following:
  46552. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46553. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46554. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46555. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46556. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46557. * @param scene needed for loading to the correct scene
  46558. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46559. * @param onLoad optional callback to be called upon successful completion
  46560. * @param onError optional callback to be called upon failure
  46561. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46562. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46563. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46564. * @param forcedExtension defines the extension to use to pick the right loader
  46565. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46566. */
  46567. 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;
  46568. /**
  46569. * Creates a cube texture
  46570. * @param rootUrl defines the url where the files to load is located
  46571. * @param scene defines the current scene
  46572. * @param files defines the list of files to load (1 per face)
  46573. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46574. * @param onLoad defines an optional callback raised when the texture is loaded
  46575. * @param onError defines an optional callback raised if there is an issue to load the texture
  46576. * @param format defines the format of the data
  46577. * @param forcedExtension defines the extension to use to pick the right loader
  46578. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46579. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46580. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46581. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46582. * @returns the cube texture as an InternalTexture
  46583. */
  46584. 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;
  46585. private _getSamplingFilter;
  46586. private static _GetNativeTextureFormat;
  46587. createRenderTargetTexture(size: number | {
  46588. width: number;
  46589. height: number;
  46590. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  46591. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46592. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46593. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46594. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46595. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46596. /**
  46597. * Updates a dynamic vertex buffer.
  46598. * @param vertexBuffer the vertex buffer to update
  46599. * @param data the data used to update the vertex buffer
  46600. * @param byteOffset the byte offset of the data (optional)
  46601. * @param byteLength the byte length of the data (optional)
  46602. */
  46603. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46604. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46605. private _updateAnisotropicLevel;
  46606. private _getAddressMode;
  46607. /** @hidden */
  46608. _bindTexture(channel: number, texture: InternalTexture): void;
  46609. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46610. releaseEffects(): void;
  46611. /** @hidden */
  46612. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46613. /** @hidden */
  46614. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46615. /** @hidden */
  46616. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46617. /** @hidden */
  46618. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46619. }
  46620. }
  46621. declare module BABYLON {
  46622. /**
  46623. * Gather the list of clipboard event types as constants.
  46624. */
  46625. export class ClipboardEventTypes {
  46626. /**
  46627. * The clipboard event is fired when a copy command is active (pressed).
  46628. */
  46629. static readonly COPY: number;
  46630. /**
  46631. * The clipboard event is fired when a cut command is active (pressed).
  46632. */
  46633. static readonly CUT: number;
  46634. /**
  46635. * The clipboard event is fired when a paste command is active (pressed).
  46636. */
  46637. static readonly PASTE: number;
  46638. }
  46639. /**
  46640. * This class is used to store clipboard related info for the onClipboardObservable event.
  46641. */
  46642. export class ClipboardInfo {
  46643. /**
  46644. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46645. */
  46646. type: number;
  46647. /**
  46648. * Defines the related dom event
  46649. */
  46650. event: ClipboardEvent;
  46651. /**
  46652. *Creates an instance of ClipboardInfo.
  46653. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46654. * @param event Defines the related dom event
  46655. */
  46656. constructor(
  46657. /**
  46658. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46659. */
  46660. type: number,
  46661. /**
  46662. * Defines the related dom event
  46663. */
  46664. event: ClipboardEvent);
  46665. /**
  46666. * Get the clipboard event's type from the keycode.
  46667. * @param keyCode Defines the keyCode for the current keyboard event.
  46668. * @return {number}
  46669. */
  46670. static GetTypeFromCharacter(keyCode: number): number;
  46671. }
  46672. }
  46673. declare module BABYLON {
  46674. /**
  46675. * Google Daydream controller
  46676. */
  46677. export class DaydreamController extends WebVRController {
  46678. /**
  46679. * Base Url for the controller model.
  46680. */
  46681. static MODEL_BASE_URL: string;
  46682. /**
  46683. * File name for the controller model.
  46684. */
  46685. static MODEL_FILENAME: string;
  46686. /**
  46687. * Gamepad Id prefix used to identify Daydream Controller.
  46688. */
  46689. static readonly GAMEPAD_ID_PREFIX: string;
  46690. /**
  46691. * Creates a new DaydreamController from a gamepad
  46692. * @param vrGamepad the gamepad that the controller should be created from
  46693. */
  46694. constructor(vrGamepad: any);
  46695. /**
  46696. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46697. * @param scene scene in which to add meshes
  46698. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46699. */
  46700. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46701. /**
  46702. * Called once for each button that changed state since the last frame
  46703. * @param buttonIdx Which button index changed
  46704. * @param state New state of the button
  46705. * @param changes Which properties on the state changed since last frame
  46706. */
  46707. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46708. }
  46709. }
  46710. declare module BABYLON {
  46711. /**
  46712. * Gear VR Controller
  46713. */
  46714. export class GearVRController extends WebVRController {
  46715. /**
  46716. * Base Url for the controller model.
  46717. */
  46718. static MODEL_BASE_URL: string;
  46719. /**
  46720. * File name for the controller model.
  46721. */
  46722. static MODEL_FILENAME: string;
  46723. /**
  46724. * Gamepad Id prefix used to identify this controller.
  46725. */
  46726. static readonly GAMEPAD_ID_PREFIX: string;
  46727. private readonly _buttonIndexToObservableNameMap;
  46728. /**
  46729. * Creates a new GearVRController from a gamepad
  46730. * @param vrGamepad the gamepad that the controller should be created from
  46731. */
  46732. constructor(vrGamepad: any);
  46733. /**
  46734. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46735. * @param scene scene in which to add meshes
  46736. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46737. */
  46738. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46739. /**
  46740. * Called once for each button that changed state since the last frame
  46741. * @param buttonIdx Which button index changed
  46742. * @param state New state of the button
  46743. * @param changes Which properties on the state changed since last frame
  46744. */
  46745. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46746. }
  46747. }
  46748. declare module BABYLON {
  46749. /**
  46750. * Class containing static functions to help procedurally build meshes
  46751. */
  46752. export class PolyhedronBuilder {
  46753. /**
  46754. * Creates a polyhedron mesh
  46755. * * 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
  46756. * * The parameter `size` (positive float, default 1) sets the polygon size
  46757. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46758. * * 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`
  46759. * * 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
  46760. * * 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)`)
  46761. * * 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
  46762. * * 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
  46763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46764. * * 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
  46765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46766. * @param name defines the name of the mesh
  46767. * @param options defines the options used to create the mesh
  46768. * @param scene defines the hosting scene
  46769. * @returns the polyhedron mesh
  46770. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46771. */
  46772. static CreatePolyhedron(name: string, options: {
  46773. type?: number;
  46774. size?: number;
  46775. sizeX?: number;
  46776. sizeY?: number;
  46777. sizeZ?: number;
  46778. custom?: any;
  46779. faceUV?: Vector4[];
  46780. faceColors?: Color4[];
  46781. flat?: boolean;
  46782. updatable?: boolean;
  46783. sideOrientation?: number;
  46784. frontUVs?: Vector4;
  46785. backUVs?: Vector4;
  46786. }, scene?: Nullable<Scene>): Mesh;
  46787. }
  46788. }
  46789. declare module BABYLON {
  46790. /**
  46791. * Gizmo that enables scaling a mesh along 3 axis
  46792. */
  46793. export class ScaleGizmo extends Gizmo {
  46794. /**
  46795. * Internal gizmo used for interactions on the x axis
  46796. */
  46797. xGizmo: AxisScaleGizmo;
  46798. /**
  46799. * Internal gizmo used for interactions on the y axis
  46800. */
  46801. yGizmo: AxisScaleGizmo;
  46802. /**
  46803. * Internal gizmo used for interactions on the z axis
  46804. */
  46805. zGizmo: AxisScaleGizmo;
  46806. /**
  46807. * Internal gizmo used to scale all axis equally
  46808. */
  46809. uniformScaleGizmo: AxisScaleGizmo;
  46810. private _meshAttached;
  46811. private _updateGizmoRotationToMatchAttachedMesh;
  46812. private _snapDistance;
  46813. private _scaleRatio;
  46814. private _uniformScalingMesh;
  46815. private _octahedron;
  46816. private _sensitivity;
  46817. /** Fires an event when any of it's sub gizmos are dragged */
  46818. onDragStartObservable: Observable<unknown>;
  46819. /** Fires an event when any of it's sub gizmos are released from dragging */
  46820. onDragEndObservable: Observable<unknown>;
  46821. attachedMesh: Nullable<AbstractMesh>;
  46822. /**
  46823. * Creates a ScaleGizmo
  46824. * @param gizmoLayer The utility layer the gizmo will be added to
  46825. */
  46826. constructor(gizmoLayer?: UtilityLayerRenderer);
  46827. updateGizmoRotationToMatchAttachedMesh: boolean;
  46828. /**
  46829. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46830. */
  46831. snapDistance: number;
  46832. /**
  46833. * Ratio for the scale of the gizmo (Default: 1)
  46834. */
  46835. scaleRatio: number;
  46836. /**
  46837. * Sensitivity factor for dragging (Default: 1)
  46838. */
  46839. sensitivity: number;
  46840. /**
  46841. * Disposes of the gizmo
  46842. */
  46843. dispose(): void;
  46844. }
  46845. }
  46846. declare module BABYLON {
  46847. /**
  46848. * Single axis scale gizmo
  46849. */
  46850. export class AxisScaleGizmo extends Gizmo {
  46851. /**
  46852. * Drag behavior responsible for the gizmos dragging interactions
  46853. */
  46854. dragBehavior: PointerDragBehavior;
  46855. private _pointerObserver;
  46856. /**
  46857. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46858. */
  46859. snapDistance: number;
  46860. /**
  46861. * Event that fires each time the gizmo snaps to a new location.
  46862. * * snapDistance is the the change in distance
  46863. */
  46864. onSnapObservable: Observable<{
  46865. snapDistance: number;
  46866. }>;
  46867. /**
  46868. * If the scaling operation should be done on all axis (default: false)
  46869. */
  46870. uniformScaling: boolean;
  46871. /**
  46872. * Custom sensitivity value for the drag strength
  46873. */
  46874. sensitivity: number;
  46875. private _isEnabled;
  46876. private _parent;
  46877. private _arrow;
  46878. private _coloredMaterial;
  46879. private _hoverMaterial;
  46880. /**
  46881. * Creates an AxisScaleGizmo
  46882. * @param gizmoLayer The utility layer the gizmo will be added to
  46883. * @param dragAxis The axis which the gizmo will be able to scale on
  46884. * @param color The color of the gizmo
  46885. */
  46886. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46887. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46888. /**
  46889. * If the gizmo is enabled
  46890. */
  46891. isEnabled: boolean;
  46892. /**
  46893. * Disposes of the gizmo
  46894. */
  46895. dispose(): void;
  46896. /**
  46897. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46898. * @param mesh The mesh to replace the default mesh of the gizmo
  46899. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46900. */
  46901. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46902. }
  46903. }
  46904. declare module BABYLON {
  46905. /**
  46906. * Bounding box gizmo
  46907. */
  46908. export class BoundingBoxGizmo extends Gizmo {
  46909. private _lineBoundingBox;
  46910. private _rotateSpheresParent;
  46911. private _scaleBoxesParent;
  46912. private _boundingDimensions;
  46913. private _renderObserver;
  46914. private _pointerObserver;
  46915. private _scaleDragSpeed;
  46916. private _tmpQuaternion;
  46917. private _tmpVector;
  46918. private _tmpRotationMatrix;
  46919. /**
  46920. * 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)
  46921. */
  46922. ignoreChildren: boolean;
  46923. /**
  46924. * 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)
  46925. */
  46926. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46927. /**
  46928. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46929. */
  46930. rotationSphereSize: number;
  46931. /**
  46932. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46933. */
  46934. scaleBoxSize: number;
  46935. /**
  46936. * 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)
  46937. */
  46938. fixedDragMeshScreenSize: boolean;
  46939. /**
  46940. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46941. */
  46942. fixedDragMeshScreenSizeDistanceFactor: number;
  46943. /**
  46944. * Fired when a rotation sphere or scale box is dragged
  46945. */
  46946. onDragStartObservable: Observable<{}>;
  46947. /**
  46948. * Fired when a scale box is dragged
  46949. */
  46950. onScaleBoxDragObservable: Observable<{}>;
  46951. /**
  46952. * Fired when a scale box drag is ended
  46953. */
  46954. onScaleBoxDragEndObservable: Observable<{}>;
  46955. /**
  46956. * Fired when a rotation sphere is dragged
  46957. */
  46958. onRotationSphereDragObservable: Observable<{}>;
  46959. /**
  46960. * Fired when a rotation sphere drag is ended
  46961. */
  46962. onRotationSphereDragEndObservable: Observable<{}>;
  46963. /**
  46964. * 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)
  46965. */
  46966. scalePivot: Nullable<Vector3>;
  46967. /**
  46968. * Mesh used as a pivot to rotate the attached mesh
  46969. */
  46970. private _anchorMesh;
  46971. private _existingMeshScale;
  46972. private _dragMesh;
  46973. private pointerDragBehavior;
  46974. private coloredMaterial;
  46975. private hoverColoredMaterial;
  46976. /**
  46977. * Sets the color of the bounding box gizmo
  46978. * @param color the color to set
  46979. */
  46980. setColor(color: Color3): void;
  46981. /**
  46982. * Creates an BoundingBoxGizmo
  46983. * @param gizmoLayer The utility layer the gizmo will be added to
  46984. * @param color The color of the gizmo
  46985. */
  46986. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46987. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46988. private _selectNode;
  46989. /**
  46990. * Updates the bounding box information for the Gizmo
  46991. */
  46992. updateBoundingBox(): void;
  46993. private _updateRotationSpheres;
  46994. private _updateScaleBoxes;
  46995. /**
  46996. * Enables rotation on the specified axis and disables rotation on the others
  46997. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46998. */
  46999. setEnabledRotationAxis(axis: string): void;
  47000. /**
  47001. * Enables/disables scaling
  47002. * @param enable if scaling should be enabled
  47003. */
  47004. setEnabledScaling(enable: boolean): void;
  47005. private _updateDummy;
  47006. /**
  47007. * Enables a pointer drag behavior on the bounding box of the gizmo
  47008. */
  47009. enableDragBehavior(): void;
  47010. /**
  47011. * Disposes of the gizmo
  47012. */
  47013. dispose(): void;
  47014. /**
  47015. * 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)
  47016. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47017. * @returns the bounding box mesh with the passed in mesh as a child
  47018. */
  47019. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47020. /**
  47021. * CustomMeshes are not supported by this gizmo
  47022. * @param mesh The mesh to replace the default mesh of the gizmo
  47023. */
  47024. setCustomMesh(mesh: Mesh): void;
  47025. }
  47026. }
  47027. declare module BABYLON {
  47028. /**
  47029. * Single plane rotation gizmo
  47030. */
  47031. export class PlaneRotationGizmo extends Gizmo {
  47032. /**
  47033. * Drag behavior responsible for the gizmos dragging interactions
  47034. */
  47035. dragBehavior: PointerDragBehavior;
  47036. private _pointerObserver;
  47037. /**
  47038. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47039. */
  47040. snapDistance: number;
  47041. /**
  47042. * Event that fires each time the gizmo snaps to a new location.
  47043. * * snapDistance is the the change in distance
  47044. */
  47045. onSnapObservable: Observable<{
  47046. snapDistance: number;
  47047. }>;
  47048. private _isEnabled;
  47049. private _parent;
  47050. /**
  47051. * Creates a PlaneRotationGizmo
  47052. * @param gizmoLayer The utility layer the gizmo will be added to
  47053. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47054. * @param color The color of the gizmo
  47055. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47056. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47057. */
  47058. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47059. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47060. /**
  47061. * If the gizmo is enabled
  47062. */
  47063. isEnabled: boolean;
  47064. /**
  47065. * Disposes of the gizmo
  47066. */
  47067. dispose(): void;
  47068. }
  47069. }
  47070. declare module BABYLON {
  47071. /**
  47072. * Gizmo that enables rotating a mesh along 3 axis
  47073. */
  47074. export class RotationGizmo extends Gizmo {
  47075. /**
  47076. * Internal gizmo used for interactions on the x axis
  47077. */
  47078. xGizmo: PlaneRotationGizmo;
  47079. /**
  47080. * Internal gizmo used for interactions on the y axis
  47081. */
  47082. yGizmo: PlaneRotationGizmo;
  47083. /**
  47084. * Internal gizmo used for interactions on the z axis
  47085. */
  47086. zGizmo: PlaneRotationGizmo;
  47087. /** Fires an event when any of it's sub gizmos are dragged */
  47088. onDragStartObservable: Observable<unknown>;
  47089. /** Fires an event when any of it's sub gizmos are released from dragging */
  47090. onDragEndObservable: Observable<unknown>;
  47091. private _meshAttached;
  47092. attachedMesh: Nullable<AbstractMesh>;
  47093. /**
  47094. * Creates a RotationGizmo
  47095. * @param gizmoLayer The utility layer the gizmo will be added to
  47096. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47097. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47098. */
  47099. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47100. updateGizmoRotationToMatchAttachedMesh: boolean;
  47101. /**
  47102. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47103. */
  47104. snapDistance: number;
  47105. /**
  47106. * Ratio for the scale of the gizmo (Default: 1)
  47107. */
  47108. scaleRatio: number;
  47109. /**
  47110. * Disposes of the gizmo
  47111. */
  47112. dispose(): void;
  47113. /**
  47114. * CustomMeshes are not supported by this gizmo
  47115. * @param mesh The mesh to replace the default mesh of the gizmo
  47116. */
  47117. setCustomMesh(mesh: Mesh): void;
  47118. }
  47119. }
  47120. declare module BABYLON {
  47121. /**
  47122. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47123. */
  47124. export class GizmoManager implements IDisposable {
  47125. private scene;
  47126. /**
  47127. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47128. */
  47129. gizmos: {
  47130. positionGizmo: Nullable<PositionGizmo>;
  47131. rotationGizmo: Nullable<RotationGizmo>;
  47132. scaleGizmo: Nullable<ScaleGizmo>;
  47133. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47134. };
  47135. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47136. clearGizmoOnEmptyPointerEvent: boolean;
  47137. /** Fires an event when the manager is attached to a mesh */
  47138. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47139. private _gizmosEnabled;
  47140. private _pointerObserver;
  47141. private _attachedMesh;
  47142. private _boundingBoxColor;
  47143. private _defaultUtilityLayer;
  47144. private _defaultKeepDepthUtilityLayer;
  47145. /**
  47146. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47147. */
  47148. boundingBoxDragBehavior: SixDofDragBehavior;
  47149. /**
  47150. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47151. */
  47152. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47153. /**
  47154. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47155. */
  47156. usePointerToAttachGizmos: boolean;
  47157. /**
  47158. * Utility layer that the bounding box gizmo belongs to
  47159. */
  47160. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47161. /**
  47162. * Utility layer that all gizmos besides bounding box belong to
  47163. */
  47164. readonly utilityLayer: UtilityLayerRenderer;
  47165. /**
  47166. * Instatiates a gizmo manager
  47167. * @param scene the scene to overlay the gizmos on top of
  47168. */
  47169. constructor(scene: Scene);
  47170. /**
  47171. * Attaches a set of gizmos to the specified mesh
  47172. * @param mesh The mesh the gizmo's should be attached to
  47173. */
  47174. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47175. /**
  47176. * If the position gizmo is enabled
  47177. */
  47178. positionGizmoEnabled: boolean;
  47179. /**
  47180. * If the rotation gizmo is enabled
  47181. */
  47182. rotationGizmoEnabled: boolean;
  47183. /**
  47184. * If the scale gizmo is enabled
  47185. */
  47186. scaleGizmoEnabled: boolean;
  47187. /**
  47188. * If the boundingBox gizmo is enabled
  47189. */
  47190. boundingBoxGizmoEnabled: boolean;
  47191. /**
  47192. * Disposes of the gizmo manager
  47193. */
  47194. dispose(): void;
  47195. }
  47196. }
  47197. declare module BABYLON {
  47198. /**
  47199. * A directional light is defined by a direction (what a surprise!).
  47200. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47201. * 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.
  47202. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47203. */
  47204. export class DirectionalLight extends ShadowLight {
  47205. private _shadowFrustumSize;
  47206. /**
  47207. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47208. */
  47209. /**
  47210. * Specifies a fix frustum size for the shadow generation.
  47211. */
  47212. shadowFrustumSize: number;
  47213. private _shadowOrthoScale;
  47214. /**
  47215. * Gets the shadow projection scale against the optimal computed one.
  47216. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47217. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47218. */
  47219. /**
  47220. * Sets the shadow projection scale against the optimal computed one.
  47221. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47222. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47223. */
  47224. shadowOrthoScale: number;
  47225. /**
  47226. * Automatically compute the projection matrix to best fit (including all the casters)
  47227. * on each frame.
  47228. */
  47229. autoUpdateExtends: boolean;
  47230. private _orthoLeft;
  47231. private _orthoRight;
  47232. private _orthoTop;
  47233. private _orthoBottom;
  47234. /**
  47235. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47236. * The directional light is emitted from everywhere in the given direction.
  47237. * It can cast shadows.
  47238. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47239. * @param name The friendly name of the light
  47240. * @param direction The direction of the light
  47241. * @param scene The scene the light belongs to
  47242. */
  47243. constructor(name: string, direction: Vector3, scene: Scene);
  47244. /**
  47245. * Returns the string "DirectionalLight".
  47246. * @return The class name
  47247. */
  47248. getClassName(): string;
  47249. /**
  47250. * Returns the integer 1.
  47251. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47252. */
  47253. getTypeID(): number;
  47254. /**
  47255. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47256. * Returns the DirectionalLight Shadow projection matrix.
  47257. */
  47258. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47259. /**
  47260. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47261. * Returns the DirectionalLight Shadow projection matrix.
  47262. */
  47263. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47264. /**
  47265. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47266. * Returns the DirectionalLight Shadow projection matrix.
  47267. */
  47268. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47269. protected _buildUniformLayout(): void;
  47270. /**
  47271. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47272. * @param effect The effect to update
  47273. * @param lightIndex The index of the light in the effect to update
  47274. * @returns The directional light
  47275. */
  47276. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47277. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47278. /**
  47279. * Gets the minZ used for shadow according to both the scene and the light.
  47280. *
  47281. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47282. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47283. * @param activeCamera The camera we are returning the min for
  47284. * @returns the depth min z
  47285. */
  47286. getDepthMinZ(activeCamera: Camera): number;
  47287. /**
  47288. * Gets the maxZ used for shadow according to both the scene and the light.
  47289. *
  47290. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47291. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47292. * @param activeCamera The camera we are returning the max for
  47293. * @returns the depth max z
  47294. */
  47295. getDepthMaxZ(activeCamera: Camera): number;
  47296. /**
  47297. * Prepares the list of defines specific to the light type.
  47298. * @param defines the list of defines
  47299. * @param lightIndex defines the index of the light for the effect
  47300. */
  47301. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47302. }
  47303. }
  47304. declare module BABYLON {
  47305. /**
  47306. * Class containing static functions to help procedurally build meshes
  47307. */
  47308. export class HemisphereBuilder {
  47309. /**
  47310. * Creates a hemisphere mesh
  47311. * @param name defines the name of the mesh
  47312. * @param options defines the options used to create the mesh
  47313. * @param scene defines the hosting scene
  47314. * @returns the hemisphere mesh
  47315. */
  47316. static CreateHemisphere(name: string, options: {
  47317. segments?: number;
  47318. diameter?: number;
  47319. sideOrientation?: number;
  47320. }, scene: any): Mesh;
  47321. }
  47322. }
  47323. declare module BABYLON {
  47324. /**
  47325. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47326. * These values define a cone of light starting from the position, emitting toward the direction.
  47327. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47328. * and the exponent defines the speed of the decay of the light with distance (reach).
  47329. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47330. */
  47331. export class SpotLight extends ShadowLight {
  47332. private _angle;
  47333. private _innerAngle;
  47334. private _cosHalfAngle;
  47335. private _lightAngleScale;
  47336. private _lightAngleOffset;
  47337. /**
  47338. * Gets the cone angle of the spot light in Radians.
  47339. */
  47340. /**
  47341. * Sets the cone angle of the spot light in Radians.
  47342. */
  47343. angle: number;
  47344. /**
  47345. * Only used in gltf falloff mode, this defines the angle where
  47346. * the directional falloff will start before cutting at angle which could be seen
  47347. * as outer angle.
  47348. */
  47349. /**
  47350. * Only used in gltf falloff mode, this defines the angle where
  47351. * the directional falloff will start before cutting at angle which could be seen
  47352. * as outer angle.
  47353. */
  47354. innerAngle: number;
  47355. private _shadowAngleScale;
  47356. /**
  47357. * Allows scaling the angle of the light for shadow generation only.
  47358. */
  47359. /**
  47360. * Allows scaling the angle of the light for shadow generation only.
  47361. */
  47362. shadowAngleScale: number;
  47363. /**
  47364. * The light decay speed with the distance from the emission spot.
  47365. */
  47366. exponent: number;
  47367. private _projectionTextureMatrix;
  47368. /**
  47369. * Allows reading the projecton texture
  47370. */
  47371. readonly projectionTextureMatrix: Matrix;
  47372. protected _projectionTextureLightNear: number;
  47373. /**
  47374. * Gets the near clip of the Spotlight for texture projection.
  47375. */
  47376. /**
  47377. * Sets the near clip of the Spotlight for texture projection.
  47378. */
  47379. projectionTextureLightNear: number;
  47380. protected _projectionTextureLightFar: number;
  47381. /**
  47382. * Gets the far clip of the Spotlight for texture projection.
  47383. */
  47384. /**
  47385. * Sets the far clip of the Spotlight for texture projection.
  47386. */
  47387. projectionTextureLightFar: number;
  47388. protected _projectionTextureUpDirection: Vector3;
  47389. /**
  47390. * Gets the Up vector of the Spotlight for texture projection.
  47391. */
  47392. /**
  47393. * Sets the Up vector of the Spotlight for texture projection.
  47394. */
  47395. projectionTextureUpDirection: Vector3;
  47396. private _projectionTexture;
  47397. /**
  47398. * Gets the projection texture of the light.
  47399. */
  47400. /**
  47401. * Sets the projection texture of the light.
  47402. */
  47403. projectionTexture: Nullable<BaseTexture>;
  47404. private _projectionTextureViewLightDirty;
  47405. private _projectionTextureProjectionLightDirty;
  47406. private _projectionTextureDirty;
  47407. private _projectionTextureViewTargetVector;
  47408. private _projectionTextureViewLightMatrix;
  47409. private _projectionTextureProjectionLightMatrix;
  47410. private _projectionTextureScalingMatrix;
  47411. /**
  47412. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47413. * It can cast shadows.
  47414. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47415. * @param name The light friendly name
  47416. * @param position The position of the spot light in the scene
  47417. * @param direction The direction of the light in the scene
  47418. * @param angle The cone angle of the light in Radians
  47419. * @param exponent The light decay speed with the distance from the emission spot
  47420. * @param scene The scene the lights belongs to
  47421. */
  47422. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47423. /**
  47424. * Returns the string "SpotLight".
  47425. * @returns the class name
  47426. */
  47427. getClassName(): string;
  47428. /**
  47429. * Returns the integer 2.
  47430. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47431. */
  47432. getTypeID(): number;
  47433. /**
  47434. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47435. */
  47436. protected _setDirection(value: Vector3): void;
  47437. /**
  47438. * Overrides the position setter to recompute the projection texture view light Matrix.
  47439. */
  47440. protected _setPosition(value: Vector3): void;
  47441. /**
  47442. * 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.
  47443. * Returns the SpotLight.
  47444. */
  47445. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47446. protected _computeProjectionTextureViewLightMatrix(): void;
  47447. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47448. /**
  47449. * Main function for light texture projection matrix computing.
  47450. */
  47451. protected _computeProjectionTextureMatrix(): void;
  47452. protected _buildUniformLayout(): void;
  47453. private _computeAngleValues;
  47454. /**
  47455. * Sets the passed Effect "effect" with the Light textures.
  47456. * @param effect The effect to update
  47457. * @param lightIndex The index of the light in the effect to update
  47458. * @returns The light
  47459. */
  47460. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  47461. /**
  47462. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47463. * @param effect The effect to update
  47464. * @param lightIndex The index of the light in the effect to update
  47465. * @returns The spot light
  47466. */
  47467. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47468. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47469. /**
  47470. * Disposes the light and the associated resources.
  47471. */
  47472. dispose(): void;
  47473. /**
  47474. * Prepares the list of defines specific to the light type.
  47475. * @param defines the list of defines
  47476. * @param lightIndex defines the index of the light for the effect
  47477. */
  47478. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47479. }
  47480. }
  47481. declare module BABYLON {
  47482. /**
  47483. * Gizmo that enables viewing a light
  47484. */
  47485. export class LightGizmo extends Gizmo {
  47486. private _lightMesh;
  47487. private _material;
  47488. private _cachedPosition;
  47489. private _cachedForward;
  47490. private _attachedMeshParent;
  47491. /**
  47492. * Creates a LightGizmo
  47493. * @param gizmoLayer The utility layer the gizmo will be added to
  47494. */
  47495. constructor(gizmoLayer?: UtilityLayerRenderer);
  47496. private _light;
  47497. /**
  47498. * The light that the gizmo is attached to
  47499. */
  47500. light: Nullable<Light>;
  47501. /**
  47502. * Gets the material used to render the light gizmo
  47503. */
  47504. readonly material: StandardMaterial;
  47505. /**
  47506. * @hidden
  47507. * Updates the gizmo to match the attached mesh's position/rotation
  47508. */
  47509. protected _update(): void;
  47510. private static _Scale;
  47511. /**
  47512. * Creates the lines for a light mesh
  47513. */
  47514. private static _CreateLightLines;
  47515. /**
  47516. * Disposes of the light gizmo
  47517. */
  47518. dispose(): void;
  47519. private static _CreateHemisphericLightMesh;
  47520. private static _CreatePointLightMesh;
  47521. private static _CreateSpotLightMesh;
  47522. private static _CreateDirectionalLightMesh;
  47523. }
  47524. }
  47525. declare module BABYLON {
  47526. /** @hidden */
  47527. export var backgroundFragmentDeclaration: {
  47528. name: string;
  47529. shader: string;
  47530. };
  47531. }
  47532. declare module BABYLON {
  47533. /** @hidden */
  47534. export var backgroundUboDeclaration: {
  47535. name: string;
  47536. shader: string;
  47537. };
  47538. }
  47539. declare module BABYLON {
  47540. /** @hidden */
  47541. export var backgroundPixelShader: {
  47542. name: string;
  47543. shader: string;
  47544. };
  47545. }
  47546. declare module BABYLON {
  47547. /** @hidden */
  47548. export var backgroundVertexDeclaration: {
  47549. name: string;
  47550. shader: string;
  47551. };
  47552. }
  47553. declare module BABYLON {
  47554. /** @hidden */
  47555. export var backgroundVertexShader: {
  47556. name: string;
  47557. shader: string;
  47558. };
  47559. }
  47560. declare module BABYLON {
  47561. /**
  47562. * Background material used to create an efficient environement around your scene.
  47563. */
  47564. export class BackgroundMaterial extends PushMaterial {
  47565. /**
  47566. * Standard reflectance value at parallel view angle.
  47567. */
  47568. static StandardReflectance0: number;
  47569. /**
  47570. * Standard reflectance value at grazing angle.
  47571. */
  47572. static StandardReflectance90: number;
  47573. protected _primaryColor: Color3;
  47574. /**
  47575. * Key light Color (multiply against the environement texture)
  47576. */
  47577. primaryColor: Color3;
  47578. protected __perceptualColor: Nullable<Color3>;
  47579. /**
  47580. * Experimental Internal Use Only.
  47581. *
  47582. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47583. * This acts as a helper to set the primary color to a more "human friendly" value.
  47584. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47585. * output color as close as possible from the chosen value.
  47586. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47587. * part of lighting setup.)
  47588. */
  47589. _perceptualColor: Nullable<Color3>;
  47590. protected _primaryColorShadowLevel: float;
  47591. /**
  47592. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47593. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47594. */
  47595. primaryColorShadowLevel: float;
  47596. protected _primaryColorHighlightLevel: float;
  47597. /**
  47598. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47599. * The primary color is used at the level chosen to define what the white area would look.
  47600. */
  47601. primaryColorHighlightLevel: float;
  47602. protected _reflectionTexture: Nullable<BaseTexture>;
  47603. /**
  47604. * Reflection Texture used in the material.
  47605. * Should be author in a specific way for the best result (refer to the documentation).
  47606. */
  47607. reflectionTexture: Nullable<BaseTexture>;
  47608. protected _reflectionBlur: float;
  47609. /**
  47610. * Reflection Texture level of blur.
  47611. *
  47612. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47613. * texture twice.
  47614. */
  47615. reflectionBlur: float;
  47616. protected _diffuseTexture: Nullable<BaseTexture>;
  47617. /**
  47618. * Diffuse Texture used in the material.
  47619. * Should be author in a specific way for the best result (refer to the documentation).
  47620. */
  47621. diffuseTexture: Nullable<BaseTexture>;
  47622. protected _shadowLights: Nullable<IShadowLight[]>;
  47623. /**
  47624. * Specify the list of lights casting shadow on the material.
  47625. * All scene shadow lights will be included if null.
  47626. */
  47627. shadowLights: Nullable<IShadowLight[]>;
  47628. protected _shadowLevel: float;
  47629. /**
  47630. * Helps adjusting the shadow to a softer level if required.
  47631. * 0 means black shadows and 1 means no shadows.
  47632. */
  47633. shadowLevel: float;
  47634. protected _sceneCenter: Vector3;
  47635. /**
  47636. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47637. * It is usually zero but might be interesting to modify according to your setup.
  47638. */
  47639. sceneCenter: Vector3;
  47640. protected _opacityFresnel: boolean;
  47641. /**
  47642. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47643. * This helps ensuring a nice transition when the camera goes under the ground.
  47644. */
  47645. opacityFresnel: boolean;
  47646. protected _reflectionFresnel: boolean;
  47647. /**
  47648. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47649. * This helps adding a mirror texture on the ground.
  47650. */
  47651. reflectionFresnel: boolean;
  47652. protected _reflectionFalloffDistance: number;
  47653. /**
  47654. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47655. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47656. */
  47657. reflectionFalloffDistance: number;
  47658. protected _reflectionAmount: number;
  47659. /**
  47660. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47661. */
  47662. reflectionAmount: number;
  47663. protected _reflectionReflectance0: number;
  47664. /**
  47665. * This specifies the weight of the reflection at grazing angle.
  47666. */
  47667. reflectionReflectance0: number;
  47668. protected _reflectionReflectance90: number;
  47669. /**
  47670. * This specifies the weight of the reflection at a perpendicular point of view.
  47671. */
  47672. reflectionReflectance90: number;
  47673. /**
  47674. * Sets the reflection reflectance fresnel values according to the default standard
  47675. * empirically know to work well :-)
  47676. */
  47677. reflectionStandardFresnelWeight: number;
  47678. protected _useRGBColor: boolean;
  47679. /**
  47680. * Helps to directly use the maps channels instead of their level.
  47681. */
  47682. useRGBColor: boolean;
  47683. protected _enableNoise: boolean;
  47684. /**
  47685. * This helps reducing the banding effect that could occur on the background.
  47686. */
  47687. enableNoise: boolean;
  47688. /**
  47689. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47690. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47691. * Recommended to be keep at 1.0 except for special cases.
  47692. */
  47693. fovMultiplier: number;
  47694. private _fovMultiplier;
  47695. /**
  47696. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47697. */
  47698. useEquirectangularFOV: boolean;
  47699. private _maxSimultaneousLights;
  47700. /**
  47701. * Number of Simultaneous lights allowed on the material.
  47702. */
  47703. maxSimultaneousLights: int;
  47704. /**
  47705. * Default configuration related to image processing available in the Background Material.
  47706. */
  47707. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47708. /**
  47709. * Keep track of the image processing observer to allow dispose and replace.
  47710. */
  47711. private _imageProcessingObserver;
  47712. /**
  47713. * Attaches a new image processing configuration to the PBR Material.
  47714. * @param configuration (if null the scene configuration will be use)
  47715. */
  47716. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47717. /**
  47718. * Gets the image processing configuration used either in this material.
  47719. */
  47720. /**
  47721. * Sets the Default image processing configuration used either in the this material.
  47722. *
  47723. * If sets to null, the scene one is in use.
  47724. */
  47725. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47726. /**
  47727. * Gets wether the color curves effect is enabled.
  47728. */
  47729. /**
  47730. * Sets wether the color curves effect is enabled.
  47731. */
  47732. cameraColorCurvesEnabled: boolean;
  47733. /**
  47734. * Gets wether the color grading effect is enabled.
  47735. */
  47736. /**
  47737. * Gets wether the color grading effect is enabled.
  47738. */
  47739. cameraColorGradingEnabled: boolean;
  47740. /**
  47741. * Gets wether tonemapping is enabled or not.
  47742. */
  47743. /**
  47744. * Sets wether tonemapping is enabled or not
  47745. */
  47746. cameraToneMappingEnabled: boolean;
  47747. /**
  47748. * The camera exposure used on this material.
  47749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47750. * This corresponds to a photographic exposure.
  47751. */
  47752. /**
  47753. * The camera exposure used on this material.
  47754. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47755. * This corresponds to a photographic exposure.
  47756. */
  47757. cameraExposure: float;
  47758. /**
  47759. * Gets The camera contrast used on this material.
  47760. */
  47761. /**
  47762. * Sets The camera contrast used on this material.
  47763. */
  47764. cameraContrast: float;
  47765. /**
  47766. * Gets the Color Grading 2D Lookup Texture.
  47767. */
  47768. /**
  47769. * Sets the Color Grading 2D Lookup Texture.
  47770. */
  47771. cameraColorGradingTexture: Nullable<BaseTexture>;
  47772. /**
  47773. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47774. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47775. * 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;
  47776. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47777. */
  47778. /**
  47779. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47780. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47781. * 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;
  47782. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47783. */
  47784. cameraColorCurves: Nullable<ColorCurves>;
  47785. /**
  47786. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47787. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47788. */
  47789. switchToBGR: boolean;
  47790. private _renderTargets;
  47791. private _reflectionControls;
  47792. private _white;
  47793. private _primaryShadowColor;
  47794. private _primaryHighlightColor;
  47795. /**
  47796. * Instantiates a Background Material in the given scene
  47797. * @param name The friendly name of the material
  47798. * @param scene The scene to add the material to
  47799. */
  47800. constructor(name: string, scene: Scene);
  47801. /**
  47802. * Gets a boolean indicating that current material needs to register RTT
  47803. */
  47804. readonly hasRenderTargetTextures: boolean;
  47805. /**
  47806. * The entire material has been created in order to prevent overdraw.
  47807. * @returns false
  47808. */
  47809. needAlphaTesting(): boolean;
  47810. /**
  47811. * The entire material has been created in order to prevent overdraw.
  47812. * @returns true if blending is enable
  47813. */
  47814. needAlphaBlending(): boolean;
  47815. /**
  47816. * Checks wether the material is ready to be rendered for a given mesh.
  47817. * @param mesh The mesh to render
  47818. * @param subMesh The submesh to check against
  47819. * @param useInstances Specify wether or not the material is used with instances
  47820. * @returns true if all the dependencies are ready (Textures, Effects...)
  47821. */
  47822. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47823. /**
  47824. * Compute the primary color according to the chosen perceptual color.
  47825. */
  47826. private _computePrimaryColorFromPerceptualColor;
  47827. /**
  47828. * Compute the highlights and shadow colors according to their chosen levels.
  47829. */
  47830. private _computePrimaryColors;
  47831. /**
  47832. * Build the uniform buffer used in the material.
  47833. */
  47834. buildUniformLayout(): void;
  47835. /**
  47836. * Unbind the material.
  47837. */
  47838. unbind(): void;
  47839. /**
  47840. * Bind only the world matrix to the material.
  47841. * @param world The world matrix to bind.
  47842. */
  47843. bindOnlyWorldMatrix(world: Matrix): void;
  47844. /**
  47845. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47846. * @param world The world matrix to bind.
  47847. * @param subMesh The submesh to bind for.
  47848. */
  47849. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47850. /**
  47851. * Checks to see if a texture is used in the material.
  47852. * @param texture - Base texture to use.
  47853. * @returns - Boolean specifying if a texture is used in the material.
  47854. */
  47855. hasTexture(texture: BaseTexture): boolean;
  47856. /**
  47857. * Dispose the material.
  47858. * @param forceDisposeEffect Force disposal of the associated effect.
  47859. * @param forceDisposeTextures Force disposal of the associated textures.
  47860. */
  47861. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47862. /**
  47863. * Clones the material.
  47864. * @param name The cloned name.
  47865. * @returns The cloned material.
  47866. */
  47867. clone(name: string): BackgroundMaterial;
  47868. /**
  47869. * Serializes the current material to its JSON representation.
  47870. * @returns The JSON representation.
  47871. */
  47872. serialize(): any;
  47873. /**
  47874. * Gets the class name of the material
  47875. * @returns "BackgroundMaterial"
  47876. */
  47877. getClassName(): string;
  47878. /**
  47879. * Parse a JSON input to create back a background material.
  47880. * @param source The JSON data to parse
  47881. * @param scene The scene to create the parsed material in
  47882. * @param rootUrl The root url of the assets the material depends upon
  47883. * @returns the instantiated BackgroundMaterial.
  47884. */
  47885. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47886. }
  47887. }
  47888. declare module BABYLON {
  47889. /**
  47890. * Represents the different options available during the creation of
  47891. * a Environment helper.
  47892. *
  47893. * This can control the default ground, skybox and image processing setup of your scene.
  47894. */
  47895. export interface IEnvironmentHelperOptions {
  47896. /**
  47897. * Specifies wether or not to create a ground.
  47898. * True by default.
  47899. */
  47900. createGround: boolean;
  47901. /**
  47902. * Specifies the ground size.
  47903. * 15 by default.
  47904. */
  47905. groundSize: number;
  47906. /**
  47907. * The texture used on the ground for the main color.
  47908. * Comes from the BabylonJS CDN by default.
  47909. *
  47910. * Remarks: Can be either a texture or a url.
  47911. */
  47912. groundTexture: string | BaseTexture;
  47913. /**
  47914. * The color mixed in the ground texture by default.
  47915. * BabylonJS clearColor by default.
  47916. */
  47917. groundColor: Color3;
  47918. /**
  47919. * Specifies the ground opacity.
  47920. * 1 by default.
  47921. */
  47922. groundOpacity: number;
  47923. /**
  47924. * Enables the ground to receive shadows.
  47925. * True by default.
  47926. */
  47927. enableGroundShadow: boolean;
  47928. /**
  47929. * Helps preventing the shadow to be fully black on the ground.
  47930. * 0.5 by default.
  47931. */
  47932. groundShadowLevel: number;
  47933. /**
  47934. * Creates a mirror texture attach to the ground.
  47935. * false by default.
  47936. */
  47937. enableGroundMirror: boolean;
  47938. /**
  47939. * Specifies the ground mirror size ratio.
  47940. * 0.3 by default as the default kernel is 64.
  47941. */
  47942. groundMirrorSizeRatio: number;
  47943. /**
  47944. * Specifies the ground mirror blur kernel size.
  47945. * 64 by default.
  47946. */
  47947. groundMirrorBlurKernel: number;
  47948. /**
  47949. * Specifies the ground mirror visibility amount.
  47950. * 1 by default
  47951. */
  47952. groundMirrorAmount: number;
  47953. /**
  47954. * Specifies the ground mirror reflectance weight.
  47955. * This uses the standard weight of the background material to setup the fresnel effect
  47956. * of the mirror.
  47957. * 1 by default.
  47958. */
  47959. groundMirrorFresnelWeight: number;
  47960. /**
  47961. * Specifies the ground mirror Falloff distance.
  47962. * This can helps reducing the size of the reflection.
  47963. * 0 by Default.
  47964. */
  47965. groundMirrorFallOffDistance: number;
  47966. /**
  47967. * Specifies the ground mirror texture type.
  47968. * Unsigned Int by Default.
  47969. */
  47970. groundMirrorTextureType: number;
  47971. /**
  47972. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47973. * the shown objects.
  47974. */
  47975. groundYBias: number;
  47976. /**
  47977. * Specifies wether or not to create a skybox.
  47978. * True by default.
  47979. */
  47980. createSkybox: boolean;
  47981. /**
  47982. * Specifies the skybox size.
  47983. * 20 by default.
  47984. */
  47985. skyboxSize: number;
  47986. /**
  47987. * The texture used on the skybox for the main color.
  47988. * Comes from the BabylonJS CDN by default.
  47989. *
  47990. * Remarks: Can be either a texture or a url.
  47991. */
  47992. skyboxTexture: string | BaseTexture;
  47993. /**
  47994. * The color mixed in the skybox texture by default.
  47995. * BabylonJS clearColor by default.
  47996. */
  47997. skyboxColor: Color3;
  47998. /**
  47999. * The background rotation around the Y axis of the scene.
  48000. * This helps aligning the key lights of your scene with the background.
  48001. * 0 by default.
  48002. */
  48003. backgroundYRotation: number;
  48004. /**
  48005. * Compute automatically the size of the elements to best fit with the scene.
  48006. */
  48007. sizeAuto: boolean;
  48008. /**
  48009. * Default position of the rootMesh if autoSize is not true.
  48010. */
  48011. rootPosition: Vector3;
  48012. /**
  48013. * Sets up the image processing in the scene.
  48014. * true by default.
  48015. */
  48016. setupImageProcessing: boolean;
  48017. /**
  48018. * The texture used as your environment texture in the scene.
  48019. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48020. *
  48021. * Remarks: Can be either a texture or a url.
  48022. */
  48023. environmentTexture: string | BaseTexture;
  48024. /**
  48025. * The value of the exposure to apply to the scene.
  48026. * 0.6 by default if setupImageProcessing is true.
  48027. */
  48028. cameraExposure: number;
  48029. /**
  48030. * The value of the contrast to apply to the scene.
  48031. * 1.6 by default if setupImageProcessing is true.
  48032. */
  48033. cameraContrast: number;
  48034. /**
  48035. * Specifies wether or not tonemapping should be enabled in the scene.
  48036. * true by default if setupImageProcessing is true.
  48037. */
  48038. toneMappingEnabled: boolean;
  48039. }
  48040. /**
  48041. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48042. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48043. * It also helps with the default setup of your imageProcessing configuration.
  48044. */
  48045. export class EnvironmentHelper {
  48046. /**
  48047. * Default ground texture URL.
  48048. */
  48049. private static _groundTextureCDNUrl;
  48050. /**
  48051. * Default skybox texture URL.
  48052. */
  48053. private static _skyboxTextureCDNUrl;
  48054. /**
  48055. * Default environment texture URL.
  48056. */
  48057. private static _environmentTextureCDNUrl;
  48058. /**
  48059. * Creates the default options for the helper.
  48060. */
  48061. private static _getDefaultOptions;
  48062. private _rootMesh;
  48063. /**
  48064. * Gets the root mesh created by the helper.
  48065. */
  48066. readonly rootMesh: Mesh;
  48067. private _skybox;
  48068. /**
  48069. * Gets the skybox created by the helper.
  48070. */
  48071. readonly skybox: Nullable<Mesh>;
  48072. private _skyboxTexture;
  48073. /**
  48074. * Gets the skybox texture created by the helper.
  48075. */
  48076. readonly skyboxTexture: Nullable<BaseTexture>;
  48077. private _skyboxMaterial;
  48078. /**
  48079. * Gets the skybox material created by the helper.
  48080. */
  48081. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48082. private _ground;
  48083. /**
  48084. * Gets the ground mesh created by the helper.
  48085. */
  48086. readonly ground: Nullable<Mesh>;
  48087. private _groundTexture;
  48088. /**
  48089. * Gets the ground texture created by the helper.
  48090. */
  48091. readonly groundTexture: Nullable<BaseTexture>;
  48092. private _groundMirror;
  48093. /**
  48094. * Gets the ground mirror created by the helper.
  48095. */
  48096. readonly groundMirror: Nullable<MirrorTexture>;
  48097. /**
  48098. * Gets the ground mirror render list to helps pushing the meshes
  48099. * you wish in the ground reflection.
  48100. */
  48101. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48102. private _groundMaterial;
  48103. /**
  48104. * Gets the ground material created by the helper.
  48105. */
  48106. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48107. /**
  48108. * Stores the creation options.
  48109. */
  48110. private readonly _scene;
  48111. private _options;
  48112. /**
  48113. * This observable will be notified with any error during the creation of the environment,
  48114. * mainly texture creation errors.
  48115. */
  48116. onErrorObservable: Observable<{
  48117. message?: string;
  48118. exception?: any;
  48119. }>;
  48120. /**
  48121. * constructor
  48122. * @param options Defines the options we want to customize the helper
  48123. * @param scene The scene to add the material to
  48124. */
  48125. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48126. /**
  48127. * Updates the background according to the new options
  48128. * @param options
  48129. */
  48130. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48131. /**
  48132. * Sets the primary color of all the available elements.
  48133. * @param color the main color to affect to the ground and the background
  48134. */
  48135. setMainColor(color: Color3): void;
  48136. /**
  48137. * Setup the image processing according to the specified options.
  48138. */
  48139. private _setupImageProcessing;
  48140. /**
  48141. * Setup the environment texture according to the specified options.
  48142. */
  48143. private _setupEnvironmentTexture;
  48144. /**
  48145. * Setup the background according to the specified options.
  48146. */
  48147. private _setupBackground;
  48148. /**
  48149. * Get the scene sizes according to the setup.
  48150. */
  48151. private _getSceneSize;
  48152. /**
  48153. * Setup the ground according to the specified options.
  48154. */
  48155. private _setupGround;
  48156. /**
  48157. * Setup the ground material according to the specified options.
  48158. */
  48159. private _setupGroundMaterial;
  48160. /**
  48161. * Setup the ground diffuse texture according to the specified options.
  48162. */
  48163. private _setupGroundDiffuseTexture;
  48164. /**
  48165. * Setup the ground mirror texture according to the specified options.
  48166. */
  48167. private _setupGroundMirrorTexture;
  48168. /**
  48169. * Setup the ground to receive the mirror texture.
  48170. */
  48171. private _setupMirrorInGroundMaterial;
  48172. /**
  48173. * Setup the skybox according to the specified options.
  48174. */
  48175. private _setupSkybox;
  48176. /**
  48177. * Setup the skybox material according to the specified options.
  48178. */
  48179. private _setupSkyboxMaterial;
  48180. /**
  48181. * Setup the skybox reflection texture according to the specified options.
  48182. */
  48183. private _setupSkyboxReflectionTexture;
  48184. private _errorHandler;
  48185. /**
  48186. * Dispose all the elements created by the Helper.
  48187. */
  48188. dispose(): void;
  48189. }
  48190. }
  48191. declare module BABYLON {
  48192. /**
  48193. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48194. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48195. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48196. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48197. */
  48198. export class PhotoDome extends TransformNode {
  48199. /**
  48200. * Define the image as a Monoscopic panoramic 360 image.
  48201. */
  48202. static readonly MODE_MONOSCOPIC: number;
  48203. /**
  48204. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48205. */
  48206. static readonly MODE_TOPBOTTOM: number;
  48207. /**
  48208. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48209. */
  48210. static readonly MODE_SIDEBYSIDE: number;
  48211. private _useDirectMapping;
  48212. /**
  48213. * The texture being displayed on the sphere
  48214. */
  48215. protected _photoTexture: Texture;
  48216. /**
  48217. * Gets or sets the texture being displayed on the sphere
  48218. */
  48219. photoTexture: Texture;
  48220. /**
  48221. * Observable raised when an error occured while loading the 360 image
  48222. */
  48223. onLoadErrorObservable: Observable<string>;
  48224. /**
  48225. * The skybox material
  48226. */
  48227. protected _material: BackgroundMaterial;
  48228. /**
  48229. * The surface used for the skybox
  48230. */
  48231. protected _mesh: Mesh;
  48232. /**
  48233. * Gets the mesh used for the skybox.
  48234. */
  48235. readonly mesh: Mesh;
  48236. /**
  48237. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48238. * Also see the options.resolution property.
  48239. */
  48240. fovMultiplier: number;
  48241. private _imageMode;
  48242. /**
  48243. * Gets or set the current video mode for the video. It can be:
  48244. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48245. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48246. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48247. */
  48248. imageMode: number;
  48249. /**
  48250. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48251. * @param name Element's name, child elements will append suffixes for their own names.
  48252. * @param urlsOfPhoto defines the url of the photo to display
  48253. * @param options defines an object containing optional or exposed sub element properties
  48254. * @param onError defines a callback called when an error occured while loading the texture
  48255. */
  48256. constructor(name: string, urlOfPhoto: string, options: {
  48257. resolution?: number;
  48258. size?: number;
  48259. useDirectMapping?: boolean;
  48260. faceForward?: boolean;
  48261. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48262. private _onBeforeCameraRenderObserver;
  48263. private _changeImageMode;
  48264. /**
  48265. * Releases resources associated with this node.
  48266. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48267. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48268. */
  48269. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48270. }
  48271. }
  48272. declare module BABYLON {
  48273. /**
  48274. * Class used to host RGBD texture specific utilities
  48275. */
  48276. export class RGBDTextureTools {
  48277. /**
  48278. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48279. * @param texture the texture to expand.
  48280. */
  48281. static ExpandRGBDTexture(texture: Texture): void;
  48282. }
  48283. }
  48284. declare module BABYLON {
  48285. /**
  48286. * Class used to host texture specific utilities
  48287. */
  48288. export class BRDFTextureTools {
  48289. /**
  48290. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48291. * @param scene defines the hosting scene
  48292. * @returns the environment BRDF texture
  48293. */
  48294. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48295. private static _environmentBRDFBase64Texture;
  48296. }
  48297. }
  48298. declare module BABYLON {
  48299. /**
  48300. * @hidden
  48301. */
  48302. export interface IMaterialClearCoatDefines {
  48303. CLEARCOAT: boolean;
  48304. CLEARCOAT_DEFAULTIOR: boolean;
  48305. CLEARCOAT_TEXTURE: boolean;
  48306. CLEARCOAT_TEXTUREDIRECTUV: number;
  48307. CLEARCOAT_BUMP: boolean;
  48308. CLEARCOAT_BUMPDIRECTUV: number;
  48309. CLEARCOAT_TINT: boolean;
  48310. CLEARCOAT_TINT_TEXTURE: boolean;
  48311. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48312. /** @hidden */
  48313. _areTexturesDirty: boolean;
  48314. }
  48315. /**
  48316. * Define the code related to the clear coat parameters of the pbr material.
  48317. */
  48318. export class PBRClearCoatConfiguration {
  48319. /**
  48320. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48321. * The default fits with a polyurethane material.
  48322. */
  48323. private static readonly _DefaultIndexOfRefraction;
  48324. private _isEnabled;
  48325. /**
  48326. * Defines if the clear coat is enabled in the material.
  48327. */
  48328. isEnabled: boolean;
  48329. /**
  48330. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48331. */
  48332. intensity: number;
  48333. /**
  48334. * Defines the clear coat layer roughness.
  48335. */
  48336. roughness: number;
  48337. private _indexOfRefraction;
  48338. /**
  48339. * Defines the index of refraction of the clear coat.
  48340. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48341. * The default fits with a polyurethane material.
  48342. * Changing the default value is more performance intensive.
  48343. */
  48344. indexOfRefraction: number;
  48345. private _texture;
  48346. /**
  48347. * Stores the clear coat values in a texture.
  48348. */
  48349. texture: Nullable<BaseTexture>;
  48350. private _bumpTexture;
  48351. /**
  48352. * Define the clear coat specific bump texture.
  48353. */
  48354. bumpTexture: Nullable<BaseTexture>;
  48355. private _isTintEnabled;
  48356. /**
  48357. * Defines if the clear coat tint is enabled in the material.
  48358. */
  48359. isTintEnabled: boolean;
  48360. /**
  48361. * Defines the clear coat tint of the material.
  48362. * This is only use if tint is enabled
  48363. */
  48364. tintColor: Color3;
  48365. /**
  48366. * Defines the distance at which the tint color should be found in the
  48367. * clear coat media.
  48368. * This is only use if tint is enabled
  48369. */
  48370. tintColorAtDistance: number;
  48371. /**
  48372. * Defines the clear coat layer thickness.
  48373. * This is only use if tint is enabled
  48374. */
  48375. tintThickness: number;
  48376. private _tintTexture;
  48377. /**
  48378. * Stores the clear tint values in a texture.
  48379. * rgb is tint
  48380. * a is a thickness factor
  48381. */
  48382. tintTexture: Nullable<BaseTexture>;
  48383. /** @hidden */
  48384. private _internalMarkAllSubMeshesAsTexturesDirty;
  48385. /** @hidden */
  48386. _markAllSubMeshesAsTexturesDirty(): void;
  48387. /**
  48388. * Instantiate a new istance of clear coat configuration.
  48389. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48390. */
  48391. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48392. /**
  48393. * Gets wehter the submesh is ready to be used or not.
  48394. * @param defines the list of "defines" to update.
  48395. * @param scene defines the scene the material belongs to.
  48396. * @param engine defines the engine the material belongs to.
  48397. * @param disableBumpMap defines wether the material disables bump or not.
  48398. * @returns - boolean indicating that the submesh is ready or not.
  48399. */
  48400. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48401. /**
  48402. * Checks to see if a texture is used in the material.
  48403. * @param defines the list of "defines" to update.
  48404. * @param scene defines the scene to the material belongs to.
  48405. */
  48406. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48407. /**
  48408. * Binds the material data.
  48409. * @param uniformBuffer defines the Uniform buffer to fill in.
  48410. * @param scene defines the scene the material belongs to.
  48411. * @param engine defines the engine the material belongs to.
  48412. * @param disableBumpMap defines wether the material disables bump or not.
  48413. * @param isFrozen defines wether the material is frozen or not.
  48414. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48415. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48416. */
  48417. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48418. /**
  48419. * Checks to see if a texture is used in the material.
  48420. * @param texture - Base texture to use.
  48421. * @returns - Boolean specifying if a texture is used in the material.
  48422. */
  48423. hasTexture(texture: BaseTexture): boolean;
  48424. /**
  48425. * Returns an array of the actively used textures.
  48426. * @param activeTextures Array of BaseTextures
  48427. */
  48428. getActiveTextures(activeTextures: BaseTexture[]): void;
  48429. /**
  48430. * Returns the animatable textures.
  48431. * @param animatables Array of animatable textures.
  48432. */
  48433. getAnimatables(animatables: IAnimatable[]): void;
  48434. /**
  48435. * Disposes the resources of the material.
  48436. * @param forceDisposeTextures - Forces the disposal of all textures.
  48437. */
  48438. dispose(forceDisposeTextures?: boolean): void;
  48439. /**
  48440. * Get the current class name of the texture useful for serialization or dynamic coding.
  48441. * @returns "PBRClearCoatConfiguration"
  48442. */
  48443. getClassName(): string;
  48444. /**
  48445. * Add fallbacks to the effect fallbacks list.
  48446. * @param defines defines the Base texture to use.
  48447. * @param fallbacks defines the current fallback list.
  48448. * @param currentRank defines the current fallback rank.
  48449. * @returns the new fallback rank.
  48450. */
  48451. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48452. /**
  48453. * Add the required uniforms to the current list.
  48454. * @param uniforms defines the current uniform list.
  48455. */
  48456. static AddUniforms(uniforms: string[]): void;
  48457. /**
  48458. * Add the required samplers to the current list.
  48459. * @param samplers defines the current sampler list.
  48460. */
  48461. static AddSamplers(samplers: string[]): void;
  48462. /**
  48463. * Add the required uniforms to the current buffer.
  48464. * @param uniformBuffer defines the current uniform buffer.
  48465. */
  48466. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48467. /**
  48468. * Makes a duplicate of the current configuration into another one.
  48469. * @param clearCoatConfiguration define the config where to copy the info
  48470. */
  48471. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48472. /**
  48473. * Serializes this clear coat configuration.
  48474. * @returns - An object with the serialized config.
  48475. */
  48476. serialize(): any;
  48477. /**
  48478. * Parses a anisotropy Configuration from a serialized object.
  48479. * @param source - Serialized object.
  48480. * @param scene Defines the scene we are parsing for
  48481. * @param rootUrl Defines the rootUrl to load from
  48482. */
  48483. parse(source: any, scene: Scene, rootUrl: string): void;
  48484. }
  48485. }
  48486. declare module BABYLON {
  48487. /**
  48488. * @hidden
  48489. */
  48490. export interface IMaterialAnisotropicDefines {
  48491. ANISOTROPIC: boolean;
  48492. ANISOTROPIC_TEXTURE: boolean;
  48493. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48494. MAINUV1: boolean;
  48495. _areTexturesDirty: boolean;
  48496. _needUVs: boolean;
  48497. }
  48498. /**
  48499. * Define the code related to the anisotropic parameters of the pbr material.
  48500. */
  48501. export class PBRAnisotropicConfiguration {
  48502. private _isEnabled;
  48503. /**
  48504. * Defines if the anisotropy is enabled in the material.
  48505. */
  48506. isEnabled: boolean;
  48507. /**
  48508. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48509. */
  48510. intensity: number;
  48511. /**
  48512. * Defines if the effect is along the tangents, bitangents or in between.
  48513. * By default, the effect is "strectching" the highlights along the tangents.
  48514. */
  48515. direction: Vector2;
  48516. private _texture;
  48517. /**
  48518. * Stores the anisotropy values in a texture.
  48519. * rg is direction (like normal from -1 to 1)
  48520. * b is a intensity
  48521. */
  48522. texture: Nullable<BaseTexture>;
  48523. /** @hidden */
  48524. private _internalMarkAllSubMeshesAsTexturesDirty;
  48525. /** @hidden */
  48526. _markAllSubMeshesAsTexturesDirty(): void;
  48527. /**
  48528. * Instantiate a new istance of anisotropy configuration.
  48529. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48530. */
  48531. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48532. /**
  48533. * Specifies that the submesh is ready to be used.
  48534. * @param defines the list of "defines" to update.
  48535. * @param scene defines the scene the material belongs to.
  48536. * @returns - boolean indicating that the submesh is ready or not.
  48537. */
  48538. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48539. /**
  48540. * Checks to see if a texture is used in the material.
  48541. * @param defines the list of "defines" to update.
  48542. * @param mesh the mesh we are preparing the defines for.
  48543. * @param scene defines the scene the material belongs to.
  48544. */
  48545. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48546. /**
  48547. * Binds the material data.
  48548. * @param uniformBuffer defines the Uniform buffer to fill in.
  48549. * @param scene defines the scene the material belongs to.
  48550. * @param isFrozen defines wether the material is frozen or not.
  48551. */
  48552. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48553. /**
  48554. * Checks to see if a texture is used in the material.
  48555. * @param texture - Base texture to use.
  48556. * @returns - Boolean specifying if a texture is used in the material.
  48557. */
  48558. hasTexture(texture: BaseTexture): boolean;
  48559. /**
  48560. * Returns an array of the actively used textures.
  48561. * @param activeTextures Array of BaseTextures
  48562. */
  48563. getActiveTextures(activeTextures: BaseTexture[]): void;
  48564. /**
  48565. * Returns the animatable textures.
  48566. * @param animatables Array of animatable textures.
  48567. */
  48568. getAnimatables(animatables: IAnimatable[]): void;
  48569. /**
  48570. * Disposes the resources of the material.
  48571. * @param forceDisposeTextures - Forces the disposal of all textures.
  48572. */
  48573. dispose(forceDisposeTextures?: boolean): void;
  48574. /**
  48575. * Get the current class name of the texture useful for serialization or dynamic coding.
  48576. * @returns "PBRAnisotropicConfiguration"
  48577. */
  48578. getClassName(): string;
  48579. /**
  48580. * Add fallbacks to the effect fallbacks list.
  48581. * @param defines defines the Base texture to use.
  48582. * @param fallbacks defines the current fallback list.
  48583. * @param currentRank defines the current fallback rank.
  48584. * @returns the new fallback rank.
  48585. */
  48586. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48587. /**
  48588. * Add the required uniforms to the current list.
  48589. * @param uniforms defines the current uniform list.
  48590. */
  48591. static AddUniforms(uniforms: string[]): void;
  48592. /**
  48593. * Add the required uniforms to the current buffer.
  48594. * @param uniformBuffer defines the current uniform buffer.
  48595. */
  48596. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48597. /**
  48598. * Add the required samplers to the current list.
  48599. * @param samplers defines the current sampler list.
  48600. */
  48601. static AddSamplers(samplers: string[]): void;
  48602. /**
  48603. * Makes a duplicate of the current configuration into another one.
  48604. * @param anisotropicConfiguration define the config where to copy the info
  48605. */
  48606. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48607. /**
  48608. * Serializes this anisotropy configuration.
  48609. * @returns - An object with the serialized config.
  48610. */
  48611. serialize(): any;
  48612. /**
  48613. * Parses a anisotropy Configuration from a serialized object.
  48614. * @param source - Serialized object.
  48615. * @param scene Defines the scene we are parsing for
  48616. * @param rootUrl Defines the rootUrl to load from
  48617. */
  48618. parse(source: any, scene: Scene, rootUrl: string): void;
  48619. }
  48620. }
  48621. declare module BABYLON {
  48622. /**
  48623. * @hidden
  48624. */
  48625. export interface IMaterialBRDFDefines {
  48626. BRDF_V_HEIGHT_CORRELATED: boolean;
  48627. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48628. SPHERICAL_HARMONICS: boolean;
  48629. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48630. /** @hidden */
  48631. _areMiscDirty: boolean;
  48632. }
  48633. /**
  48634. * Define the code related to the BRDF parameters of the pbr material.
  48635. */
  48636. export class PBRBRDFConfiguration {
  48637. /**
  48638. * Default value used for the energy conservation.
  48639. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48640. */
  48641. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48642. /**
  48643. * Default value used for the Smith Visibility Height Correlated mode.
  48644. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48645. */
  48646. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48647. /**
  48648. * Default value used for the IBL diffuse part.
  48649. * This can help switching back to the polynomials mode globally which is a tiny bit
  48650. * less GPU intensive at the drawback of a lower quality.
  48651. */
  48652. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48653. /**
  48654. * Default value used for activating energy conservation for the specular workflow.
  48655. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48656. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48657. */
  48658. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48659. private _useEnergyConservation;
  48660. /**
  48661. * Defines if the material uses energy conservation.
  48662. */
  48663. useEnergyConservation: boolean;
  48664. private _useSmithVisibilityHeightCorrelated;
  48665. /**
  48666. * LEGACY Mode set to false
  48667. * Defines if the material uses height smith correlated visibility term.
  48668. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48669. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48670. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48671. * Not relying on height correlated will also disable energy conservation.
  48672. */
  48673. useSmithVisibilityHeightCorrelated: boolean;
  48674. private _useSphericalHarmonics;
  48675. /**
  48676. * LEGACY Mode set to false
  48677. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48678. * diffuse part of the IBL.
  48679. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48680. * to the ground truth.
  48681. */
  48682. useSphericalHarmonics: boolean;
  48683. private _useSpecularGlossinessInputEnergyConservation;
  48684. /**
  48685. * Defines if the material uses energy conservation, when the specular workflow is active.
  48686. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48687. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48688. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48689. */
  48690. useSpecularGlossinessInputEnergyConservation: boolean;
  48691. /** @hidden */
  48692. private _internalMarkAllSubMeshesAsMiscDirty;
  48693. /** @hidden */
  48694. _markAllSubMeshesAsMiscDirty(): void;
  48695. /**
  48696. * Instantiate a new istance of clear coat configuration.
  48697. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48698. */
  48699. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48700. /**
  48701. * Checks to see if a texture is used in the material.
  48702. * @param defines the list of "defines" to update.
  48703. */
  48704. prepareDefines(defines: IMaterialBRDFDefines): void;
  48705. /**
  48706. * Get the current class name of the texture useful for serialization or dynamic coding.
  48707. * @returns "PBRClearCoatConfiguration"
  48708. */
  48709. getClassName(): string;
  48710. /**
  48711. * Makes a duplicate of the current configuration into another one.
  48712. * @param brdfConfiguration define the config where to copy the info
  48713. */
  48714. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48715. /**
  48716. * Serializes this BRDF configuration.
  48717. * @returns - An object with the serialized config.
  48718. */
  48719. serialize(): any;
  48720. /**
  48721. * Parses a anisotropy Configuration from a serialized object.
  48722. * @param source - Serialized object.
  48723. * @param scene Defines the scene we are parsing for
  48724. * @param rootUrl Defines the rootUrl to load from
  48725. */
  48726. parse(source: any, scene: Scene, rootUrl: string): void;
  48727. }
  48728. }
  48729. declare module BABYLON {
  48730. /**
  48731. * @hidden
  48732. */
  48733. export interface IMaterialSheenDefines {
  48734. SHEEN: boolean;
  48735. SHEEN_TEXTURE: boolean;
  48736. SHEEN_TEXTUREDIRECTUV: number;
  48737. SHEEN_LINKWITHALBEDO: boolean;
  48738. /** @hidden */
  48739. _areTexturesDirty: boolean;
  48740. }
  48741. /**
  48742. * Define the code related to the Sheen parameters of the pbr material.
  48743. */
  48744. export class PBRSheenConfiguration {
  48745. private _isEnabled;
  48746. /**
  48747. * Defines if the material uses sheen.
  48748. */
  48749. isEnabled: boolean;
  48750. private _linkSheenWithAlbedo;
  48751. /**
  48752. * Defines if the sheen is linked to the sheen color.
  48753. */
  48754. linkSheenWithAlbedo: boolean;
  48755. /**
  48756. * Defines the sheen intensity.
  48757. */
  48758. intensity: number;
  48759. /**
  48760. * Defines the sheen color.
  48761. */
  48762. color: Color3;
  48763. private _texture;
  48764. /**
  48765. * Stores the sheen tint values in a texture.
  48766. * rgb is tint
  48767. * a is a intensity
  48768. */
  48769. texture: Nullable<BaseTexture>;
  48770. /** @hidden */
  48771. private _internalMarkAllSubMeshesAsTexturesDirty;
  48772. /** @hidden */
  48773. _markAllSubMeshesAsTexturesDirty(): void;
  48774. /**
  48775. * Instantiate a new istance of clear coat configuration.
  48776. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48777. */
  48778. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48779. /**
  48780. * Specifies that the submesh is ready to be used.
  48781. * @param defines the list of "defines" to update.
  48782. * @param scene defines the scene the material belongs to.
  48783. * @returns - boolean indicating that the submesh is ready or not.
  48784. */
  48785. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48786. /**
  48787. * Checks to see if a texture is used in the material.
  48788. * @param defines the list of "defines" to update.
  48789. * @param scene defines the scene the material belongs to.
  48790. */
  48791. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48792. /**
  48793. * Binds the material data.
  48794. * @param uniformBuffer defines the Uniform buffer to fill in.
  48795. * @param scene defines the scene the material belongs to.
  48796. * @param isFrozen defines wether the material is frozen or not.
  48797. */
  48798. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48799. /**
  48800. * Checks to see if a texture is used in the material.
  48801. * @param texture - Base texture to use.
  48802. * @returns - Boolean specifying if a texture is used in the material.
  48803. */
  48804. hasTexture(texture: BaseTexture): boolean;
  48805. /**
  48806. * Returns an array of the actively used textures.
  48807. * @param activeTextures Array of BaseTextures
  48808. */
  48809. getActiveTextures(activeTextures: BaseTexture[]): void;
  48810. /**
  48811. * Returns the animatable textures.
  48812. * @param animatables Array of animatable textures.
  48813. */
  48814. getAnimatables(animatables: IAnimatable[]): void;
  48815. /**
  48816. * Disposes the resources of the material.
  48817. * @param forceDisposeTextures - Forces the disposal of all textures.
  48818. */
  48819. dispose(forceDisposeTextures?: boolean): void;
  48820. /**
  48821. * Get the current class name of the texture useful for serialization or dynamic coding.
  48822. * @returns "PBRSheenConfiguration"
  48823. */
  48824. getClassName(): string;
  48825. /**
  48826. * Add fallbacks to the effect fallbacks list.
  48827. * @param defines defines the Base texture to use.
  48828. * @param fallbacks defines the current fallback list.
  48829. * @param currentRank defines the current fallback rank.
  48830. * @returns the new fallback rank.
  48831. */
  48832. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48833. /**
  48834. * Add the required uniforms to the current list.
  48835. * @param uniforms defines the current uniform list.
  48836. */
  48837. static AddUniforms(uniforms: string[]): void;
  48838. /**
  48839. * Add the required uniforms to the current buffer.
  48840. * @param uniformBuffer defines the current uniform buffer.
  48841. */
  48842. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48843. /**
  48844. * Add the required samplers to the current list.
  48845. * @param samplers defines the current sampler list.
  48846. */
  48847. static AddSamplers(samplers: string[]): void;
  48848. /**
  48849. * Makes a duplicate of the current configuration into another one.
  48850. * @param sheenConfiguration define the config where to copy the info
  48851. */
  48852. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48853. /**
  48854. * Serializes this BRDF configuration.
  48855. * @returns - An object with the serialized config.
  48856. */
  48857. serialize(): any;
  48858. /**
  48859. * Parses a anisotropy Configuration from a serialized object.
  48860. * @param source - Serialized object.
  48861. * @param scene Defines the scene we are parsing for
  48862. * @param rootUrl Defines the rootUrl to load from
  48863. */
  48864. parse(source: any, scene: Scene, rootUrl: string): void;
  48865. }
  48866. }
  48867. declare module BABYLON {
  48868. /**
  48869. * @hidden
  48870. */
  48871. export interface IMaterialSubSurfaceDefines {
  48872. SUBSURFACE: boolean;
  48873. SS_REFRACTION: boolean;
  48874. SS_TRANSLUCENCY: boolean;
  48875. SS_SCATERRING: boolean;
  48876. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48877. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48878. SS_REFRACTIONMAP_3D: boolean;
  48879. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48880. SS_LODINREFRACTIONALPHA: boolean;
  48881. SS_GAMMAREFRACTION: boolean;
  48882. SS_RGBDREFRACTION: boolean;
  48883. SS_LINEARSPECULARREFRACTION: boolean;
  48884. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48885. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48886. /** @hidden */
  48887. _areTexturesDirty: boolean;
  48888. }
  48889. /**
  48890. * Define the code related to the sub surface parameters of the pbr material.
  48891. */
  48892. export class PBRSubSurfaceConfiguration {
  48893. private _isRefractionEnabled;
  48894. /**
  48895. * Defines if the refraction is enabled in the material.
  48896. */
  48897. isRefractionEnabled: boolean;
  48898. private _isTranslucencyEnabled;
  48899. /**
  48900. * Defines if the translucency is enabled in the material.
  48901. */
  48902. isTranslucencyEnabled: boolean;
  48903. private _isScatteringEnabled;
  48904. /**
  48905. * Defines the refraction intensity of the material.
  48906. * The refraction when enabled replaces the Diffuse part of the material.
  48907. * The intensity helps transitionning between diffuse and refraction.
  48908. */
  48909. refractionIntensity: number;
  48910. /**
  48911. * Defines the translucency intensity of the material.
  48912. * When translucency has been enabled, this defines how much of the "translucency"
  48913. * is addded to the diffuse part of the material.
  48914. */
  48915. translucencyIntensity: number;
  48916. /**
  48917. * Defines the scattering intensity of the material.
  48918. * When scattering has been enabled, this defines how much of the "scattered light"
  48919. * is addded to the diffuse part of the material.
  48920. */
  48921. scatteringIntensity: number;
  48922. private _thicknessTexture;
  48923. /**
  48924. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48925. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48926. * 0 would mean minimumThickness
  48927. * 1 would mean maximumThickness
  48928. * The other channels might be use as a mask to vary the different effects intensity.
  48929. */
  48930. thicknessTexture: Nullable<BaseTexture>;
  48931. private _refractionTexture;
  48932. /**
  48933. * Defines the texture to use for refraction.
  48934. */
  48935. refractionTexture: Nullable<BaseTexture>;
  48936. private _indexOfRefraction;
  48937. /**
  48938. * Defines the index of refraction used in the material.
  48939. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48940. */
  48941. indexOfRefraction: number;
  48942. private _invertRefractionY;
  48943. /**
  48944. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48945. */
  48946. invertRefractionY: boolean;
  48947. private _linkRefractionWithTransparency;
  48948. /**
  48949. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48950. * Materials half opaque for instance using refraction could benefit from this control.
  48951. */
  48952. linkRefractionWithTransparency: boolean;
  48953. /**
  48954. * Defines the minimum thickness stored in the thickness map.
  48955. * If no thickness map is defined, this value will be used to simulate thickness.
  48956. */
  48957. minimumThickness: number;
  48958. /**
  48959. * Defines the maximum thickness stored in the thickness map.
  48960. */
  48961. maximumThickness: number;
  48962. /**
  48963. * Defines the volume tint of the material.
  48964. * This is used for both translucency and scattering.
  48965. */
  48966. tintColor: Color3;
  48967. /**
  48968. * Defines the distance at which the tint color should be found in the media.
  48969. * This is used for refraction only.
  48970. */
  48971. tintColorAtDistance: number;
  48972. /**
  48973. * Defines how far each channel transmit through the media.
  48974. * It is defined as a color to simplify it selection.
  48975. */
  48976. diffusionDistance: Color3;
  48977. private _useMaskFromThicknessTexture;
  48978. /**
  48979. * Stores the intensity of the different subsurface effects in the thickness texture.
  48980. * * the green channel is the translucency intensity.
  48981. * * the blue channel is the scattering intensity.
  48982. * * the alpha channel is the refraction intensity.
  48983. */
  48984. useMaskFromThicknessTexture: boolean;
  48985. /** @hidden */
  48986. private _internalMarkAllSubMeshesAsTexturesDirty;
  48987. /** @hidden */
  48988. _markAllSubMeshesAsTexturesDirty(): void;
  48989. /**
  48990. * Instantiate a new istance of sub surface configuration.
  48991. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48992. */
  48993. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48994. /**
  48995. * Gets wehter the submesh is ready to be used or not.
  48996. * @param defines the list of "defines" to update.
  48997. * @param scene defines the scene the material belongs to.
  48998. * @returns - boolean indicating that the submesh is ready or not.
  48999. */
  49000. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49001. /**
  49002. * Checks to see if a texture is used in the material.
  49003. * @param defines the list of "defines" to update.
  49004. * @param scene defines the scene to the material belongs to.
  49005. */
  49006. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49007. /**
  49008. * Binds the material data.
  49009. * @param uniformBuffer defines the Uniform buffer to fill in.
  49010. * @param scene defines the scene the material belongs to.
  49011. * @param engine defines the engine the material belongs to.
  49012. * @param isFrozen defines wether the material is frozen or not.
  49013. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49014. */
  49015. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49016. /**
  49017. * Unbinds the material from the mesh.
  49018. * @param activeEffect defines the effect that should be unbound from.
  49019. * @returns true if unbound, otherwise false
  49020. */
  49021. unbind(activeEffect: Effect): boolean;
  49022. /**
  49023. * Returns the texture used for refraction or null if none is used.
  49024. * @param scene defines the scene the material belongs to.
  49025. * @returns - Refraction texture if present. If no refraction texture and refraction
  49026. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49027. */
  49028. private _getRefractionTexture;
  49029. /**
  49030. * Returns true if alpha blending should be disabled.
  49031. */
  49032. readonly disableAlphaBlending: boolean;
  49033. /**
  49034. * Fills the list of render target textures.
  49035. * @param renderTargets the list of render targets to update
  49036. */
  49037. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49038. /**
  49039. * Checks to see if a texture is used in the material.
  49040. * @param texture - Base texture to use.
  49041. * @returns - Boolean specifying if a texture is used in the material.
  49042. */
  49043. hasTexture(texture: BaseTexture): boolean;
  49044. /**
  49045. * Gets a boolean indicating that current material needs to register RTT
  49046. * @returns true if this uses a render target otherwise false.
  49047. */
  49048. hasRenderTargetTextures(): boolean;
  49049. /**
  49050. * Returns an array of the actively used textures.
  49051. * @param activeTextures Array of BaseTextures
  49052. */
  49053. getActiveTextures(activeTextures: BaseTexture[]): void;
  49054. /**
  49055. * Returns the animatable textures.
  49056. * @param animatables Array of animatable textures.
  49057. */
  49058. getAnimatables(animatables: IAnimatable[]): void;
  49059. /**
  49060. * Disposes the resources of the material.
  49061. * @param forceDisposeTextures - Forces the disposal of all textures.
  49062. */
  49063. dispose(forceDisposeTextures?: boolean): void;
  49064. /**
  49065. * Get the current class name of the texture useful for serialization or dynamic coding.
  49066. * @returns "PBRSubSurfaceConfiguration"
  49067. */
  49068. getClassName(): string;
  49069. /**
  49070. * Add fallbacks to the effect fallbacks list.
  49071. * @param defines defines the Base texture to use.
  49072. * @param fallbacks defines the current fallback list.
  49073. * @param currentRank defines the current fallback rank.
  49074. * @returns the new fallback rank.
  49075. */
  49076. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49077. /**
  49078. * Add the required uniforms to the current list.
  49079. * @param uniforms defines the current uniform list.
  49080. */
  49081. static AddUniforms(uniforms: string[]): void;
  49082. /**
  49083. * Add the required samplers to the current list.
  49084. * @param samplers defines the current sampler list.
  49085. */
  49086. static AddSamplers(samplers: string[]): void;
  49087. /**
  49088. * Add the required uniforms to the current buffer.
  49089. * @param uniformBuffer defines the current uniform buffer.
  49090. */
  49091. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49092. /**
  49093. * Makes a duplicate of the current configuration into another one.
  49094. * @param configuration define the config where to copy the info
  49095. */
  49096. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49097. /**
  49098. * Serializes this Sub Surface configuration.
  49099. * @returns - An object with the serialized config.
  49100. */
  49101. serialize(): any;
  49102. /**
  49103. * Parses a anisotropy Configuration from a serialized object.
  49104. * @param source - Serialized object.
  49105. * @param scene Defines the scene we are parsing for
  49106. * @param rootUrl Defines the rootUrl to load from
  49107. */
  49108. parse(source: any, scene: Scene, rootUrl: string): void;
  49109. }
  49110. }
  49111. declare module BABYLON {
  49112. /** @hidden */
  49113. export var pbrFragmentDeclaration: {
  49114. name: string;
  49115. shader: string;
  49116. };
  49117. }
  49118. declare module BABYLON {
  49119. /** @hidden */
  49120. export var pbrUboDeclaration: {
  49121. name: string;
  49122. shader: string;
  49123. };
  49124. }
  49125. declare module BABYLON {
  49126. /** @hidden */
  49127. export var pbrFragmentExtraDeclaration: {
  49128. name: string;
  49129. shader: string;
  49130. };
  49131. }
  49132. declare module BABYLON {
  49133. /** @hidden */
  49134. export var pbrFragmentSamplersDeclaration: {
  49135. name: string;
  49136. shader: string;
  49137. };
  49138. }
  49139. declare module BABYLON {
  49140. /** @hidden */
  49141. export var pbrHelperFunctions: {
  49142. name: string;
  49143. shader: string;
  49144. };
  49145. }
  49146. declare module BABYLON {
  49147. /** @hidden */
  49148. export var harmonicsFunctions: {
  49149. name: string;
  49150. shader: string;
  49151. };
  49152. }
  49153. declare module BABYLON {
  49154. /** @hidden */
  49155. export var pbrDirectLightingSetupFunctions: {
  49156. name: string;
  49157. shader: string;
  49158. };
  49159. }
  49160. declare module BABYLON {
  49161. /** @hidden */
  49162. export var pbrDirectLightingFalloffFunctions: {
  49163. name: string;
  49164. shader: string;
  49165. };
  49166. }
  49167. declare module BABYLON {
  49168. /** @hidden */
  49169. export var pbrBRDFFunctions: {
  49170. name: string;
  49171. shader: string;
  49172. };
  49173. }
  49174. declare module BABYLON {
  49175. /** @hidden */
  49176. export var pbrDirectLightingFunctions: {
  49177. name: string;
  49178. shader: string;
  49179. };
  49180. }
  49181. declare module BABYLON {
  49182. /** @hidden */
  49183. export var pbrIBLFunctions: {
  49184. name: string;
  49185. shader: string;
  49186. };
  49187. }
  49188. declare module BABYLON {
  49189. /** @hidden */
  49190. export var pbrDebug: {
  49191. name: string;
  49192. shader: string;
  49193. };
  49194. }
  49195. declare module BABYLON {
  49196. /** @hidden */
  49197. export var pbrPixelShader: {
  49198. name: string;
  49199. shader: string;
  49200. };
  49201. }
  49202. declare module BABYLON {
  49203. /** @hidden */
  49204. export var pbrVertexDeclaration: {
  49205. name: string;
  49206. shader: string;
  49207. };
  49208. }
  49209. declare module BABYLON {
  49210. /** @hidden */
  49211. export var pbrVertexShader: {
  49212. name: string;
  49213. shader: string;
  49214. };
  49215. }
  49216. declare module BABYLON {
  49217. /**
  49218. * Manages the defines for the PBR Material.
  49219. * @hidden
  49220. */
  49221. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49222. PBR: boolean;
  49223. MAINUV1: boolean;
  49224. MAINUV2: boolean;
  49225. UV1: boolean;
  49226. UV2: boolean;
  49227. ALBEDO: boolean;
  49228. ALBEDODIRECTUV: number;
  49229. VERTEXCOLOR: boolean;
  49230. AMBIENT: boolean;
  49231. AMBIENTDIRECTUV: number;
  49232. AMBIENTINGRAYSCALE: boolean;
  49233. OPACITY: boolean;
  49234. VERTEXALPHA: boolean;
  49235. OPACITYDIRECTUV: number;
  49236. OPACITYRGB: boolean;
  49237. ALPHATEST: boolean;
  49238. DEPTHPREPASS: boolean;
  49239. ALPHABLEND: boolean;
  49240. ALPHAFROMALBEDO: boolean;
  49241. ALPHATESTVALUE: string;
  49242. SPECULAROVERALPHA: boolean;
  49243. RADIANCEOVERALPHA: boolean;
  49244. ALPHAFRESNEL: boolean;
  49245. LINEARALPHAFRESNEL: boolean;
  49246. PREMULTIPLYALPHA: boolean;
  49247. EMISSIVE: boolean;
  49248. EMISSIVEDIRECTUV: number;
  49249. REFLECTIVITY: boolean;
  49250. REFLECTIVITYDIRECTUV: number;
  49251. SPECULARTERM: boolean;
  49252. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49253. MICROSURFACEAUTOMATIC: boolean;
  49254. LODBASEDMICROSFURACE: boolean;
  49255. MICROSURFACEMAP: boolean;
  49256. MICROSURFACEMAPDIRECTUV: number;
  49257. METALLICWORKFLOW: boolean;
  49258. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49259. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49260. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49261. AOSTOREINMETALMAPRED: boolean;
  49262. METALLICF0FACTORFROMMETALLICMAP: boolean;
  49263. ENVIRONMENTBRDF: boolean;
  49264. ENVIRONMENTBRDF_RGBD: boolean;
  49265. NORMAL: boolean;
  49266. TANGENT: boolean;
  49267. BUMP: boolean;
  49268. BUMPDIRECTUV: number;
  49269. OBJECTSPACE_NORMALMAP: boolean;
  49270. PARALLAX: boolean;
  49271. PARALLAXOCCLUSION: boolean;
  49272. NORMALXYSCALE: boolean;
  49273. LIGHTMAP: boolean;
  49274. LIGHTMAPDIRECTUV: number;
  49275. USELIGHTMAPASSHADOWMAP: boolean;
  49276. GAMMALIGHTMAP: boolean;
  49277. RGBDLIGHTMAP: boolean;
  49278. REFLECTION: boolean;
  49279. REFLECTIONMAP_3D: boolean;
  49280. REFLECTIONMAP_SPHERICAL: boolean;
  49281. REFLECTIONMAP_PLANAR: boolean;
  49282. REFLECTIONMAP_CUBIC: boolean;
  49283. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49284. REFLECTIONMAP_PROJECTION: boolean;
  49285. REFLECTIONMAP_SKYBOX: boolean;
  49286. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49287. REFLECTIONMAP_EXPLICIT: boolean;
  49288. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49289. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49290. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49291. INVERTCUBICMAP: boolean;
  49292. USESPHERICALFROMREFLECTIONMAP: boolean;
  49293. USEIRRADIANCEMAP: boolean;
  49294. SPHERICAL_HARMONICS: boolean;
  49295. USESPHERICALINVERTEX: boolean;
  49296. REFLECTIONMAP_OPPOSITEZ: boolean;
  49297. LODINREFLECTIONALPHA: boolean;
  49298. GAMMAREFLECTION: boolean;
  49299. RGBDREFLECTION: boolean;
  49300. LINEARSPECULARREFLECTION: boolean;
  49301. RADIANCEOCCLUSION: boolean;
  49302. HORIZONOCCLUSION: boolean;
  49303. INSTANCES: boolean;
  49304. NUM_BONE_INFLUENCERS: number;
  49305. BonesPerMesh: number;
  49306. BONETEXTURE: boolean;
  49307. NONUNIFORMSCALING: boolean;
  49308. MORPHTARGETS: boolean;
  49309. MORPHTARGETS_NORMAL: boolean;
  49310. MORPHTARGETS_TANGENT: boolean;
  49311. MORPHTARGETS_UV: boolean;
  49312. NUM_MORPH_INFLUENCERS: number;
  49313. IMAGEPROCESSING: boolean;
  49314. VIGNETTE: boolean;
  49315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49316. VIGNETTEBLENDMODEOPAQUE: boolean;
  49317. TONEMAPPING: boolean;
  49318. TONEMAPPING_ACES: boolean;
  49319. CONTRAST: boolean;
  49320. COLORCURVES: boolean;
  49321. COLORGRADING: boolean;
  49322. COLORGRADING3D: boolean;
  49323. SAMPLER3DGREENDEPTH: boolean;
  49324. SAMPLER3DBGRMAP: boolean;
  49325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49326. EXPOSURE: boolean;
  49327. MULTIVIEW: boolean;
  49328. USEPHYSICALLIGHTFALLOFF: boolean;
  49329. USEGLTFLIGHTFALLOFF: boolean;
  49330. TWOSIDEDLIGHTING: boolean;
  49331. SHADOWFLOAT: boolean;
  49332. CLIPPLANE: boolean;
  49333. CLIPPLANE2: boolean;
  49334. CLIPPLANE3: boolean;
  49335. CLIPPLANE4: boolean;
  49336. POINTSIZE: boolean;
  49337. FOG: boolean;
  49338. LOGARITHMICDEPTH: boolean;
  49339. FORCENORMALFORWARD: boolean;
  49340. SPECULARAA: boolean;
  49341. CLEARCOAT: boolean;
  49342. CLEARCOAT_DEFAULTIOR: boolean;
  49343. CLEARCOAT_TEXTURE: boolean;
  49344. CLEARCOAT_TEXTUREDIRECTUV: number;
  49345. CLEARCOAT_BUMP: boolean;
  49346. CLEARCOAT_BUMPDIRECTUV: number;
  49347. CLEARCOAT_TINT: boolean;
  49348. CLEARCOAT_TINT_TEXTURE: boolean;
  49349. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49350. ANISOTROPIC: boolean;
  49351. ANISOTROPIC_TEXTURE: boolean;
  49352. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49353. BRDF_V_HEIGHT_CORRELATED: boolean;
  49354. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49355. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49356. SHEEN: boolean;
  49357. SHEEN_TEXTURE: boolean;
  49358. SHEEN_TEXTUREDIRECTUV: number;
  49359. SHEEN_LINKWITHALBEDO: boolean;
  49360. SUBSURFACE: boolean;
  49361. SS_REFRACTION: boolean;
  49362. SS_TRANSLUCENCY: boolean;
  49363. SS_SCATERRING: boolean;
  49364. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49365. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49366. SS_REFRACTIONMAP_3D: boolean;
  49367. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49368. SS_LODINREFRACTIONALPHA: boolean;
  49369. SS_GAMMAREFRACTION: boolean;
  49370. SS_RGBDREFRACTION: boolean;
  49371. SS_LINEARSPECULARREFRACTION: boolean;
  49372. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49373. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49374. UNLIT: boolean;
  49375. DEBUGMODE: number;
  49376. /**
  49377. * Initializes the PBR Material defines.
  49378. */
  49379. constructor();
  49380. /**
  49381. * Resets the PBR Material defines.
  49382. */
  49383. reset(): void;
  49384. }
  49385. /**
  49386. * The Physically based material base class of BJS.
  49387. *
  49388. * This offers the main features of a standard PBR material.
  49389. * For more information, please refer to the documentation :
  49390. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49391. */
  49392. export abstract class PBRBaseMaterial extends PushMaterial {
  49393. /**
  49394. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49395. */
  49396. static readonly PBRMATERIAL_OPAQUE: number;
  49397. /**
  49398. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49399. */
  49400. static readonly PBRMATERIAL_ALPHATEST: number;
  49401. /**
  49402. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49403. */
  49404. static readonly PBRMATERIAL_ALPHABLEND: number;
  49405. /**
  49406. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49407. * They are also discarded below the alpha cutoff threshold to improve performances.
  49408. */
  49409. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49410. /**
  49411. * Defines the default value of how much AO map is occluding the analytical lights
  49412. * (point spot...).
  49413. */
  49414. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49415. /**
  49416. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49417. */
  49418. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49419. /**
  49420. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49421. * to enhance interoperability with other engines.
  49422. */
  49423. static readonly LIGHTFALLOFF_GLTF: number;
  49424. /**
  49425. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49426. * to enhance interoperability with other materials.
  49427. */
  49428. static readonly LIGHTFALLOFF_STANDARD: number;
  49429. /**
  49430. * Intensity of the direct lights e.g. the four lights available in your scene.
  49431. * This impacts both the direct diffuse and specular highlights.
  49432. */
  49433. protected _directIntensity: number;
  49434. /**
  49435. * Intensity of the emissive part of the material.
  49436. * This helps controlling the emissive effect without modifying the emissive color.
  49437. */
  49438. protected _emissiveIntensity: number;
  49439. /**
  49440. * Intensity of the environment e.g. how much the environment will light the object
  49441. * either through harmonics for rough material or through the refelction for shiny ones.
  49442. */
  49443. protected _environmentIntensity: number;
  49444. /**
  49445. * This is a special control allowing the reduction of the specular highlights coming from the
  49446. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49447. */
  49448. protected _specularIntensity: number;
  49449. /**
  49450. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49451. */
  49452. private _lightingInfos;
  49453. /**
  49454. * Debug Control allowing disabling the bump map on this material.
  49455. */
  49456. protected _disableBumpMap: boolean;
  49457. /**
  49458. * AKA Diffuse Texture in standard nomenclature.
  49459. */
  49460. protected _albedoTexture: Nullable<BaseTexture>;
  49461. /**
  49462. * AKA Occlusion Texture in other nomenclature.
  49463. */
  49464. protected _ambientTexture: Nullable<BaseTexture>;
  49465. /**
  49466. * AKA Occlusion Texture Intensity in other nomenclature.
  49467. */
  49468. protected _ambientTextureStrength: number;
  49469. /**
  49470. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49471. * 1 means it completely occludes it
  49472. * 0 mean it has no impact
  49473. */
  49474. protected _ambientTextureImpactOnAnalyticalLights: number;
  49475. /**
  49476. * Stores the alpha values in a texture.
  49477. */
  49478. protected _opacityTexture: Nullable<BaseTexture>;
  49479. /**
  49480. * Stores the reflection values in a texture.
  49481. */
  49482. protected _reflectionTexture: Nullable<BaseTexture>;
  49483. /**
  49484. * Stores the emissive values in a texture.
  49485. */
  49486. protected _emissiveTexture: Nullable<BaseTexture>;
  49487. /**
  49488. * AKA Specular texture in other nomenclature.
  49489. */
  49490. protected _reflectivityTexture: Nullable<BaseTexture>;
  49491. /**
  49492. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49493. */
  49494. protected _metallicTexture: Nullable<BaseTexture>;
  49495. /**
  49496. * Specifies the metallic scalar of the metallic/roughness workflow.
  49497. * Can also be used to scale the metalness values of the metallic texture.
  49498. */
  49499. protected _metallic: Nullable<number>;
  49500. /**
  49501. * Specifies the roughness scalar of the metallic/roughness workflow.
  49502. * Can also be used to scale the roughness values of the metallic texture.
  49503. */
  49504. protected _roughness: Nullable<number>;
  49505. /**
  49506. * Specifies the an F0 factor to help configuring the material F0.
  49507. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  49508. * to 0.5 the previously hard coded value stays the same.
  49509. * Can also be used to scale the F0 values of the metallic texture.
  49510. */
  49511. protected _metallicF0Factor: number;
  49512. /**
  49513. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  49514. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  49515. * your expectation as it multiplies with the texture data.
  49516. */
  49517. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  49518. /**
  49519. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49520. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49521. */
  49522. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49523. /**
  49524. * Stores surface normal data used to displace a mesh in a texture.
  49525. */
  49526. protected _bumpTexture: Nullable<BaseTexture>;
  49527. /**
  49528. * Stores the pre-calculated light information of a mesh in a texture.
  49529. */
  49530. protected _lightmapTexture: Nullable<BaseTexture>;
  49531. /**
  49532. * The color of a material in ambient lighting.
  49533. */
  49534. protected _ambientColor: Color3;
  49535. /**
  49536. * AKA Diffuse Color in other nomenclature.
  49537. */
  49538. protected _albedoColor: Color3;
  49539. /**
  49540. * AKA Specular Color in other nomenclature.
  49541. */
  49542. protected _reflectivityColor: Color3;
  49543. /**
  49544. * The color applied when light is reflected from a material.
  49545. */
  49546. protected _reflectionColor: Color3;
  49547. /**
  49548. * The color applied when light is emitted from a material.
  49549. */
  49550. protected _emissiveColor: Color3;
  49551. /**
  49552. * AKA Glossiness in other nomenclature.
  49553. */
  49554. protected _microSurface: number;
  49555. /**
  49556. * Specifies that the material will use the light map as a show map.
  49557. */
  49558. protected _useLightmapAsShadowmap: boolean;
  49559. /**
  49560. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49561. * makes the reflect vector face the model (under horizon).
  49562. */
  49563. protected _useHorizonOcclusion: boolean;
  49564. /**
  49565. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49566. * too much the area relying on ambient texture to define their ambient occlusion.
  49567. */
  49568. protected _useRadianceOcclusion: boolean;
  49569. /**
  49570. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49571. */
  49572. protected _useAlphaFromAlbedoTexture: boolean;
  49573. /**
  49574. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49575. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49576. */
  49577. protected _useSpecularOverAlpha: boolean;
  49578. /**
  49579. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49580. */
  49581. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49582. /**
  49583. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49584. */
  49585. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49586. /**
  49587. * Specifies if the metallic texture contains the roughness information in its green channel.
  49588. */
  49589. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49590. /**
  49591. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49592. */
  49593. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49594. /**
  49595. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49596. */
  49597. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49598. /**
  49599. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49600. */
  49601. protected _useAmbientInGrayScale: boolean;
  49602. /**
  49603. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49604. * The material will try to infer what glossiness each pixel should be.
  49605. */
  49606. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49607. /**
  49608. * Defines the falloff type used in this material.
  49609. * It by default is Physical.
  49610. */
  49611. protected _lightFalloff: number;
  49612. /**
  49613. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49614. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49615. */
  49616. protected _useRadianceOverAlpha: boolean;
  49617. /**
  49618. * Allows using an object space normal map (instead of tangent space).
  49619. */
  49620. protected _useObjectSpaceNormalMap: boolean;
  49621. /**
  49622. * Allows using the bump map in parallax mode.
  49623. */
  49624. protected _useParallax: boolean;
  49625. /**
  49626. * Allows using the bump map in parallax occlusion mode.
  49627. */
  49628. protected _useParallaxOcclusion: boolean;
  49629. /**
  49630. * Controls the scale bias of the parallax mode.
  49631. */
  49632. protected _parallaxScaleBias: number;
  49633. /**
  49634. * If sets to true, disables all the lights affecting the material.
  49635. */
  49636. protected _disableLighting: boolean;
  49637. /**
  49638. * Number of Simultaneous lights allowed on the material.
  49639. */
  49640. protected _maxSimultaneousLights: number;
  49641. /**
  49642. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49643. */
  49644. protected _invertNormalMapX: boolean;
  49645. /**
  49646. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49647. */
  49648. protected _invertNormalMapY: boolean;
  49649. /**
  49650. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49651. */
  49652. protected _twoSidedLighting: boolean;
  49653. /**
  49654. * Defines the alpha limits in alpha test mode.
  49655. */
  49656. protected _alphaCutOff: number;
  49657. /**
  49658. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49659. */
  49660. protected _forceAlphaTest: boolean;
  49661. /**
  49662. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49663. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49664. */
  49665. protected _useAlphaFresnel: boolean;
  49666. /**
  49667. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49668. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49669. */
  49670. protected _useLinearAlphaFresnel: boolean;
  49671. /**
  49672. * The transparency mode of the material.
  49673. */
  49674. protected _transparencyMode: Nullable<number>;
  49675. /**
  49676. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49677. * from cos thetav and roughness:
  49678. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49679. */
  49680. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49681. /**
  49682. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49683. */
  49684. protected _forceIrradianceInFragment: boolean;
  49685. /**
  49686. * Force normal to face away from face.
  49687. */
  49688. protected _forceNormalForward: boolean;
  49689. /**
  49690. * Enables specular anti aliasing in the PBR shader.
  49691. * It will both interacts on the Geometry for analytical and IBL lighting.
  49692. * It also prefilter the roughness map based on the bump values.
  49693. */
  49694. protected _enableSpecularAntiAliasing: boolean;
  49695. /**
  49696. * Default configuration related to image processing available in the PBR Material.
  49697. */
  49698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49699. /**
  49700. * Keep track of the image processing observer to allow dispose and replace.
  49701. */
  49702. private _imageProcessingObserver;
  49703. /**
  49704. * Attaches a new image processing configuration to the PBR Material.
  49705. * @param configuration
  49706. */
  49707. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49708. /**
  49709. * Stores the available render targets.
  49710. */
  49711. private _renderTargets;
  49712. /**
  49713. * Sets the global ambient color for the material used in lighting calculations.
  49714. */
  49715. private _globalAmbientColor;
  49716. /**
  49717. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49718. */
  49719. private _useLogarithmicDepth;
  49720. /**
  49721. * If set to true, no lighting calculations will be applied.
  49722. */
  49723. private _unlit;
  49724. private _debugMode;
  49725. /**
  49726. * @hidden
  49727. * This is reserved for the inspector.
  49728. * Defines the material debug mode.
  49729. * It helps seeing only some components of the material while troubleshooting.
  49730. */
  49731. debugMode: number;
  49732. /**
  49733. * @hidden
  49734. * This is reserved for the inspector.
  49735. * Specify from where on screen the debug mode should start.
  49736. * The value goes from -1 (full screen) to 1 (not visible)
  49737. * It helps with side by side comparison against the final render
  49738. * This defaults to -1
  49739. */
  49740. private debugLimit;
  49741. /**
  49742. * @hidden
  49743. * This is reserved for the inspector.
  49744. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49745. * You can use the factor to better multiply the final value.
  49746. */
  49747. private debugFactor;
  49748. /**
  49749. * Defines the clear coat layer parameters for the material.
  49750. */
  49751. readonly clearCoat: PBRClearCoatConfiguration;
  49752. /**
  49753. * Defines the anisotropic parameters for the material.
  49754. */
  49755. readonly anisotropy: PBRAnisotropicConfiguration;
  49756. /**
  49757. * Defines the BRDF parameters for the material.
  49758. */
  49759. readonly brdf: PBRBRDFConfiguration;
  49760. /**
  49761. * Defines the Sheen parameters for the material.
  49762. */
  49763. readonly sheen: PBRSheenConfiguration;
  49764. /**
  49765. * Defines the SubSurface parameters for the material.
  49766. */
  49767. readonly subSurface: PBRSubSurfaceConfiguration;
  49768. /**
  49769. * Custom callback helping to override the default shader used in the material.
  49770. */
  49771. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49772. protected _rebuildInParallel: boolean;
  49773. /**
  49774. * Instantiates a new PBRMaterial instance.
  49775. *
  49776. * @param name The material name
  49777. * @param scene The scene the material will be use in.
  49778. */
  49779. constructor(name: string, scene: Scene);
  49780. /**
  49781. * Gets a boolean indicating that current material needs to register RTT
  49782. */
  49783. readonly hasRenderTargetTextures: boolean;
  49784. /**
  49785. * Gets the name of the material class.
  49786. */
  49787. getClassName(): string;
  49788. /**
  49789. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49790. */
  49791. /**
  49792. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49793. */
  49794. useLogarithmicDepth: boolean;
  49795. /**
  49796. * Gets the current transparency mode.
  49797. */
  49798. /**
  49799. * Sets the transparency mode of the material.
  49800. *
  49801. * | Value | Type | Description |
  49802. * | ----- | ----------------------------------- | ----------- |
  49803. * | 0 | OPAQUE | |
  49804. * | 1 | ALPHATEST | |
  49805. * | 2 | ALPHABLEND | |
  49806. * | 3 | ALPHATESTANDBLEND | |
  49807. *
  49808. */
  49809. transparencyMode: Nullable<number>;
  49810. /**
  49811. * Returns true if alpha blending should be disabled.
  49812. */
  49813. private readonly _disableAlphaBlending;
  49814. /**
  49815. * Specifies whether or not this material should be rendered in alpha blend mode.
  49816. */
  49817. needAlphaBlending(): boolean;
  49818. /**
  49819. * Specifies if the mesh will require alpha blending.
  49820. * @param mesh - BJS mesh.
  49821. */
  49822. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49823. /**
  49824. * Specifies whether or not this material should be rendered in alpha test mode.
  49825. */
  49826. needAlphaTesting(): boolean;
  49827. /**
  49828. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49829. */
  49830. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49831. /**
  49832. * Gets the texture used for the alpha test.
  49833. */
  49834. getAlphaTestTexture(): Nullable<BaseTexture>;
  49835. /**
  49836. * Specifies that the submesh is ready to be used.
  49837. * @param mesh - BJS mesh.
  49838. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49839. * @param useInstances - Specifies that instances should be used.
  49840. * @returns - boolean indicating that the submesh is ready or not.
  49841. */
  49842. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49843. /**
  49844. * Specifies if the material uses metallic roughness workflow.
  49845. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49846. */
  49847. isMetallicWorkflow(): boolean;
  49848. private _prepareEffect;
  49849. private _prepareDefines;
  49850. /**
  49851. * Force shader compilation
  49852. */
  49853. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  49854. /**
  49855. * Initializes the uniform buffer layout for the shader.
  49856. */
  49857. buildUniformLayout(): void;
  49858. /**
  49859. * Unbinds the material from the mesh
  49860. */
  49861. unbind(): void;
  49862. /**
  49863. * Binds the submesh data.
  49864. * @param world - The world matrix.
  49865. * @param mesh - The BJS mesh.
  49866. * @param subMesh - A submesh of the BJS mesh.
  49867. */
  49868. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49869. /**
  49870. * Returns the animatable textures.
  49871. * @returns - Array of animatable textures.
  49872. */
  49873. getAnimatables(): IAnimatable[];
  49874. /**
  49875. * Returns the texture used for reflections.
  49876. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49877. */
  49878. private _getReflectionTexture;
  49879. /**
  49880. * Returns an array of the actively used textures.
  49881. * @returns - Array of BaseTextures
  49882. */
  49883. getActiveTextures(): BaseTexture[];
  49884. /**
  49885. * Checks to see if a texture is used in the material.
  49886. * @param texture - Base texture to use.
  49887. * @returns - Boolean specifying if a texture is used in the material.
  49888. */
  49889. hasTexture(texture: BaseTexture): boolean;
  49890. /**
  49891. * Disposes the resources of the material.
  49892. * @param forceDisposeEffect - Forces the disposal of effects.
  49893. * @param forceDisposeTextures - Forces the disposal of all textures.
  49894. */
  49895. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49896. }
  49897. }
  49898. declare module BABYLON {
  49899. /**
  49900. * The Physically based material of BJS.
  49901. *
  49902. * This offers the main features of a standard PBR material.
  49903. * For more information, please refer to the documentation :
  49904. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49905. */
  49906. export class PBRMaterial extends PBRBaseMaterial {
  49907. /**
  49908. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49909. */
  49910. static readonly PBRMATERIAL_OPAQUE: number;
  49911. /**
  49912. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49913. */
  49914. static readonly PBRMATERIAL_ALPHATEST: number;
  49915. /**
  49916. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49917. */
  49918. static readonly PBRMATERIAL_ALPHABLEND: number;
  49919. /**
  49920. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49921. * They are also discarded below the alpha cutoff threshold to improve performances.
  49922. */
  49923. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49924. /**
  49925. * Defines the default value of how much AO map is occluding the analytical lights
  49926. * (point spot...).
  49927. */
  49928. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49929. /**
  49930. * Intensity of the direct lights e.g. the four lights available in your scene.
  49931. * This impacts both the direct diffuse and specular highlights.
  49932. */
  49933. directIntensity: number;
  49934. /**
  49935. * Intensity of the emissive part of the material.
  49936. * This helps controlling the emissive effect without modifying the emissive color.
  49937. */
  49938. emissiveIntensity: number;
  49939. /**
  49940. * Intensity of the environment e.g. how much the environment will light the object
  49941. * either through harmonics for rough material or through the refelction for shiny ones.
  49942. */
  49943. environmentIntensity: number;
  49944. /**
  49945. * This is a special control allowing the reduction of the specular highlights coming from the
  49946. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49947. */
  49948. specularIntensity: number;
  49949. /**
  49950. * Debug Control allowing disabling the bump map on this material.
  49951. */
  49952. disableBumpMap: boolean;
  49953. /**
  49954. * AKA Diffuse Texture in standard nomenclature.
  49955. */
  49956. albedoTexture: BaseTexture;
  49957. /**
  49958. * AKA Occlusion Texture in other nomenclature.
  49959. */
  49960. ambientTexture: BaseTexture;
  49961. /**
  49962. * AKA Occlusion Texture Intensity in other nomenclature.
  49963. */
  49964. ambientTextureStrength: number;
  49965. /**
  49966. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49967. * 1 means it completely occludes it
  49968. * 0 mean it has no impact
  49969. */
  49970. ambientTextureImpactOnAnalyticalLights: number;
  49971. /**
  49972. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  49973. */
  49974. opacityTexture: BaseTexture;
  49975. /**
  49976. * Stores the reflection values in a texture.
  49977. */
  49978. reflectionTexture: Nullable<BaseTexture>;
  49979. /**
  49980. * Stores the emissive values in a texture.
  49981. */
  49982. emissiveTexture: BaseTexture;
  49983. /**
  49984. * AKA Specular texture in other nomenclature.
  49985. */
  49986. reflectivityTexture: BaseTexture;
  49987. /**
  49988. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49989. */
  49990. metallicTexture: BaseTexture;
  49991. /**
  49992. * Specifies the metallic scalar of the metallic/roughness workflow.
  49993. * Can also be used to scale the metalness values of the metallic texture.
  49994. */
  49995. metallic: Nullable<number>;
  49996. /**
  49997. * Specifies the roughness scalar of the metallic/roughness workflow.
  49998. * Can also be used to scale the roughness values of the metallic texture.
  49999. */
  50000. roughness: Nullable<number>;
  50001. /**
  50002. * Specifies the an F0 factor to help configuring the material F0.
  50003. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50004. * to 0.5 the previously hard coded value stays the same.
  50005. * Can also be used to scale the F0 values of the metallic texture.
  50006. */
  50007. metallicF0Factor: number;
  50008. /**
  50009. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50010. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50011. * your expectation as it multiplies with the texture data.
  50012. */
  50013. useMetallicF0FactorFromMetallicTexture: boolean;
  50014. /**
  50015. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50016. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50017. */
  50018. microSurfaceTexture: BaseTexture;
  50019. /**
  50020. * Stores surface normal data used to displace a mesh in a texture.
  50021. */
  50022. bumpTexture: BaseTexture;
  50023. /**
  50024. * Stores the pre-calculated light information of a mesh in a texture.
  50025. */
  50026. lightmapTexture: BaseTexture;
  50027. /**
  50028. * Stores the refracted light information in a texture.
  50029. */
  50030. refractionTexture: Nullable<BaseTexture>;
  50031. /**
  50032. * The color of a material in ambient lighting.
  50033. */
  50034. ambientColor: Color3;
  50035. /**
  50036. * AKA Diffuse Color in other nomenclature.
  50037. */
  50038. albedoColor: Color3;
  50039. /**
  50040. * AKA Specular Color in other nomenclature.
  50041. */
  50042. reflectivityColor: Color3;
  50043. /**
  50044. * The color reflected from the material.
  50045. */
  50046. reflectionColor: Color3;
  50047. /**
  50048. * The color emitted from the material.
  50049. */
  50050. emissiveColor: Color3;
  50051. /**
  50052. * AKA Glossiness in other nomenclature.
  50053. */
  50054. microSurface: number;
  50055. /**
  50056. * source material index of refraction (IOR)' / 'destination material IOR.
  50057. */
  50058. indexOfRefraction: number;
  50059. /**
  50060. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50061. */
  50062. invertRefractionY: boolean;
  50063. /**
  50064. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50065. * Materials half opaque for instance using refraction could benefit from this control.
  50066. */
  50067. linkRefractionWithTransparency: boolean;
  50068. /**
  50069. * If true, the light map contains occlusion information instead of lighting info.
  50070. */
  50071. useLightmapAsShadowmap: boolean;
  50072. /**
  50073. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50074. */
  50075. useAlphaFromAlbedoTexture: boolean;
  50076. /**
  50077. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50078. */
  50079. forceAlphaTest: boolean;
  50080. /**
  50081. * Defines the alpha limits in alpha test mode.
  50082. */
  50083. alphaCutOff: number;
  50084. /**
  50085. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50086. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50087. */
  50088. useSpecularOverAlpha: boolean;
  50089. /**
  50090. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50091. */
  50092. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50093. /**
  50094. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50095. */
  50096. useRoughnessFromMetallicTextureAlpha: boolean;
  50097. /**
  50098. * Specifies if the metallic texture contains the roughness information in its green channel.
  50099. */
  50100. useRoughnessFromMetallicTextureGreen: boolean;
  50101. /**
  50102. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50103. */
  50104. useMetallnessFromMetallicTextureBlue: boolean;
  50105. /**
  50106. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50107. */
  50108. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50109. /**
  50110. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50111. */
  50112. useAmbientInGrayScale: boolean;
  50113. /**
  50114. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50115. * The material will try to infer what glossiness each pixel should be.
  50116. */
  50117. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50118. /**
  50119. * BJS is using an harcoded light falloff based on a manually sets up range.
  50120. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50121. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50122. */
  50123. /**
  50124. * BJS is using an harcoded light falloff based on a manually sets up range.
  50125. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50126. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50127. */
  50128. usePhysicalLightFalloff: boolean;
  50129. /**
  50130. * In order to support the falloff compatibility with gltf, a special mode has been added
  50131. * to reproduce the gltf light falloff.
  50132. */
  50133. /**
  50134. * In order to support the falloff compatibility with gltf, a special mode has been added
  50135. * to reproduce the gltf light falloff.
  50136. */
  50137. useGLTFLightFalloff: boolean;
  50138. /**
  50139. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50140. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50141. */
  50142. useRadianceOverAlpha: boolean;
  50143. /**
  50144. * Allows using an object space normal map (instead of tangent space).
  50145. */
  50146. useObjectSpaceNormalMap: boolean;
  50147. /**
  50148. * Allows using the bump map in parallax mode.
  50149. */
  50150. useParallax: boolean;
  50151. /**
  50152. * Allows using the bump map in parallax occlusion mode.
  50153. */
  50154. useParallaxOcclusion: boolean;
  50155. /**
  50156. * Controls the scale bias of the parallax mode.
  50157. */
  50158. parallaxScaleBias: number;
  50159. /**
  50160. * If sets to true, disables all the lights affecting the material.
  50161. */
  50162. disableLighting: boolean;
  50163. /**
  50164. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50165. */
  50166. forceIrradianceInFragment: boolean;
  50167. /**
  50168. * Number of Simultaneous lights allowed on the material.
  50169. */
  50170. maxSimultaneousLights: number;
  50171. /**
  50172. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50173. */
  50174. invertNormalMapX: boolean;
  50175. /**
  50176. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50177. */
  50178. invertNormalMapY: boolean;
  50179. /**
  50180. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50181. */
  50182. twoSidedLighting: boolean;
  50183. /**
  50184. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50185. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50186. */
  50187. useAlphaFresnel: boolean;
  50188. /**
  50189. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50190. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50191. */
  50192. useLinearAlphaFresnel: boolean;
  50193. /**
  50194. * Let user defines the brdf lookup texture used for IBL.
  50195. * A default 8bit version is embedded but you could point at :
  50196. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50197. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50198. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50199. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50200. */
  50201. environmentBRDFTexture: Nullable<BaseTexture>;
  50202. /**
  50203. * Force normal to face away from face.
  50204. */
  50205. forceNormalForward: boolean;
  50206. /**
  50207. * Enables specular anti aliasing in the PBR shader.
  50208. * It will both interacts on the Geometry for analytical and IBL lighting.
  50209. * It also prefilter the roughness map based on the bump values.
  50210. */
  50211. enableSpecularAntiAliasing: boolean;
  50212. /**
  50213. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50214. * makes the reflect vector face the model (under horizon).
  50215. */
  50216. useHorizonOcclusion: boolean;
  50217. /**
  50218. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50219. * too much the area relying on ambient texture to define their ambient occlusion.
  50220. */
  50221. useRadianceOcclusion: boolean;
  50222. /**
  50223. * If set to true, no lighting calculations will be applied.
  50224. */
  50225. unlit: boolean;
  50226. /**
  50227. * Gets the image processing configuration used either in this material.
  50228. */
  50229. /**
  50230. * Sets the Default image processing configuration used either in the this material.
  50231. *
  50232. * If sets to null, the scene one is in use.
  50233. */
  50234. imageProcessingConfiguration: ImageProcessingConfiguration;
  50235. /**
  50236. * Gets wether the color curves effect is enabled.
  50237. */
  50238. /**
  50239. * Sets wether the color curves effect is enabled.
  50240. */
  50241. cameraColorCurvesEnabled: boolean;
  50242. /**
  50243. * Gets wether the color grading effect is enabled.
  50244. */
  50245. /**
  50246. * Gets wether the color grading effect is enabled.
  50247. */
  50248. cameraColorGradingEnabled: boolean;
  50249. /**
  50250. * Gets wether tonemapping is enabled or not.
  50251. */
  50252. /**
  50253. * Sets wether tonemapping is enabled or not
  50254. */
  50255. cameraToneMappingEnabled: boolean;
  50256. /**
  50257. * The camera exposure used on this material.
  50258. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50259. * This corresponds to a photographic exposure.
  50260. */
  50261. /**
  50262. * The camera exposure used on this material.
  50263. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50264. * This corresponds to a photographic exposure.
  50265. */
  50266. cameraExposure: number;
  50267. /**
  50268. * Gets The camera contrast used on this material.
  50269. */
  50270. /**
  50271. * Sets The camera contrast used on this material.
  50272. */
  50273. cameraContrast: number;
  50274. /**
  50275. * Gets the Color Grading 2D Lookup Texture.
  50276. */
  50277. /**
  50278. * Sets the Color Grading 2D Lookup Texture.
  50279. */
  50280. cameraColorGradingTexture: Nullable<BaseTexture>;
  50281. /**
  50282. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50283. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50284. * 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;
  50285. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50286. */
  50287. /**
  50288. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50289. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50290. * 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;
  50291. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50292. */
  50293. cameraColorCurves: Nullable<ColorCurves>;
  50294. /**
  50295. * Instantiates a new PBRMaterial instance.
  50296. *
  50297. * @param name The material name
  50298. * @param scene The scene the material will be use in.
  50299. */
  50300. constructor(name: string, scene: Scene);
  50301. /**
  50302. * Returns the name of this material class.
  50303. */
  50304. getClassName(): string;
  50305. /**
  50306. * Makes a duplicate of the current material.
  50307. * @param name - name to use for the new material.
  50308. */
  50309. clone(name: string): PBRMaterial;
  50310. /**
  50311. * Serializes this PBR Material.
  50312. * @returns - An object with the serialized material.
  50313. */
  50314. serialize(): any;
  50315. /**
  50316. * Parses a PBR Material from a serialized object.
  50317. * @param source - Serialized object.
  50318. * @param scene - BJS scene instance.
  50319. * @param rootUrl - url for the scene object
  50320. * @returns - PBRMaterial
  50321. */
  50322. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50323. }
  50324. }
  50325. declare module BABYLON {
  50326. /**
  50327. * Direct draw surface info
  50328. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50329. */
  50330. export interface DDSInfo {
  50331. /**
  50332. * Width of the texture
  50333. */
  50334. width: number;
  50335. /**
  50336. * Width of the texture
  50337. */
  50338. height: number;
  50339. /**
  50340. * Number of Mipmaps for the texture
  50341. * @see https://en.wikipedia.org/wiki/Mipmap
  50342. */
  50343. mipmapCount: number;
  50344. /**
  50345. * If the textures format is a known fourCC format
  50346. * @see https://www.fourcc.org/
  50347. */
  50348. isFourCC: boolean;
  50349. /**
  50350. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50351. */
  50352. isRGB: boolean;
  50353. /**
  50354. * If the texture is a lumincance format
  50355. */
  50356. isLuminance: boolean;
  50357. /**
  50358. * If this is a cube texture
  50359. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50360. */
  50361. isCube: boolean;
  50362. /**
  50363. * If the texture is a compressed format eg. FOURCC_DXT1
  50364. */
  50365. isCompressed: boolean;
  50366. /**
  50367. * The dxgiFormat of the texture
  50368. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50369. */
  50370. dxgiFormat: number;
  50371. /**
  50372. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50373. */
  50374. textureType: number;
  50375. /**
  50376. * Sphericle polynomial created for the dds texture
  50377. */
  50378. sphericalPolynomial?: SphericalPolynomial;
  50379. }
  50380. /**
  50381. * Class used to provide DDS decompression tools
  50382. */
  50383. export class DDSTools {
  50384. /**
  50385. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50386. */
  50387. static StoreLODInAlphaChannel: boolean;
  50388. /**
  50389. * Gets DDS information from an array buffer
  50390. * @param arrayBuffer defines the array buffer to read data from
  50391. * @returns the DDS information
  50392. */
  50393. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50394. private static _FloatView;
  50395. private static _Int32View;
  50396. private static _ToHalfFloat;
  50397. private static _FromHalfFloat;
  50398. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50399. private static _GetHalfFloatRGBAArrayBuffer;
  50400. private static _GetFloatRGBAArrayBuffer;
  50401. private static _GetFloatAsUIntRGBAArrayBuffer;
  50402. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50403. private static _GetRGBAArrayBuffer;
  50404. private static _ExtractLongWordOrder;
  50405. private static _GetRGBArrayBuffer;
  50406. private static _GetLuminanceArrayBuffer;
  50407. /**
  50408. * Uploads DDS Levels to a Babylon Texture
  50409. * @hidden
  50410. */
  50411. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50412. }
  50413. interface ThinEngine {
  50414. /**
  50415. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50416. * @param rootUrl defines the url where the file to load is located
  50417. * @param scene defines the current scene
  50418. * @param lodScale defines scale to apply to the mip map selection
  50419. * @param lodOffset defines offset to apply to the mip map selection
  50420. * @param onLoad defines an optional callback raised when the texture is loaded
  50421. * @param onError defines an optional callback raised if there is an issue to load the texture
  50422. * @param format defines the format of the data
  50423. * @param forcedExtension defines the extension to use to pick the right loader
  50424. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50425. * @returns the cube texture as an InternalTexture
  50426. */
  50427. 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;
  50428. }
  50429. }
  50430. declare module BABYLON {
  50431. /**
  50432. * Implementation of the DDS Texture Loader.
  50433. * @hidden
  50434. */
  50435. export class _DDSTextureLoader implements IInternalTextureLoader {
  50436. /**
  50437. * Defines wether the loader supports cascade loading the different faces.
  50438. */
  50439. readonly supportCascades: boolean;
  50440. /**
  50441. * This returns if the loader support the current file information.
  50442. * @param extension defines the file extension of the file being loaded
  50443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50444. * @param fallback defines the fallback internal texture if any
  50445. * @param isBase64 defines whether the texture is encoded as a base64
  50446. * @param isBuffer defines whether the texture data are stored as a buffer
  50447. * @returns true if the loader can load the specified file
  50448. */
  50449. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50450. /**
  50451. * Transform the url before loading if required.
  50452. * @param rootUrl the url of the texture
  50453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50454. * @returns the transformed texture
  50455. */
  50456. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50457. /**
  50458. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50459. * @param rootUrl the url of the texture
  50460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50461. * @returns the fallback texture
  50462. */
  50463. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50464. /**
  50465. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50466. * @param data contains the texture data
  50467. * @param texture defines the BabylonJS internal texture
  50468. * @param createPolynomials will be true if polynomials have been requested
  50469. * @param onLoad defines the callback to trigger once the texture is ready
  50470. * @param onError defines the callback to trigger in case of error
  50471. */
  50472. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50473. /**
  50474. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50475. * @param data contains the texture data
  50476. * @param texture defines the BabylonJS internal texture
  50477. * @param callback defines the method to call once ready to upload
  50478. */
  50479. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50480. }
  50481. }
  50482. declare module BABYLON {
  50483. /**
  50484. * Implementation of the ENV Texture Loader.
  50485. * @hidden
  50486. */
  50487. export class _ENVTextureLoader implements IInternalTextureLoader {
  50488. /**
  50489. * Defines wether the loader supports cascade loading the different faces.
  50490. */
  50491. readonly supportCascades: boolean;
  50492. /**
  50493. * This returns if the loader support the current file information.
  50494. * @param extension defines the file extension of the file being loaded
  50495. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50496. * @param fallback defines the fallback internal texture if any
  50497. * @param isBase64 defines whether the texture is encoded as a base64
  50498. * @param isBuffer defines whether the texture data are stored as a buffer
  50499. * @returns true if the loader can load the specified file
  50500. */
  50501. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50502. /**
  50503. * Transform the url before loading if required.
  50504. * @param rootUrl the url of the texture
  50505. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50506. * @returns the transformed texture
  50507. */
  50508. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50509. /**
  50510. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50511. * @param rootUrl the url of the texture
  50512. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50513. * @returns the fallback texture
  50514. */
  50515. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50516. /**
  50517. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50518. * @param data contains the texture data
  50519. * @param texture defines the BabylonJS internal texture
  50520. * @param createPolynomials will be true if polynomials have been requested
  50521. * @param onLoad defines the callback to trigger once the texture is ready
  50522. * @param onError defines the callback to trigger in case of error
  50523. */
  50524. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50525. /**
  50526. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50527. * @param data contains the texture data
  50528. * @param texture defines the BabylonJS internal texture
  50529. * @param callback defines the method to call once ready to upload
  50530. */
  50531. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50532. }
  50533. }
  50534. declare module BABYLON {
  50535. /**
  50536. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50537. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50538. */
  50539. export class KhronosTextureContainer {
  50540. /** contents of the KTX container file */
  50541. arrayBuffer: any;
  50542. private static HEADER_LEN;
  50543. private static COMPRESSED_2D;
  50544. private static COMPRESSED_3D;
  50545. private static TEX_2D;
  50546. private static TEX_3D;
  50547. /**
  50548. * Gets the openGL type
  50549. */
  50550. glType: number;
  50551. /**
  50552. * Gets the openGL type size
  50553. */
  50554. glTypeSize: number;
  50555. /**
  50556. * Gets the openGL format
  50557. */
  50558. glFormat: number;
  50559. /**
  50560. * Gets the openGL internal format
  50561. */
  50562. glInternalFormat: number;
  50563. /**
  50564. * Gets the base internal format
  50565. */
  50566. glBaseInternalFormat: number;
  50567. /**
  50568. * Gets image width in pixel
  50569. */
  50570. pixelWidth: number;
  50571. /**
  50572. * Gets image height in pixel
  50573. */
  50574. pixelHeight: number;
  50575. /**
  50576. * Gets image depth in pixels
  50577. */
  50578. pixelDepth: number;
  50579. /**
  50580. * Gets the number of array elements
  50581. */
  50582. numberOfArrayElements: number;
  50583. /**
  50584. * Gets the number of faces
  50585. */
  50586. numberOfFaces: number;
  50587. /**
  50588. * Gets the number of mipmap levels
  50589. */
  50590. numberOfMipmapLevels: number;
  50591. /**
  50592. * Gets the bytes of key value data
  50593. */
  50594. bytesOfKeyValueData: number;
  50595. /**
  50596. * Gets the load type
  50597. */
  50598. loadType: number;
  50599. /**
  50600. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50601. */
  50602. isInvalid: boolean;
  50603. /**
  50604. * Creates a new KhronosTextureContainer
  50605. * @param arrayBuffer contents of the KTX container file
  50606. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50607. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50608. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50609. */
  50610. constructor(
  50611. /** contents of the KTX container file */
  50612. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50613. /**
  50614. * Uploads KTX content to a Babylon Texture.
  50615. * It is assumed that the texture has already been created & is currently bound
  50616. * @hidden
  50617. */
  50618. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50619. private _upload2DCompressedLevels;
  50620. }
  50621. }
  50622. declare module BABYLON {
  50623. /**
  50624. * Implementation of the KTX Texture Loader.
  50625. * @hidden
  50626. */
  50627. export class _KTXTextureLoader implements IInternalTextureLoader {
  50628. /**
  50629. * Defines wether the loader supports cascade loading the different faces.
  50630. */
  50631. readonly supportCascades: boolean;
  50632. /**
  50633. * This returns if the loader support the current file information.
  50634. * @param extension defines the file extension of the file being loaded
  50635. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50636. * @param fallback defines the fallback internal texture if any
  50637. * @param isBase64 defines whether the texture is encoded as a base64
  50638. * @param isBuffer defines whether the texture data are stored as a buffer
  50639. * @returns true if the loader can load the specified file
  50640. */
  50641. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50642. /**
  50643. * Transform the url before loading if required.
  50644. * @param rootUrl the url of the texture
  50645. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50646. * @returns the transformed texture
  50647. */
  50648. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50649. /**
  50650. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50651. * @param rootUrl the url of the texture
  50652. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50653. * @returns the fallback texture
  50654. */
  50655. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50656. /**
  50657. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50658. * @param data contains the texture data
  50659. * @param texture defines the BabylonJS internal texture
  50660. * @param createPolynomials will be true if polynomials have been requested
  50661. * @param onLoad defines the callback to trigger once the texture is ready
  50662. * @param onError defines the callback to trigger in case of error
  50663. */
  50664. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50665. /**
  50666. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50667. * @param data contains the texture data
  50668. * @param texture defines the BabylonJS internal texture
  50669. * @param callback defines the method to call once ready to upload
  50670. */
  50671. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50672. }
  50673. }
  50674. declare module BABYLON {
  50675. /** @hidden */
  50676. export var _forceSceneHelpersToBundle: boolean;
  50677. interface Scene {
  50678. /**
  50679. * Creates a default light for the scene.
  50680. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50681. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50682. */
  50683. createDefaultLight(replace?: boolean): void;
  50684. /**
  50685. * Creates a default camera for the scene.
  50686. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50687. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50688. * @param replace has default false, when true replaces the active camera in the scene
  50689. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50690. */
  50691. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50692. /**
  50693. * Creates a default camera and a default light.
  50694. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50695. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50696. * @param replace has the default false, when true replaces the active camera/light in the scene
  50697. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50698. */
  50699. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50700. /**
  50701. * Creates a new sky box
  50702. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50703. * @param environmentTexture defines the texture to use as environment texture
  50704. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50705. * @param scale defines the overall scale of the skybox
  50706. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50707. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50708. * @returns a new mesh holding the sky box
  50709. */
  50710. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50711. /**
  50712. * Creates a new environment
  50713. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50714. * @param options defines the options you can use to configure the environment
  50715. * @returns the new EnvironmentHelper
  50716. */
  50717. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50718. /**
  50719. * Creates a new VREXperienceHelper
  50720. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50721. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50722. * @returns a new VREXperienceHelper
  50723. */
  50724. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50725. /**
  50726. * Creates a new WebXRDefaultExperience
  50727. * @see http://doc.babylonjs.com/how_to/webxr
  50728. * @param options experience options
  50729. * @returns a promise for a new WebXRDefaultExperience
  50730. */
  50731. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50732. }
  50733. }
  50734. declare module BABYLON {
  50735. /**
  50736. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50737. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50738. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50739. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50740. */
  50741. export class VideoDome extends TransformNode {
  50742. /**
  50743. * Define the video source as a Monoscopic panoramic 360 video.
  50744. */
  50745. static readonly MODE_MONOSCOPIC: number;
  50746. /**
  50747. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50748. */
  50749. static readonly MODE_TOPBOTTOM: number;
  50750. /**
  50751. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50752. */
  50753. static readonly MODE_SIDEBYSIDE: number;
  50754. private _halfDome;
  50755. private _useDirectMapping;
  50756. /**
  50757. * The video texture being displayed on the sphere
  50758. */
  50759. protected _videoTexture: VideoTexture;
  50760. /**
  50761. * Gets the video texture being displayed on the sphere
  50762. */
  50763. readonly videoTexture: VideoTexture;
  50764. /**
  50765. * The skybox material
  50766. */
  50767. protected _material: BackgroundMaterial;
  50768. /**
  50769. * The surface used for the skybox
  50770. */
  50771. protected _mesh: Mesh;
  50772. /**
  50773. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50774. */
  50775. private _halfDomeMask;
  50776. /**
  50777. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50778. * Also see the options.resolution property.
  50779. */
  50780. fovMultiplier: number;
  50781. private _videoMode;
  50782. /**
  50783. * Gets or set the current video mode for the video. It can be:
  50784. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50785. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50786. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50787. */
  50788. videoMode: number;
  50789. /**
  50790. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50791. *
  50792. */
  50793. /**
  50794. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50795. */
  50796. halfDome: boolean;
  50797. /**
  50798. * Oberserver used in Stereoscopic VR Mode.
  50799. */
  50800. private _onBeforeCameraRenderObserver;
  50801. /**
  50802. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50803. * @param name Element's name, child elements will append suffixes for their own names.
  50804. * @param urlsOrVideo defines the url(s) or the video element to use
  50805. * @param options An object containing optional or exposed sub element properties
  50806. */
  50807. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50808. resolution?: number;
  50809. clickToPlay?: boolean;
  50810. autoPlay?: boolean;
  50811. loop?: boolean;
  50812. size?: number;
  50813. poster?: string;
  50814. faceForward?: boolean;
  50815. useDirectMapping?: boolean;
  50816. halfDomeMode?: boolean;
  50817. }, scene: Scene);
  50818. private _changeVideoMode;
  50819. /**
  50820. * Releases resources associated with this node.
  50821. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50822. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50823. */
  50824. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50825. }
  50826. }
  50827. declare module BABYLON {
  50828. /**
  50829. * This class can be used to get instrumentation data from a Babylon engine
  50830. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50831. */
  50832. export class EngineInstrumentation implements IDisposable {
  50833. /**
  50834. * Define the instrumented engine.
  50835. */
  50836. engine: Engine;
  50837. private _captureGPUFrameTime;
  50838. private _gpuFrameTimeToken;
  50839. private _gpuFrameTime;
  50840. private _captureShaderCompilationTime;
  50841. private _shaderCompilationTime;
  50842. private _onBeginFrameObserver;
  50843. private _onEndFrameObserver;
  50844. private _onBeforeShaderCompilationObserver;
  50845. private _onAfterShaderCompilationObserver;
  50846. /**
  50847. * Gets the perf counter used for GPU frame time
  50848. */
  50849. readonly gpuFrameTimeCounter: PerfCounter;
  50850. /**
  50851. * Gets the GPU frame time capture status
  50852. */
  50853. /**
  50854. * Enable or disable the GPU frame time capture
  50855. */
  50856. captureGPUFrameTime: boolean;
  50857. /**
  50858. * Gets the perf counter used for shader compilation time
  50859. */
  50860. readonly shaderCompilationTimeCounter: PerfCounter;
  50861. /**
  50862. * Gets the shader compilation time capture status
  50863. */
  50864. /**
  50865. * Enable or disable the shader compilation time capture
  50866. */
  50867. captureShaderCompilationTime: boolean;
  50868. /**
  50869. * Instantiates a new engine instrumentation.
  50870. * This class can be used to get instrumentation data from a Babylon engine
  50871. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50872. * @param engine Defines the engine to instrument
  50873. */
  50874. constructor(
  50875. /**
  50876. * Define the instrumented engine.
  50877. */
  50878. engine: Engine);
  50879. /**
  50880. * Dispose and release associated resources.
  50881. */
  50882. dispose(): void;
  50883. }
  50884. }
  50885. declare module BABYLON {
  50886. /**
  50887. * This class can be used to get instrumentation data from a Babylon engine
  50888. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50889. */
  50890. export class SceneInstrumentation implements IDisposable {
  50891. /**
  50892. * Defines the scene to instrument
  50893. */
  50894. scene: Scene;
  50895. private _captureActiveMeshesEvaluationTime;
  50896. private _activeMeshesEvaluationTime;
  50897. private _captureRenderTargetsRenderTime;
  50898. private _renderTargetsRenderTime;
  50899. private _captureFrameTime;
  50900. private _frameTime;
  50901. private _captureRenderTime;
  50902. private _renderTime;
  50903. private _captureInterFrameTime;
  50904. private _interFrameTime;
  50905. private _captureParticlesRenderTime;
  50906. private _particlesRenderTime;
  50907. private _captureSpritesRenderTime;
  50908. private _spritesRenderTime;
  50909. private _capturePhysicsTime;
  50910. private _physicsTime;
  50911. private _captureAnimationsTime;
  50912. private _animationsTime;
  50913. private _captureCameraRenderTime;
  50914. private _cameraRenderTime;
  50915. private _onBeforeActiveMeshesEvaluationObserver;
  50916. private _onAfterActiveMeshesEvaluationObserver;
  50917. private _onBeforeRenderTargetsRenderObserver;
  50918. private _onAfterRenderTargetsRenderObserver;
  50919. private _onAfterRenderObserver;
  50920. private _onBeforeDrawPhaseObserver;
  50921. private _onAfterDrawPhaseObserver;
  50922. private _onBeforeAnimationsObserver;
  50923. private _onBeforeParticlesRenderingObserver;
  50924. private _onAfterParticlesRenderingObserver;
  50925. private _onBeforeSpritesRenderingObserver;
  50926. private _onAfterSpritesRenderingObserver;
  50927. private _onBeforePhysicsObserver;
  50928. private _onAfterPhysicsObserver;
  50929. private _onAfterAnimationsObserver;
  50930. private _onBeforeCameraRenderObserver;
  50931. private _onAfterCameraRenderObserver;
  50932. /**
  50933. * Gets the perf counter used for active meshes evaluation time
  50934. */
  50935. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50936. /**
  50937. * Gets the active meshes evaluation time capture status
  50938. */
  50939. /**
  50940. * Enable or disable the active meshes evaluation time capture
  50941. */
  50942. captureActiveMeshesEvaluationTime: boolean;
  50943. /**
  50944. * Gets the perf counter used for render targets render time
  50945. */
  50946. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50947. /**
  50948. * Gets the render targets render time capture status
  50949. */
  50950. /**
  50951. * Enable or disable the render targets render time capture
  50952. */
  50953. captureRenderTargetsRenderTime: boolean;
  50954. /**
  50955. * Gets the perf counter used for particles render time
  50956. */
  50957. readonly particlesRenderTimeCounter: PerfCounter;
  50958. /**
  50959. * Gets the particles render time capture status
  50960. */
  50961. /**
  50962. * Enable or disable the particles render time capture
  50963. */
  50964. captureParticlesRenderTime: boolean;
  50965. /**
  50966. * Gets the perf counter used for sprites render time
  50967. */
  50968. readonly spritesRenderTimeCounter: PerfCounter;
  50969. /**
  50970. * Gets the sprites render time capture status
  50971. */
  50972. /**
  50973. * Enable or disable the sprites render time capture
  50974. */
  50975. captureSpritesRenderTime: boolean;
  50976. /**
  50977. * Gets the perf counter used for physics time
  50978. */
  50979. readonly physicsTimeCounter: PerfCounter;
  50980. /**
  50981. * Gets the physics time capture status
  50982. */
  50983. /**
  50984. * Enable or disable the physics time capture
  50985. */
  50986. capturePhysicsTime: boolean;
  50987. /**
  50988. * Gets the perf counter used for animations time
  50989. */
  50990. readonly animationsTimeCounter: PerfCounter;
  50991. /**
  50992. * Gets the animations time capture status
  50993. */
  50994. /**
  50995. * Enable or disable the animations time capture
  50996. */
  50997. captureAnimationsTime: boolean;
  50998. /**
  50999. * Gets the perf counter used for frame time capture
  51000. */
  51001. readonly frameTimeCounter: PerfCounter;
  51002. /**
  51003. * Gets the frame time capture status
  51004. */
  51005. /**
  51006. * Enable or disable the frame time capture
  51007. */
  51008. captureFrameTime: boolean;
  51009. /**
  51010. * Gets the perf counter used for inter-frames time capture
  51011. */
  51012. readonly interFrameTimeCounter: PerfCounter;
  51013. /**
  51014. * Gets the inter-frames time capture status
  51015. */
  51016. /**
  51017. * Enable or disable the inter-frames time capture
  51018. */
  51019. captureInterFrameTime: boolean;
  51020. /**
  51021. * Gets the perf counter used for render time capture
  51022. */
  51023. readonly renderTimeCounter: PerfCounter;
  51024. /**
  51025. * Gets the render time capture status
  51026. */
  51027. /**
  51028. * Enable or disable the render time capture
  51029. */
  51030. captureRenderTime: boolean;
  51031. /**
  51032. * Gets the perf counter used for camera render time capture
  51033. */
  51034. readonly cameraRenderTimeCounter: PerfCounter;
  51035. /**
  51036. * Gets the camera render time capture status
  51037. */
  51038. /**
  51039. * Enable or disable the camera render time capture
  51040. */
  51041. captureCameraRenderTime: boolean;
  51042. /**
  51043. * Gets the perf counter used for draw calls
  51044. */
  51045. readonly drawCallsCounter: PerfCounter;
  51046. /**
  51047. * Instantiates a new scene instrumentation.
  51048. * This class can be used to get instrumentation data from a Babylon engine
  51049. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51050. * @param scene Defines the scene to instrument
  51051. */
  51052. constructor(
  51053. /**
  51054. * Defines the scene to instrument
  51055. */
  51056. scene: Scene);
  51057. /**
  51058. * Dispose and release associated resources.
  51059. */
  51060. dispose(): void;
  51061. }
  51062. }
  51063. declare module BABYLON {
  51064. /** @hidden */
  51065. export var glowMapGenerationPixelShader: {
  51066. name: string;
  51067. shader: string;
  51068. };
  51069. }
  51070. declare module BABYLON {
  51071. /** @hidden */
  51072. export var glowMapGenerationVertexShader: {
  51073. name: string;
  51074. shader: string;
  51075. };
  51076. }
  51077. declare module BABYLON {
  51078. /**
  51079. * Effect layer options. This helps customizing the behaviour
  51080. * of the effect layer.
  51081. */
  51082. export interface IEffectLayerOptions {
  51083. /**
  51084. * Multiplication factor apply to the canvas size to compute the render target size
  51085. * used to generated the objects (the smaller the faster).
  51086. */
  51087. mainTextureRatio: number;
  51088. /**
  51089. * Enforces a fixed size texture to ensure effect stability across devices.
  51090. */
  51091. mainTextureFixedSize?: number;
  51092. /**
  51093. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51094. */
  51095. alphaBlendingMode: number;
  51096. /**
  51097. * The camera attached to the layer.
  51098. */
  51099. camera: Nullable<Camera>;
  51100. /**
  51101. * The rendering group to draw the layer in.
  51102. */
  51103. renderingGroupId: number;
  51104. }
  51105. /**
  51106. * The effect layer Helps adding post process effect blended with the main pass.
  51107. *
  51108. * This can be for instance use to generate glow or higlight effects on the scene.
  51109. *
  51110. * The effect layer class can not be used directly and is intented to inherited from to be
  51111. * customized per effects.
  51112. */
  51113. export abstract class EffectLayer {
  51114. private _vertexBuffers;
  51115. private _indexBuffer;
  51116. private _cachedDefines;
  51117. private _effectLayerMapGenerationEffect;
  51118. private _effectLayerOptions;
  51119. private _mergeEffect;
  51120. protected _scene: Scene;
  51121. protected _engine: Engine;
  51122. protected _maxSize: number;
  51123. protected _mainTextureDesiredSize: ISize;
  51124. protected _mainTexture: RenderTargetTexture;
  51125. protected _shouldRender: boolean;
  51126. protected _postProcesses: PostProcess[];
  51127. protected _textures: BaseTexture[];
  51128. protected _emissiveTextureAndColor: {
  51129. texture: Nullable<BaseTexture>;
  51130. color: Color4;
  51131. };
  51132. /**
  51133. * The name of the layer
  51134. */
  51135. name: string;
  51136. /**
  51137. * The clear color of the texture used to generate the glow map.
  51138. */
  51139. neutralColor: Color4;
  51140. /**
  51141. * Specifies wether the highlight layer is enabled or not.
  51142. */
  51143. isEnabled: boolean;
  51144. /**
  51145. * Gets the camera attached to the layer.
  51146. */
  51147. readonly camera: Nullable<Camera>;
  51148. /**
  51149. * Gets the rendering group id the layer should render in.
  51150. */
  51151. renderingGroupId: number;
  51152. /**
  51153. * An event triggered when the effect layer has been disposed.
  51154. */
  51155. onDisposeObservable: Observable<EffectLayer>;
  51156. /**
  51157. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51158. */
  51159. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51160. /**
  51161. * An event triggered when the generated texture is being merged in the scene.
  51162. */
  51163. onBeforeComposeObservable: Observable<EffectLayer>;
  51164. /**
  51165. * An event triggered when the mesh is rendered into the effect render target.
  51166. */
  51167. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  51168. /**
  51169. * An event triggered after the mesh has been rendered into the effect render target.
  51170. */
  51171. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  51172. /**
  51173. * An event triggered when the generated texture has been merged in the scene.
  51174. */
  51175. onAfterComposeObservable: Observable<EffectLayer>;
  51176. /**
  51177. * An event triggered when the efffect layer changes its size.
  51178. */
  51179. onSizeChangedObservable: Observable<EffectLayer>;
  51180. /** @hidden */
  51181. static _SceneComponentInitialization: (scene: Scene) => void;
  51182. /**
  51183. * Instantiates a new effect Layer and references it in the scene.
  51184. * @param name The name of the layer
  51185. * @param scene The scene to use the layer in
  51186. */
  51187. constructor(
  51188. /** The Friendly of the effect in the scene */
  51189. name: string, scene: Scene);
  51190. /**
  51191. * Get the effect name of the layer.
  51192. * @return The effect name
  51193. */
  51194. abstract getEffectName(): string;
  51195. /**
  51196. * Checks for the readiness of the element composing the layer.
  51197. * @param subMesh the mesh to check for
  51198. * @param useInstances specify wether or not to use instances to render the mesh
  51199. * @return true if ready otherwise, false
  51200. */
  51201. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51202. /**
  51203. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51204. * @returns true if the effect requires stencil during the main canvas render pass.
  51205. */
  51206. abstract needStencil(): boolean;
  51207. /**
  51208. * Create the merge effect. This is the shader use to blit the information back
  51209. * to the main canvas at the end of the scene rendering.
  51210. * @returns The effect containing the shader used to merge the effect on the main canvas
  51211. */
  51212. protected abstract _createMergeEffect(): Effect;
  51213. /**
  51214. * Creates the render target textures and post processes used in the effect layer.
  51215. */
  51216. protected abstract _createTextureAndPostProcesses(): void;
  51217. /**
  51218. * Implementation specific of rendering the generating effect on the main canvas.
  51219. * @param effect The effect used to render through
  51220. */
  51221. protected abstract _internalRender(effect: Effect): void;
  51222. /**
  51223. * Sets the required values for both the emissive texture and and the main color.
  51224. */
  51225. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51226. /**
  51227. * Free any resources and references associated to a mesh.
  51228. * Internal use
  51229. * @param mesh The mesh to free.
  51230. */
  51231. abstract _disposeMesh(mesh: Mesh): void;
  51232. /**
  51233. * Serializes this layer (Glow or Highlight for example)
  51234. * @returns a serialized layer object
  51235. */
  51236. abstract serialize?(): any;
  51237. /**
  51238. * Initializes the effect layer with the required options.
  51239. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51240. */
  51241. protected _init(options: Partial<IEffectLayerOptions>): void;
  51242. /**
  51243. * Generates the index buffer of the full screen quad blending to the main canvas.
  51244. */
  51245. private _generateIndexBuffer;
  51246. /**
  51247. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51248. */
  51249. private _generateVertexBuffer;
  51250. /**
  51251. * Sets the main texture desired size which is the closest power of two
  51252. * of the engine canvas size.
  51253. */
  51254. private _setMainTextureSize;
  51255. /**
  51256. * Creates the main texture for the effect layer.
  51257. */
  51258. protected _createMainTexture(): void;
  51259. /**
  51260. * Adds specific effects defines.
  51261. * @param defines The defines to add specifics to.
  51262. */
  51263. protected _addCustomEffectDefines(defines: string[]): void;
  51264. /**
  51265. * Checks for the readiness of the element composing the layer.
  51266. * @param subMesh the mesh to check for
  51267. * @param useInstances specify wether or not to use instances to render the mesh
  51268. * @param emissiveTexture the associated emissive texture used to generate the glow
  51269. * @return true if ready otherwise, false
  51270. */
  51271. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51272. /**
  51273. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51274. */
  51275. render(): void;
  51276. /**
  51277. * Determine if a given mesh will be used in the current effect.
  51278. * @param mesh mesh to test
  51279. * @returns true if the mesh will be used
  51280. */
  51281. hasMesh(mesh: AbstractMesh): boolean;
  51282. /**
  51283. * Returns true if the layer contains information to display, otherwise false.
  51284. * @returns true if the glow layer should be rendered
  51285. */
  51286. shouldRender(): boolean;
  51287. /**
  51288. * Returns true if the mesh should render, otherwise false.
  51289. * @param mesh The mesh to render
  51290. * @returns true if it should render otherwise false
  51291. */
  51292. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51293. /**
  51294. * Returns true if the mesh can be rendered, otherwise false.
  51295. * @param mesh The mesh to render
  51296. * @param material The material used on the mesh
  51297. * @returns true if it can be rendered otherwise false
  51298. */
  51299. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51300. /**
  51301. * Returns true if the mesh should render, otherwise false.
  51302. * @param mesh The mesh to render
  51303. * @returns true if it should render otherwise false
  51304. */
  51305. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51306. /**
  51307. * Renders the submesh passed in parameter to the generation map.
  51308. */
  51309. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51310. /**
  51311. * Defines wether the current material of the mesh should be use to render the effect.
  51312. * @param mesh defines the current mesh to render
  51313. */
  51314. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51315. /**
  51316. * Rebuild the required buffers.
  51317. * @hidden Internal use only.
  51318. */
  51319. _rebuild(): void;
  51320. /**
  51321. * Dispose only the render target textures and post process.
  51322. */
  51323. private _disposeTextureAndPostProcesses;
  51324. /**
  51325. * Dispose the highlight layer and free resources.
  51326. */
  51327. dispose(): void;
  51328. /**
  51329. * Gets the class name of the effect layer
  51330. * @returns the string with the class name of the effect layer
  51331. */
  51332. getClassName(): string;
  51333. /**
  51334. * Creates an effect layer from parsed effect layer data
  51335. * @param parsedEffectLayer defines effect layer data
  51336. * @param scene defines the current scene
  51337. * @param rootUrl defines the root URL containing the effect layer information
  51338. * @returns a parsed effect Layer
  51339. */
  51340. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51341. }
  51342. }
  51343. declare module BABYLON {
  51344. interface AbstractScene {
  51345. /**
  51346. * The list of effect layers (highlights/glow) added to the scene
  51347. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51348. * @see http://doc.babylonjs.com/how_to/glow_layer
  51349. */
  51350. effectLayers: Array<EffectLayer>;
  51351. /**
  51352. * Removes the given effect layer from this scene.
  51353. * @param toRemove defines the effect layer to remove
  51354. * @returns the index of the removed effect layer
  51355. */
  51356. removeEffectLayer(toRemove: EffectLayer): number;
  51357. /**
  51358. * Adds the given effect layer to this scene
  51359. * @param newEffectLayer defines the effect layer to add
  51360. */
  51361. addEffectLayer(newEffectLayer: EffectLayer): void;
  51362. }
  51363. /**
  51364. * Defines the layer scene component responsible to manage any effect layers
  51365. * in a given scene.
  51366. */
  51367. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51368. /**
  51369. * The component name helpfull to identify the component in the list of scene components.
  51370. */
  51371. readonly name: string;
  51372. /**
  51373. * The scene the component belongs to.
  51374. */
  51375. scene: Scene;
  51376. private _engine;
  51377. private _renderEffects;
  51378. private _needStencil;
  51379. private _previousStencilState;
  51380. /**
  51381. * Creates a new instance of the component for the given scene
  51382. * @param scene Defines the scene to register the component in
  51383. */
  51384. constructor(scene: Scene);
  51385. /**
  51386. * Registers the component in a given scene
  51387. */
  51388. register(): void;
  51389. /**
  51390. * Rebuilds the elements related to this component in case of
  51391. * context lost for instance.
  51392. */
  51393. rebuild(): void;
  51394. /**
  51395. * Serializes the component data to the specified json object
  51396. * @param serializationObject The object to serialize to
  51397. */
  51398. serialize(serializationObject: any): void;
  51399. /**
  51400. * Adds all the elements from the container to the scene
  51401. * @param container the container holding the elements
  51402. */
  51403. addFromContainer(container: AbstractScene): void;
  51404. /**
  51405. * Removes all the elements in the container from the scene
  51406. * @param container contains the elements to remove
  51407. * @param dispose if the removed element should be disposed (default: false)
  51408. */
  51409. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51410. /**
  51411. * Disposes the component and the associated ressources.
  51412. */
  51413. dispose(): void;
  51414. private _isReadyForMesh;
  51415. private _renderMainTexture;
  51416. private _setStencil;
  51417. private _setStencilBack;
  51418. private _draw;
  51419. private _drawCamera;
  51420. private _drawRenderingGroup;
  51421. }
  51422. }
  51423. declare module BABYLON {
  51424. /** @hidden */
  51425. export var glowMapMergePixelShader: {
  51426. name: string;
  51427. shader: string;
  51428. };
  51429. }
  51430. declare module BABYLON {
  51431. /** @hidden */
  51432. export var glowMapMergeVertexShader: {
  51433. name: string;
  51434. shader: string;
  51435. };
  51436. }
  51437. declare module BABYLON {
  51438. interface AbstractScene {
  51439. /**
  51440. * Return a the first highlight layer of the scene with a given name.
  51441. * @param name The name of the highlight layer to look for.
  51442. * @return The highlight layer if found otherwise null.
  51443. */
  51444. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51445. }
  51446. /**
  51447. * Glow layer options. This helps customizing the behaviour
  51448. * of the glow layer.
  51449. */
  51450. export interface IGlowLayerOptions {
  51451. /**
  51452. * Multiplication factor apply to the canvas size to compute the render target size
  51453. * used to generated the glowing objects (the smaller the faster).
  51454. */
  51455. mainTextureRatio: number;
  51456. /**
  51457. * Enforces a fixed size texture to ensure resize independant blur.
  51458. */
  51459. mainTextureFixedSize?: number;
  51460. /**
  51461. * How big is the kernel of the blur texture.
  51462. */
  51463. blurKernelSize: number;
  51464. /**
  51465. * The camera attached to the layer.
  51466. */
  51467. camera: Nullable<Camera>;
  51468. /**
  51469. * Enable MSAA by chosing the number of samples.
  51470. */
  51471. mainTextureSamples?: number;
  51472. /**
  51473. * The rendering group to draw the layer in.
  51474. */
  51475. renderingGroupId: number;
  51476. }
  51477. /**
  51478. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51479. *
  51480. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  51481. *
  51482. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51483. */
  51484. export class GlowLayer extends EffectLayer {
  51485. /**
  51486. * Effect Name of the layer.
  51487. */
  51488. static readonly EffectName: string;
  51489. /**
  51490. * The default blur kernel size used for the glow.
  51491. */
  51492. static DefaultBlurKernelSize: number;
  51493. /**
  51494. * The default texture size ratio used for the glow.
  51495. */
  51496. static DefaultTextureRatio: number;
  51497. /**
  51498. * Sets the kernel size of the blur.
  51499. */
  51500. /**
  51501. * Gets the kernel size of the blur.
  51502. */
  51503. blurKernelSize: number;
  51504. /**
  51505. * Sets the glow intensity.
  51506. */
  51507. /**
  51508. * Gets the glow intensity.
  51509. */
  51510. intensity: number;
  51511. private _options;
  51512. private _intensity;
  51513. private _horizontalBlurPostprocess1;
  51514. private _verticalBlurPostprocess1;
  51515. private _horizontalBlurPostprocess2;
  51516. private _verticalBlurPostprocess2;
  51517. private _blurTexture1;
  51518. private _blurTexture2;
  51519. private _postProcesses1;
  51520. private _postProcesses2;
  51521. private _includedOnlyMeshes;
  51522. private _excludedMeshes;
  51523. private _meshesUsingTheirOwnMaterials;
  51524. /**
  51525. * Callback used to let the user override the color selection on a per mesh basis
  51526. */
  51527. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51528. /**
  51529. * Callback used to let the user override the texture selection on a per mesh basis
  51530. */
  51531. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51532. /**
  51533. * Instantiates a new glow Layer and references it to the scene.
  51534. * @param name The name of the layer
  51535. * @param scene The scene to use the layer in
  51536. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51537. */
  51538. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51539. /**
  51540. * Get the effect name of the layer.
  51541. * @return The effect name
  51542. */
  51543. getEffectName(): string;
  51544. /**
  51545. * Create the merge effect. This is the shader use to blit the information back
  51546. * to the main canvas at the end of the scene rendering.
  51547. */
  51548. protected _createMergeEffect(): Effect;
  51549. /**
  51550. * Creates the render target textures and post processes used in the glow layer.
  51551. */
  51552. protected _createTextureAndPostProcesses(): void;
  51553. /**
  51554. * Checks for the readiness of the element composing the layer.
  51555. * @param subMesh the mesh to check for
  51556. * @param useInstances specify wether or not to use instances to render the mesh
  51557. * @param emissiveTexture the associated emissive texture used to generate the glow
  51558. * @return true if ready otherwise, false
  51559. */
  51560. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51561. /**
  51562. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51563. */
  51564. needStencil(): boolean;
  51565. /**
  51566. * Returns true if the mesh can be rendered, otherwise false.
  51567. * @param mesh The mesh to render
  51568. * @param material The material used on the mesh
  51569. * @returns true if it can be rendered otherwise false
  51570. */
  51571. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51572. /**
  51573. * Implementation specific of rendering the generating effect on the main canvas.
  51574. * @param effect The effect used to render through
  51575. */
  51576. protected _internalRender(effect: Effect): void;
  51577. /**
  51578. * Sets the required values for both the emissive texture and and the main color.
  51579. */
  51580. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51581. /**
  51582. * Returns true if the mesh should render, otherwise false.
  51583. * @param mesh The mesh to render
  51584. * @returns true if it should render otherwise false
  51585. */
  51586. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51587. /**
  51588. * Adds specific effects defines.
  51589. * @param defines The defines to add specifics to.
  51590. */
  51591. protected _addCustomEffectDefines(defines: string[]): void;
  51592. /**
  51593. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51594. * @param mesh The mesh to exclude from the glow layer
  51595. */
  51596. addExcludedMesh(mesh: Mesh): void;
  51597. /**
  51598. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51599. * @param mesh The mesh to remove
  51600. */
  51601. removeExcludedMesh(mesh: Mesh): void;
  51602. /**
  51603. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51604. * @param mesh The mesh to include in the glow layer
  51605. */
  51606. addIncludedOnlyMesh(mesh: Mesh): void;
  51607. /**
  51608. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51609. * @param mesh The mesh to remove
  51610. */
  51611. removeIncludedOnlyMesh(mesh: Mesh): void;
  51612. /**
  51613. * Determine if a given mesh will be used in the glow layer
  51614. * @param mesh The mesh to test
  51615. * @returns true if the mesh will be highlighted by the current glow layer
  51616. */
  51617. hasMesh(mesh: AbstractMesh): boolean;
  51618. /**
  51619. * Defines wether the current material of the mesh should be use to render the effect.
  51620. * @param mesh defines the current mesh to render
  51621. */
  51622. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  51623. /**
  51624. * Add a mesh to be rendered through its own material and not with emissive only.
  51625. * @param mesh The mesh for which we need to use its material
  51626. */
  51627. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  51628. /**
  51629. * Remove a mesh from being rendered through its own material and not with emissive only.
  51630. * @param mesh The mesh for which we need to not use its material
  51631. */
  51632. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  51633. /**
  51634. * Free any resources and references associated to a mesh.
  51635. * Internal use
  51636. * @param mesh The mesh to free.
  51637. * @hidden
  51638. */
  51639. _disposeMesh(mesh: Mesh): void;
  51640. /**
  51641. * Gets the class name of the effect layer
  51642. * @returns the string with the class name of the effect layer
  51643. */
  51644. getClassName(): string;
  51645. /**
  51646. * Serializes this glow layer
  51647. * @returns a serialized glow layer object
  51648. */
  51649. serialize(): any;
  51650. /**
  51651. * Creates a Glow Layer from parsed glow layer data
  51652. * @param parsedGlowLayer defines glow layer data
  51653. * @param scene defines the current scene
  51654. * @param rootUrl defines the root URL containing the glow layer information
  51655. * @returns a parsed Glow Layer
  51656. */
  51657. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51658. }
  51659. }
  51660. declare module BABYLON {
  51661. /** @hidden */
  51662. export var glowBlurPostProcessPixelShader: {
  51663. name: string;
  51664. shader: string;
  51665. };
  51666. }
  51667. declare module BABYLON {
  51668. interface AbstractScene {
  51669. /**
  51670. * Return a the first highlight layer of the scene with a given name.
  51671. * @param name The name of the highlight layer to look for.
  51672. * @return The highlight layer if found otherwise null.
  51673. */
  51674. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51675. }
  51676. /**
  51677. * Highlight layer options. This helps customizing the behaviour
  51678. * of the highlight layer.
  51679. */
  51680. export interface IHighlightLayerOptions {
  51681. /**
  51682. * Multiplication factor apply to the canvas size to compute the render target size
  51683. * used to generated the glowing objects (the smaller the faster).
  51684. */
  51685. mainTextureRatio: number;
  51686. /**
  51687. * Enforces a fixed size texture to ensure resize independant blur.
  51688. */
  51689. mainTextureFixedSize?: number;
  51690. /**
  51691. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51692. * of the picture to blur (the smaller the faster).
  51693. */
  51694. blurTextureSizeRatio: number;
  51695. /**
  51696. * How big in texel of the blur texture is the vertical blur.
  51697. */
  51698. blurVerticalSize: number;
  51699. /**
  51700. * How big in texel of the blur texture is the horizontal blur.
  51701. */
  51702. blurHorizontalSize: number;
  51703. /**
  51704. * Alpha blending mode used to apply the blur. Default is combine.
  51705. */
  51706. alphaBlendingMode: number;
  51707. /**
  51708. * The camera attached to the layer.
  51709. */
  51710. camera: Nullable<Camera>;
  51711. /**
  51712. * Should we display highlight as a solid stroke?
  51713. */
  51714. isStroke?: boolean;
  51715. /**
  51716. * The rendering group to draw the layer in.
  51717. */
  51718. renderingGroupId: number;
  51719. }
  51720. /**
  51721. * The highlight layer Helps adding a glow effect around a mesh.
  51722. *
  51723. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  51724. * glowy meshes to your scene.
  51725. *
  51726. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51727. */
  51728. export class HighlightLayer extends EffectLayer {
  51729. name: string;
  51730. /**
  51731. * Effect Name of the highlight layer.
  51732. */
  51733. static readonly EffectName: string;
  51734. /**
  51735. * The neutral color used during the preparation of the glow effect.
  51736. * This is black by default as the blend operation is a blend operation.
  51737. */
  51738. static NeutralColor: Color4;
  51739. /**
  51740. * Stencil value used for glowing meshes.
  51741. */
  51742. static GlowingMeshStencilReference: number;
  51743. /**
  51744. * Stencil value used for the other meshes in the scene.
  51745. */
  51746. static NormalMeshStencilReference: number;
  51747. /**
  51748. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51749. */
  51750. innerGlow: boolean;
  51751. /**
  51752. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51753. */
  51754. outerGlow: boolean;
  51755. /**
  51756. * Specifies the horizontal size of the blur.
  51757. */
  51758. /**
  51759. * Gets the horizontal size of the blur.
  51760. */
  51761. blurHorizontalSize: number;
  51762. /**
  51763. * Specifies the vertical size of the blur.
  51764. */
  51765. /**
  51766. * Gets the vertical size of the blur.
  51767. */
  51768. blurVerticalSize: number;
  51769. /**
  51770. * An event triggered when the highlight layer is being blurred.
  51771. */
  51772. onBeforeBlurObservable: Observable<HighlightLayer>;
  51773. /**
  51774. * An event triggered when the highlight layer has been blurred.
  51775. */
  51776. onAfterBlurObservable: Observable<HighlightLayer>;
  51777. private _instanceGlowingMeshStencilReference;
  51778. private _options;
  51779. private _downSamplePostprocess;
  51780. private _horizontalBlurPostprocess;
  51781. private _verticalBlurPostprocess;
  51782. private _blurTexture;
  51783. private _meshes;
  51784. private _excludedMeshes;
  51785. /**
  51786. * Instantiates a new highlight Layer and references it to the scene..
  51787. * @param name The name of the layer
  51788. * @param scene The scene to use the layer in
  51789. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51790. */
  51791. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51792. /**
  51793. * Get the effect name of the layer.
  51794. * @return The effect name
  51795. */
  51796. getEffectName(): string;
  51797. /**
  51798. * Create the merge effect. This is the shader use to blit the information back
  51799. * to the main canvas at the end of the scene rendering.
  51800. */
  51801. protected _createMergeEffect(): Effect;
  51802. /**
  51803. * Creates the render target textures and post processes used in the highlight layer.
  51804. */
  51805. protected _createTextureAndPostProcesses(): void;
  51806. /**
  51807. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51808. */
  51809. needStencil(): boolean;
  51810. /**
  51811. * Checks for the readiness of the element composing the layer.
  51812. * @param subMesh the mesh to check for
  51813. * @param useInstances specify wether or not to use instances to render the mesh
  51814. * @param emissiveTexture the associated emissive texture used to generate the glow
  51815. * @return true if ready otherwise, false
  51816. */
  51817. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51818. /**
  51819. * Implementation specific of rendering the generating effect on the main canvas.
  51820. * @param effect The effect used to render through
  51821. */
  51822. protected _internalRender(effect: Effect): void;
  51823. /**
  51824. * Returns true if the layer contains information to display, otherwise false.
  51825. */
  51826. shouldRender(): boolean;
  51827. /**
  51828. * Returns true if the mesh should render, otherwise false.
  51829. * @param mesh The mesh to render
  51830. * @returns true if it should render otherwise false
  51831. */
  51832. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51833. /**
  51834. * Sets the required values for both the emissive texture and and the main color.
  51835. */
  51836. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51837. /**
  51838. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51839. * @param mesh The mesh to exclude from the highlight layer
  51840. */
  51841. addExcludedMesh(mesh: Mesh): void;
  51842. /**
  51843. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51844. * @param mesh The mesh to highlight
  51845. */
  51846. removeExcludedMesh(mesh: Mesh): void;
  51847. /**
  51848. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51849. * @param mesh mesh to test
  51850. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51851. */
  51852. hasMesh(mesh: AbstractMesh): boolean;
  51853. /**
  51854. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51855. * @param mesh The mesh to highlight
  51856. * @param color The color of the highlight
  51857. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51858. */
  51859. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51860. /**
  51861. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51862. * @param mesh The mesh to highlight
  51863. */
  51864. removeMesh(mesh: Mesh): void;
  51865. /**
  51866. * Force the stencil to the normal expected value for none glowing parts
  51867. */
  51868. private _defaultStencilReference;
  51869. /**
  51870. * Free any resources and references associated to a mesh.
  51871. * Internal use
  51872. * @param mesh The mesh to free.
  51873. * @hidden
  51874. */
  51875. _disposeMesh(mesh: Mesh): void;
  51876. /**
  51877. * Dispose the highlight layer and free resources.
  51878. */
  51879. dispose(): void;
  51880. /**
  51881. * Gets the class name of the effect layer
  51882. * @returns the string with the class name of the effect layer
  51883. */
  51884. getClassName(): string;
  51885. /**
  51886. * Serializes this Highlight layer
  51887. * @returns a serialized Highlight layer object
  51888. */
  51889. serialize(): any;
  51890. /**
  51891. * Creates a Highlight layer from parsed Highlight layer data
  51892. * @param parsedHightlightLayer defines the Highlight layer data
  51893. * @param scene defines the current scene
  51894. * @param rootUrl defines the root URL containing the Highlight layer information
  51895. * @returns a parsed Highlight layer
  51896. */
  51897. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51898. }
  51899. }
  51900. declare module BABYLON {
  51901. interface AbstractScene {
  51902. /**
  51903. * The list of layers (background and foreground) of the scene
  51904. */
  51905. layers: Array<Layer>;
  51906. }
  51907. /**
  51908. * Defines the layer scene component responsible to manage any layers
  51909. * in a given scene.
  51910. */
  51911. export class LayerSceneComponent implements ISceneComponent {
  51912. /**
  51913. * The component name helpfull to identify the component in the list of scene components.
  51914. */
  51915. readonly name: string;
  51916. /**
  51917. * The scene the component belongs to.
  51918. */
  51919. scene: Scene;
  51920. private _engine;
  51921. /**
  51922. * Creates a new instance of the component for the given scene
  51923. * @param scene Defines the scene to register the component in
  51924. */
  51925. constructor(scene: Scene);
  51926. /**
  51927. * Registers the component in a given scene
  51928. */
  51929. register(): void;
  51930. /**
  51931. * Rebuilds the elements related to this component in case of
  51932. * context lost for instance.
  51933. */
  51934. rebuild(): void;
  51935. /**
  51936. * Disposes the component and the associated ressources.
  51937. */
  51938. dispose(): void;
  51939. private _draw;
  51940. private _drawCameraPredicate;
  51941. private _drawCameraBackground;
  51942. private _drawCameraForeground;
  51943. private _drawRenderTargetPredicate;
  51944. private _drawRenderTargetBackground;
  51945. private _drawRenderTargetForeground;
  51946. /**
  51947. * Adds all the elements from the container to the scene
  51948. * @param container the container holding the elements
  51949. */
  51950. addFromContainer(container: AbstractScene): void;
  51951. /**
  51952. * Removes all the elements in the container from the scene
  51953. * @param container contains the elements to remove
  51954. * @param dispose if the removed element should be disposed (default: false)
  51955. */
  51956. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51957. }
  51958. }
  51959. declare module BABYLON {
  51960. /** @hidden */
  51961. export var layerPixelShader: {
  51962. name: string;
  51963. shader: string;
  51964. };
  51965. }
  51966. declare module BABYLON {
  51967. /** @hidden */
  51968. export var layerVertexShader: {
  51969. name: string;
  51970. shader: string;
  51971. };
  51972. }
  51973. declare module BABYLON {
  51974. /**
  51975. * This represents a full screen 2d layer.
  51976. * This can be useful to display a picture in the background of your scene for instance.
  51977. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51978. */
  51979. export class Layer {
  51980. /**
  51981. * Define the name of the layer.
  51982. */
  51983. name: string;
  51984. /**
  51985. * Define the texture the layer should display.
  51986. */
  51987. texture: Nullable<Texture>;
  51988. /**
  51989. * Is the layer in background or foreground.
  51990. */
  51991. isBackground: boolean;
  51992. /**
  51993. * Define the color of the layer (instead of texture).
  51994. */
  51995. color: Color4;
  51996. /**
  51997. * Define the scale of the layer in order to zoom in out of the texture.
  51998. */
  51999. scale: Vector2;
  52000. /**
  52001. * Define an offset for the layer in order to shift the texture.
  52002. */
  52003. offset: Vector2;
  52004. /**
  52005. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52006. */
  52007. alphaBlendingMode: number;
  52008. /**
  52009. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52010. * Alpha test will not mix with the background color in case of transparency.
  52011. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52012. */
  52013. alphaTest: boolean;
  52014. /**
  52015. * Define a mask to restrict the layer to only some of the scene cameras.
  52016. */
  52017. layerMask: number;
  52018. /**
  52019. * Define the list of render target the layer is visible into.
  52020. */
  52021. renderTargetTextures: RenderTargetTexture[];
  52022. /**
  52023. * Define if the layer is only used in renderTarget or if it also
  52024. * renders in the main frame buffer of the canvas.
  52025. */
  52026. renderOnlyInRenderTargetTextures: boolean;
  52027. private _scene;
  52028. private _vertexBuffers;
  52029. private _indexBuffer;
  52030. private _effect;
  52031. private _previousDefines;
  52032. /**
  52033. * An event triggered when the layer is disposed.
  52034. */
  52035. onDisposeObservable: Observable<Layer>;
  52036. private _onDisposeObserver;
  52037. /**
  52038. * Back compatibility with callback before the onDisposeObservable existed.
  52039. * The set callback will be triggered when the layer has been disposed.
  52040. */
  52041. onDispose: () => void;
  52042. /**
  52043. * An event triggered before rendering the scene
  52044. */
  52045. onBeforeRenderObservable: Observable<Layer>;
  52046. private _onBeforeRenderObserver;
  52047. /**
  52048. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52049. * The set callback will be triggered just before rendering the layer.
  52050. */
  52051. onBeforeRender: () => void;
  52052. /**
  52053. * An event triggered after rendering the scene
  52054. */
  52055. onAfterRenderObservable: Observable<Layer>;
  52056. private _onAfterRenderObserver;
  52057. /**
  52058. * Back compatibility with callback before the onAfterRenderObservable existed.
  52059. * The set callback will be triggered just after rendering the layer.
  52060. */
  52061. onAfterRender: () => void;
  52062. /**
  52063. * Instantiates a new layer.
  52064. * This represents a full screen 2d layer.
  52065. * This can be useful to display a picture in the background of your scene for instance.
  52066. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52067. * @param name Define the name of the layer in the scene
  52068. * @param imgUrl Define the url of the texture to display in the layer
  52069. * @param scene Define the scene the layer belongs to
  52070. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52071. * @param color Defines a color for the layer
  52072. */
  52073. constructor(
  52074. /**
  52075. * Define the name of the layer.
  52076. */
  52077. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52078. private _createIndexBuffer;
  52079. /** @hidden */
  52080. _rebuild(): void;
  52081. /**
  52082. * Renders the layer in the scene.
  52083. */
  52084. render(): void;
  52085. /**
  52086. * Disposes and releases the associated ressources.
  52087. */
  52088. dispose(): void;
  52089. }
  52090. }
  52091. declare module BABYLON {
  52092. /** @hidden */
  52093. export var lensFlarePixelShader: {
  52094. name: string;
  52095. shader: string;
  52096. };
  52097. }
  52098. declare module BABYLON {
  52099. /** @hidden */
  52100. export var lensFlareVertexShader: {
  52101. name: string;
  52102. shader: string;
  52103. };
  52104. }
  52105. declare module BABYLON {
  52106. /**
  52107. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52108. * It is usually composed of several `lensFlare`.
  52109. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52110. */
  52111. export class LensFlareSystem {
  52112. /**
  52113. * Define the name of the lens flare system
  52114. */
  52115. name: string;
  52116. /**
  52117. * List of lens flares used in this system.
  52118. */
  52119. lensFlares: LensFlare[];
  52120. /**
  52121. * Define a limit from the border the lens flare can be visible.
  52122. */
  52123. borderLimit: number;
  52124. /**
  52125. * Define a viewport border we do not want to see the lens flare in.
  52126. */
  52127. viewportBorder: number;
  52128. /**
  52129. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52130. */
  52131. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52132. /**
  52133. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52134. */
  52135. layerMask: number;
  52136. /**
  52137. * Define the id of the lens flare system in the scene.
  52138. * (equal to name by default)
  52139. */
  52140. id: string;
  52141. private _scene;
  52142. private _emitter;
  52143. private _vertexBuffers;
  52144. private _indexBuffer;
  52145. private _effect;
  52146. private _positionX;
  52147. private _positionY;
  52148. private _isEnabled;
  52149. /** @hidden */
  52150. static _SceneComponentInitialization: (scene: Scene) => void;
  52151. /**
  52152. * Instantiates a lens flare system.
  52153. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52154. * It is usually composed of several `lensFlare`.
  52155. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52156. * @param name Define the name of the lens flare system in the scene
  52157. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52158. * @param scene Define the scene the lens flare system belongs to
  52159. */
  52160. constructor(
  52161. /**
  52162. * Define the name of the lens flare system
  52163. */
  52164. name: string, emitter: any, scene: Scene);
  52165. /**
  52166. * Define if the lens flare system is enabled.
  52167. */
  52168. isEnabled: boolean;
  52169. /**
  52170. * Get the scene the effects belongs to.
  52171. * @returns the scene holding the lens flare system
  52172. */
  52173. getScene(): Scene;
  52174. /**
  52175. * Get the emitter of the lens flare system.
  52176. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52177. * @returns the emitter of the lens flare system
  52178. */
  52179. getEmitter(): any;
  52180. /**
  52181. * Set the emitter of the lens flare system.
  52182. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52183. * @param newEmitter Define the new emitter of the system
  52184. */
  52185. setEmitter(newEmitter: any): void;
  52186. /**
  52187. * Get the lens flare system emitter position.
  52188. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52189. * @returns the position
  52190. */
  52191. getEmitterPosition(): Vector3;
  52192. /**
  52193. * @hidden
  52194. */
  52195. computeEffectivePosition(globalViewport: Viewport): boolean;
  52196. /** @hidden */
  52197. _isVisible(): boolean;
  52198. /**
  52199. * @hidden
  52200. */
  52201. render(): boolean;
  52202. /**
  52203. * Dispose and release the lens flare with its associated resources.
  52204. */
  52205. dispose(): void;
  52206. /**
  52207. * Parse a lens flare system from a JSON repressentation
  52208. * @param parsedLensFlareSystem Define the JSON to parse
  52209. * @param scene Define the scene the parsed system should be instantiated in
  52210. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52211. * @returns the parsed system
  52212. */
  52213. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52214. /**
  52215. * Serialize the current Lens Flare System into a JSON representation.
  52216. * @returns the serialized JSON
  52217. */
  52218. serialize(): any;
  52219. }
  52220. }
  52221. declare module BABYLON {
  52222. /**
  52223. * This represents one of the lens effect in a `lensFlareSystem`.
  52224. * It controls one of the indiviual texture used in the effect.
  52225. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52226. */
  52227. export class LensFlare {
  52228. /**
  52229. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52230. */
  52231. size: number;
  52232. /**
  52233. * 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.
  52234. */
  52235. position: number;
  52236. /**
  52237. * Define the lens color.
  52238. */
  52239. color: Color3;
  52240. /**
  52241. * Define the lens texture.
  52242. */
  52243. texture: Nullable<Texture>;
  52244. /**
  52245. * Define the alpha mode to render this particular lens.
  52246. */
  52247. alphaMode: number;
  52248. private _system;
  52249. /**
  52250. * Creates a new Lens Flare.
  52251. * This represents one of the lens effect in a `lensFlareSystem`.
  52252. * It controls one of the indiviual texture used in the effect.
  52253. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52254. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52255. * @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.
  52256. * @param color Define the lens color
  52257. * @param imgUrl Define the lens texture url
  52258. * @param system Define the `lensFlareSystem` this flare is part of
  52259. * @returns The newly created Lens Flare
  52260. */
  52261. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52262. /**
  52263. * Instantiates a new Lens Flare.
  52264. * This represents one of the lens effect in a `lensFlareSystem`.
  52265. * It controls one of the indiviual texture used in the effect.
  52266. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52267. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52268. * @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.
  52269. * @param color Define the lens color
  52270. * @param imgUrl Define the lens texture url
  52271. * @param system Define the `lensFlareSystem` this flare is part of
  52272. */
  52273. constructor(
  52274. /**
  52275. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52276. */
  52277. size: number,
  52278. /**
  52279. * 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.
  52280. */
  52281. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52282. /**
  52283. * Dispose and release the lens flare with its associated resources.
  52284. */
  52285. dispose(): void;
  52286. }
  52287. }
  52288. declare module BABYLON {
  52289. interface AbstractScene {
  52290. /**
  52291. * The list of lens flare system added to the scene
  52292. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52293. */
  52294. lensFlareSystems: Array<LensFlareSystem>;
  52295. /**
  52296. * Removes the given lens flare system from this scene.
  52297. * @param toRemove The lens flare system to remove
  52298. * @returns The index of the removed lens flare system
  52299. */
  52300. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52301. /**
  52302. * Adds the given lens flare system to this scene
  52303. * @param newLensFlareSystem The lens flare system to add
  52304. */
  52305. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52306. /**
  52307. * Gets a lens flare system using its name
  52308. * @param name defines the name to look for
  52309. * @returns the lens flare system or null if not found
  52310. */
  52311. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52312. /**
  52313. * Gets a lens flare system using its id
  52314. * @param id defines the id to look for
  52315. * @returns the lens flare system or null if not found
  52316. */
  52317. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52318. }
  52319. /**
  52320. * Defines the lens flare scene component responsible to manage any lens flares
  52321. * in a given scene.
  52322. */
  52323. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52324. /**
  52325. * The component name helpfull to identify the component in the list of scene components.
  52326. */
  52327. readonly name: string;
  52328. /**
  52329. * The scene the component belongs to.
  52330. */
  52331. scene: Scene;
  52332. /**
  52333. * Creates a new instance of the component for the given scene
  52334. * @param scene Defines the scene to register the component in
  52335. */
  52336. constructor(scene: Scene);
  52337. /**
  52338. * Registers the component in a given scene
  52339. */
  52340. register(): void;
  52341. /**
  52342. * Rebuilds the elements related to this component in case of
  52343. * context lost for instance.
  52344. */
  52345. rebuild(): void;
  52346. /**
  52347. * Adds all the elements from the container to the scene
  52348. * @param container the container holding the elements
  52349. */
  52350. addFromContainer(container: AbstractScene): void;
  52351. /**
  52352. * Removes all the elements in the container from the scene
  52353. * @param container contains the elements to remove
  52354. * @param dispose if the removed element should be disposed (default: false)
  52355. */
  52356. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52357. /**
  52358. * Serializes the component data to the specified json object
  52359. * @param serializationObject The object to serialize to
  52360. */
  52361. serialize(serializationObject: any): void;
  52362. /**
  52363. * Disposes the component and the associated ressources.
  52364. */
  52365. dispose(): void;
  52366. private _draw;
  52367. }
  52368. }
  52369. declare module BABYLON {
  52370. /**
  52371. * Defines the shadow generator component responsible to manage any shadow generators
  52372. * in a given scene.
  52373. */
  52374. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52375. /**
  52376. * The component name helpfull to identify the component in the list of scene components.
  52377. */
  52378. readonly name: string;
  52379. /**
  52380. * The scene the component belongs to.
  52381. */
  52382. scene: Scene;
  52383. /**
  52384. * Creates a new instance of the component for the given scene
  52385. * @param scene Defines the scene to register the component in
  52386. */
  52387. constructor(scene: Scene);
  52388. /**
  52389. * Registers the component in a given scene
  52390. */
  52391. register(): void;
  52392. /**
  52393. * Rebuilds the elements related to this component in case of
  52394. * context lost for instance.
  52395. */
  52396. rebuild(): void;
  52397. /**
  52398. * Serializes the component data to the specified json object
  52399. * @param serializationObject The object to serialize to
  52400. */
  52401. serialize(serializationObject: any): void;
  52402. /**
  52403. * Adds all the elements from the container to the scene
  52404. * @param container the container holding the elements
  52405. */
  52406. addFromContainer(container: AbstractScene): void;
  52407. /**
  52408. * Removes all the elements in the container from the scene
  52409. * @param container contains the elements to remove
  52410. * @param dispose if the removed element should be disposed (default: false)
  52411. */
  52412. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52413. /**
  52414. * Rebuilds the elements related to this component in case of
  52415. * context lost for instance.
  52416. */
  52417. dispose(): void;
  52418. private _gatherRenderTargets;
  52419. }
  52420. }
  52421. declare module BABYLON {
  52422. /**
  52423. * A point light is a light defined by an unique point in world space.
  52424. * The light is emitted in every direction from this point.
  52425. * A good example of a point light is a standard light bulb.
  52426. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52427. */
  52428. export class PointLight extends ShadowLight {
  52429. private _shadowAngle;
  52430. /**
  52431. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52432. * This specifies what angle the shadow will use to be created.
  52433. *
  52434. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52435. */
  52436. /**
  52437. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52438. * This specifies what angle the shadow will use to be created.
  52439. *
  52440. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52441. */
  52442. shadowAngle: number;
  52443. /**
  52444. * Gets the direction if it has been set.
  52445. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52446. */
  52447. /**
  52448. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52449. */
  52450. direction: Vector3;
  52451. /**
  52452. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52453. * A PointLight emits the light in every direction.
  52454. * It can cast shadows.
  52455. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52456. * ```javascript
  52457. * var pointLight = new PointLight("pl", camera.position, scene);
  52458. * ```
  52459. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52460. * @param name The light friendly name
  52461. * @param position The position of the point light in the scene
  52462. * @param scene The scene the lights belongs to
  52463. */
  52464. constructor(name: string, position: Vector3, scene: Scene);
  52465. /**
  52466. * Returns the string "PointLight"
  52467. * @returns the class name
  52468. */
  52469. getClassName(): string;
  52470. /**
  52471. * Returns the integer 0.
  52472. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52473. */
  52474. getTypeID(): number;
  52475. /**
  52476. * Specifies wether or not the shadowmap should be a cube texture.
  52477. * @returns true if the shadowmap needs to be a cube texture.
  52478. */
  52479. needCube(): boolean;
  52480. /**
  52481. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52482. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52483. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52484. */
  52485. getShadowDirection(faceIndex?: number): Vector3;
  52486. /**
  52487. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52488. * - fov = PI / 2
  52489. * - aspect ratio : 1.0
  52490. * - z-near and far equal to the active camera minZ and maxZ.
  52491. * Returns the PointLight.
  52492. */
  52493. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52494. protected _buildUniformLayout(): void;
  52495. /**
  52496. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52497. * @param effect The effect to update
  52498. * @param lightIndex The index of the light in the effect to update
  52499. * @returns The point light
  52500. */
  52501. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52502. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52503. /**
  52504. * Prepares the list of defines specific to the light type.
  52505. * @param defines the list of defines
  52506. * @param lightIndex defines the index of the light for the effect
  52507. */
  52508. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52509. }
  52510. }
  52511. declare module BABYLON {
  52512. /**
  52513. * Header information of HDR texture files.
  52514. */
  52515. export interface HDRInfo {
  52516. /**
  52517. * The height of the texture in pixels.
  52518. */
  52519. height: number;
  52520. /**
  52521. * The width of the texture in pixels.
  52522. */
  52523. width: number;
  52524. /**
  52525. * The index of the beginning of the data in the binary file.
  52526. */
  52527. dataPosition: number;
  52528. }
  52529. /**
  52530. * This groups tools to convert HDR texture to native colors array.
  52531. */
  52532. export class HDRTools {
  52533. private static Ldexp;
  52534. private static Rgbe2float;
  52535. private static readStringLine;
  52536. /**
  52537. * Reads header information from an RGBE texture stored in a native array.
  52538. * More information on this format are available here:
  52539. * https://en.wikipedia.org/wiki/RGBE_image_format
  52540. *
  52541. * @param uint8array The binary file stored in native array.
  52542. * @return The header information.
  52543. */
  52544. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52545. /**
  52546. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52547. * This RGBE texture needs to store the information as a panorama.
  52548. *
  52549. * More information on this format are available here:
  52550. * https://en.wikipedia.org/wiki/RGBE_image_format
  52551. *
  52552. * @param buffer The binary file stored in an array buffer.
  52553. * @param size The expected size of the extracted cubemap.
  52554. * @return The Cube Map information.
  52555. */
  52556. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52557. /**
  52558. * Returns the pixels data extracted from an RGBE texture.
  52559. * This pixels will be stored left to right up to down in the R G B order in one array.
  52560. *
  52561. * More information on this format are available here:
  52562. * https://en.wikipedia.org/wiki/RGBE_image_format
  52563. *
  52564. * @param uint8array The binary file stored in an array buffer.
  52565. * @param hdrInfo The header information of the file.
  52566. * @return The pixels data in RGB right to left up to down order.
  52567. */
  52568. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52569. private static RGBE_ReadPixels_RLE;
  52570. }
  52571. }
  52572. declare module BABYLON {
  52573. /**
  52574. * This represents a texture coming from an HDR input.
  52575. *
  52576. * The only supported format is currently panorama picture stored in RGBE format.
  52577. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52578. */
  52579. export class HDRCubeTexture extends BaseTexture {
  52580. private static _facesMapping;
  52581. private _generateHarmonics;
  52582. private _noMipmap;
  52583. private _textureMatrix;
  52584. private _size;
  52585. private _onLoad;
  52586. private _onError;
  52587. /**
  52588. * The texture URL.
  52589. */
  52590. url: string;
  52591. /**
  52592. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52593. */
  52594. coordinatesMode: number;
  52595. protected _isBlocking: boolean;
  52596. /**
  52597. * Sets wether or not the texture is blocking during loading.
  52598. */
  52599. /**
  52600. * Gets wether or not the texture is blocking during loading.
  52601. */
  52602. isBlocking: boolean;
  52603. protected _rotationY: number;
  52604. /**
  52605. * Sets texture matrix rotation angle around Y axis in radians.
  52606. */
  52607. /**
  52608. * Gets texture matrix rotation angle around Y axis radians.
  52609. */
  52610. rotationY: number;
  52611. /**
  52612. * Gets or sets the center of the bounding box associated with the cube texture
  52613. * It must define where the camera used to render the texture was set
  52614. */
  52615. boundingBoxPosition: Vector3;
  52616. private _boundingBoxSize;
  52617. /**
  52618. * Gets or sets the size of the bounding box associated with the cube texture
  52619. * When defined, the cubemap will switch to local mode
  52620. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52621. * @example https://www.babylonjs-playground.com/#RNASML
  52622. */
  52623. boundingBoxSize: Vector3;
  52624. /**
  52625. * Instantiates an HDRTexture from the following parameters.
  52626. *
  52627. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52628. * @param scene The scene the texture will be used in
  52629. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52630. * @param noMipmap Forces to not generate the mipmap if true
  52631. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52632. * @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)
  52633. * @param reserved Reserved flag for internal use.
  52634. */
  52635. 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>);
  52636. /**
  52637. * Get the current class name of the texture useful for serialization or dynamic coding.
  52638. * @returns "HDRCubeTexture"
  52639. */
  52640. getClassName(): string;
  52641. /**
  52642. * Occurs when the file is raw .hdr file.
  52643. */
  52644. private loadTexture;
  52645. clone(): HDRCubeTexture;
  52646. delayLoad(): void;
  52647. /**
  52648. * Get the texture reflection matrix used to rotate/transform the reflection.
  52649. * @returns the reflection matrix
  52650. */
  52651. getReflectionTextureMatrix(): Matrix;
  52652. /**
  52653. * Set the texture reflection matrix used to rotate/transform the reflection.
  52654. * @param value Define the reflection matrix to set
  52655. */
  52656. setReflectionTextureMatrix(value: Matrix): void;
  52657. /**
  52658. * Parses a JSON representation of an HDR Texture in order to create the texture
  52659. * @param parsedTexture Define the JSON representation
  52660. * @param scene Define the scene the texture should be created in
  52661. * @param rootUrl Define the root url in case we need to load relative dependencies
  52662. * @returns the newly created texture after parsing
  52663. */
  52664. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52665. serialize(): any;
  52666. }
  52667. }
  52668. declare module BABYLON {
  52669. /**
  52670. * Class used to control physics engine
  52671. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52672. */
  52673. export class PhysicsEngine implements IPhysicsEngine {
  52674. private _physicsPlugin;
  52675. /**
  52676. * Global value used to control the smallest number supported by the simulation
  52677. */
  52678. static Epsilon: number;
  52679. private _impostors;
  52680. private _joints;
  52681. private _subTimeStep;
  52682. /**
  52683. * Gets the gravity vector used by the simulation
  52684. */
  52685. gravity: Vector3;
  52686. /**
  52687. * Factory used to create the default physics plugin.
  52688. * @returns The default physics plugin
  52689. */
  52690. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52691. /**
  52692. * Creates a new Physics Engine
  52693. * @param gravity defines the gravity vector used by the simulation
  52694. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52695. */
  52696. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52697. /**
  52698. * Sets the gravity vector used by the simulation
  52699. * @param gravity defines the gravity vector to use
  52700. */
  52701. setGravity(gravity: Vector3): void;
  52702. /**
  52703. * Set the time step of the physics engine.
  52704. * Default is 1/60.
  52705. * To slow it down, enter 1/600 for example.
  52706. * To speed it up, 1/30
  52707. * @param newTimeStep defines the new timestep to apply to this world.
  52708. */
  52709. setTimeStep(newTimeStep?: number): void;
  52710. /**
  52711. * Get the time step of the physics engine.
  52712. * @returns the current time step
  52713. */
  52714. getTimeStep(): number;
  52715. /**
  52716. * Set the sub time step of the physics engine.
  52717. * Default is 0 meaning there is no sub steps
  52718. * To increase physics resolution precision, set a small value (like 1 ms)
  52719. * @param subTimeStep defines the new sub timestep used for physics resolution.
  52720. */
  52721. setSubTimeStep(subTimeStep?: number): void;
  52722. /**
  52723. * Get the sub time step of the physics engine.
  52724. * @returns the current sub time step
  52725. */
  52726. getSubTimeStep(): number;
  52727. /**
  52728. * Release all resources
  52729. */
  52730. dispose(): void;
  52731. /**
  52732. * Gets the name of the current physics plugin
  52733. * @returns the name of the plugin
  52734. */
  52735. getPhysicsPluginName(): string;
  52736. /**
  52737. * Adding a new impostor for the impostor tracking.
  52738. * This will be done by the impostor itself.
  52739. * @param impostor the impostor to add
  52740. */
  52741. addImpostor(impostor: PhysicsImpostor): void;
  52742. /**
  52743. * Remove an impostor from the engine.
  52744. * This impostor and its mesh will not longer be updated by the physics engine.
  52745. * @param impostor the impostor to remove
  52746. */
  52747. removeImpostor(impostor: PhysicsImpostor): void;
  52748. /**
  52749. * Add a joint to the physics engine
  52750. * @param mainImpostor defines the main impostor to which the joint is added.
  52751. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52752. * @param joint defines the joint that will connect both impostors.
  52753. */
  52754. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52755. /**
  52756. * Removes a joint from the simulation
  52757. * @param mainImpostor defines the impostor used with the joint
  52758. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52759. * @param joint defines the joint to remove
  52760. */
  52761. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52762. /**
  52763. * Called by the scene. No need to call it.
  52764. * @param delta defines the timespam between frames
  52765. */
  52766. _step(delta: number): void;
  52767. /**
  52768. * Gets the current plugin used to run the simulation
  52769. * @returns current plugin
  52770. */
  52771. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52772. /**
  52773. * Gets the list of physic impostors
  52774. * @returns an array of PhysicsImpostor
  52775. */
  52776. getImpostors(): Array<PhysicsImpostor>;
  52777. /**
  52778. * Gets the impostor for a physics enabled object
  52779. * @param object defines the object impersonated by the impostor
  52780. * @returns the PhysicsImpostor or null if not found
  52781. */
  52782. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52783. /**
  52784. * Gets the impostor for a physics body object
  52785. * @param body defines physics body used by the impostor
  52786. * @returns the PhysicsImpostor or null if not found
  52787. */
  52788. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52789. /**
  52790. * Does a raycast in the physics world
  52791. * @param from when should the ray start?
  52792. * @param to when should the ray end?
  52793. * @returns PhysicsRaycastResult
  52794. */
  52795. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52796. }
  52797. }
  52798. declare module BABYLON {
  52799. /** @hidden */
  52800. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52801. private _useDeltaForWorldStep;
  52802. world: any;
  52803. name: string;
  52804. private _physicsMaterials;
  52805. private _fixedTimeStep;
  52806. private _cannonRaycastResult;
  52807. private _raycastResult;
  52808. private _physicsBodysToRemoveAfterStep;
  52809. BJSCANNON: any;
  52810. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52811. setGravity(gravity: Vector3): void;
  52812. setTimeStep(timeStep: number): void;
  52813. getTimeStep(): number;
  52814. executeStep(delta: number): void;
  52815. private _removeMarkedPhysicsBodiesFromWorld;
  52816. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52817. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52818. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52819. private _processChildMeshes;
  52820. removePhysicsBody(impostor: PhysicsImpostor): void;
  52821. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52822. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52823. private _addMaterial;
  52824. private _checkWithEpsilon;
  52825. private _createShape;
  52826. private _createHeightmap;
  52827. private _minus90X;
  52828. private _plus90X;
  52829. private _tmpPosition;
  52830. private _tmpDeltaPosition;
  52831. private _tmpUnityRotation;
  52832. private _updatePhysicsBodyTransformation;
  52833. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52834. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52835. isSupported(): boolean;
  52836. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52837. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52838. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52839. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52840. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52841. getBodyMass(impostor: PhysicsImpostor): number;
  52842. getBodyFriction(impostor: PhysicsImpostor): number;
  52843. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52844. getBodyRestitution(impostor: PhysicsImpostor): number;
  52845. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52846. sleepBody(impostor: PhysicsImpostor): void;
  52847. wakeUpBody(impostor: PhysicsImpostor): void;
  52848. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52849. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52850. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52851. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52852. getRadius(impostor: PhysicsImpostor): number;
  52853. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52854. dispose(): void;
  52855. private _extendNamespace;
  52856. /**
  52857. * Does a raycast in the physics world
  52858. * @param from when should the ray start?
  52859. * @param to when should the ray end?
  52860. * @returns PhysicsRaycastResult
  52861. */
  52862. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52863. }
  52864. }
  52865. declare module BABYLON {
  52866. /** @hidden */
  52867. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52868. world: any;
  52869. name: string;
  52870. BJSOIMO: any;
  52871. private _raycastResult;
  52872. constructor(iterations?: number, oimoInjection?: any);
  52873. setGravity(gravity: Vector3): void;
  52874. setTimeStep(timeStep: number): void;
  52875. getTimeStep(): number;
  52876. private _tmpImpostorsArray;
  52877. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52878. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52879. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52880. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52881. private _tmpPositionVector;
  52882. removePhysicsBody(impostor: PhysicsImpostor): void;
  52883. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52884. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52885. isSupported(): boolean;
  52886. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52887. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52888. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52889. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52890. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52891. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52892. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52893. getBodyMass(impostor: PhysicsImpostor): number;
  52894. getBodyFriction(impostor: PhysicsImpostor): number;
  52895. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52896. getBodyRestitution(impostor: PhysicsImpostor): number;
  52897. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52898. sleepBody(impostor: PhysicsImpostor): void;
  52899. wakeUpBody(impostor: PhysicsImpostor): void;
  52900. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52901. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52902. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52903. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52904. getRadius(impostor: PhysicsImpostor): number;
  52905. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52906. dispose(): void;
  52907. /**
  52908. * Does a raycast in the physics world
  52909. * @param from when should the ray start?
  52910. * @param to when should the ray end?
  52911. * @returns PhysicsRaycastResult
  52912. */
  52913. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52914. }
  52915. }
  52916. declare module BABYLON {
  52917. /**
  52918. * Class containing static functions to help procedurally build meshes
  52919. */
  52920. export class RibbonBuilder {
  52921. /**
  52922. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52923. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52924. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52925. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52926. * * 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
  52927. * * 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
  52928. * * 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
  52929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52930. * * 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
  52931. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52932. * * 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
  52933. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52934. * * 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
  52935. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52937. * @param name defines the name of the mesh
  52938. * @param options defines the options used to create the mesh
  52939. * @param scene defines the hosting scene
  52940. * @returns the ribbon mesh
  52941. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52942. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52943. */
  52944. static CreateRibbon(name: string, options: {
  52945. pathArray: Vector3[][];
  52946. closeArray?: boolean;
  52947. closePath?: boolean;
  52948. offset?: number;
  52949. updatable?: boolean;
  52950. sideOrientation?: number;
  52951. frontUVs?: Vector4;
  52952. backUVs?: Vector4;
  52953. instance?: Mesh;
  52954. invertUV?: boolean;
  52955. uvs?: Vector2[];
  52956. colors?: Color4[];
  52957. }, scene?: Nullable<Scene>): Mesh;
  52958. }
  52959. }
  52960. declare module BABYLON {
  52961. /**
  52962. * Class containing static functions to help procedurally build meshes
  52963. */
  52964. export class ShapeBuilder {
  52965. /**
  52966. * 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.
  52967. * * 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.
  52968. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52969. * * 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.
  52970. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52971. * * 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
  52972. * * 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
  52973. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52975. * * 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
  52976. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52978. * @param name defines the name of the mesh
  52979. * @param options defines the options used to create the mesh
  52980. * @param scene defines the hosting scene
  52981. * @returns the extruded shape mesh
  52982. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52983. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52984. */
  52985. static ExtrudeShape(name: string, options: {
  52986. shape: Vector3[];
  52987. path: Vector3[];
  52988. scale?: number;
  52989. rotation?: number;
  52990. cap?: number;
  52991. updatable?: boolean;
  52992. sideOrientation?: number;
  52993. frontUVs?: Vector4;
  52994. backUVs?: Vector4;
  52995. instance?: Mesh;
  52996. invertUV?: boolean;
  52997. }, scene?: Nullable<Scene>): Mesh;
  52998. /**
  52999. * Creates an custom extruded shape mesh.
  53000. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53001. * * 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.
  53002. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53003. * * 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
  53004. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53005. * * 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
  53006. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53007. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53008. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53009. * * 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
  53010. * * 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
  53011. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53013. * * 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
  53014. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53016. * @param name defines the name of the mesh
  53017. * @param options defines the options used to create the mesh
  53018. * @param scene defines the hosting scene
  53019. * @returns the custom extruded shape mesh
  53020. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53021. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53023. */
  53024. static ExtrudeShapeCustom(name: string, options: {
  53025. shape: Vector3[];
  53026. path: Vector3[];
  53027. scaleFunction?: any;
  53028. rotationFunction?: any;
  53029. ribbonCloseArray?: boolean;
  53030. ribbonClosePath?: boolean;
  53031. cap?: number;
  53032. updatable?: boolean;
  53033. sideOrientation?: number;
  53034. frontUVs?: Vector4;
  53035. backUVs?: Vector4;
  53036. instance?: Mesh;
  53037. invertUV?: boolean;
  53038. }, scene?: Nullable<Scene>): Mesh;
  53039. private static _ExtrudeShapeGeneric;
  53040. }
  53041. }
  53042. declare module BABYLON {
  53043. /**
  53044. * AmmoJS Physics plugin
  53045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53046. * @see https://github.com/kripken/ammo.js/
  53047. */
  53048. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53049. private _useDeltaForWorldStep;
  53050. /**
  53051. * Reference to the Ammo library
  53052. */
  53053. bjsAMMO: any;
  53054. /**
  53055. * Created ammoJS world which physics bodies are added to
  53056. */
  53057. world: any;
  53058. /**
  53059. * Name of the plugin
  53060. */
  53061. name: string;
  53062. private _timeStep;
  53063. private _fixedTimeStep;
  53064. private _maxSteps;
  53065. private _tmpQuaternion;
  53066. private _tmpAmmoTransform;
  53067. private _tmpAmmoQuaternion;
  53068. private _tmpAmmoConcreteContactResultCallback;
  53069. private _collisionConfiguration;
  53070. private _dispatcher;
  53071. private _overlappingPairCache;
  53072. private _solver;
  53073. private _softBodySolver;
  53074. private _tmpAmmoVectorA;
  53075. private _tmpAmmoVectorB;
  53076. private _tmpAmmoVectorC;
  53077. private _tmpAmmoVectorD;
  53078. private _tmpContactCallbackResult;
  53079. private _tmpAmmoVectorRCA;
  53080. private _tmpAmmoVectorRCB;
  53081. private _raycastResult;
  53082. private static readonly DISABLE_COLLISION_FLAG;
  53083. private static readonly KINEMATIC_FLAG;
  53084. private static readonly DISABLE_DEACTIVATION_FLAG;
  53085. /**
  53086. * Initializes the ammoJS plugin
  53087. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53088. * @param ammoInjection can be used to inject your own ammo reference
  53089. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53090. */
  53091. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53092. /**
  53093. * Sets the gravity of the physics world (m/(s^2))
  53094. * @param gravity Gravity to set
  53095. */
  53096. setGravity(gravity: Vector3): void;
  53097. /**
  53098. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53099. * @param timeStep timestep to use in seconds
  53100. */
  53101. setTimeStep(timeStep: number): void;
  53102. /**
  53103. * 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)
  53104. * @param fixedTimeStep fixedTimeStep to use in seconds
  53105. */
  53106. setFixedTimeStep(fixedTimeStep: number): void;
  53107. /**
  53108. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53109. * @param maxSteps the maximum number of steps by the physics engine per frame
  53110. */
  53111. setMaxSteps(maxSteps: number): void;
  53112. /**
  53113. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53114. * @returns the current timestep in seconds
  53115. */
  53116. getTimeStep(): number;
  53117. /**
  53118. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  53119. */
  53120. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  53121. private _isImpostorInContact;
  53122. private _isImpostorPairInContact;
  53123. private _stepSimulation;
  53124. /**
  53125. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53126. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53127. * After the step the babylon meshes are set to the position of the physics imposters
  53128. * @param delta amount of time to step forward
  53129. * @param impostors array of imposters to update before/after the step
  53130. */
  53131. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53132. /**
  53133. * Update babylon mesh to match physics world object
  53134. * @param impostor imposter to match
  53135. */
  53136. private _afterSoftStep;
  53137. /**
  53138. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53139. * @param impostor imposter to match
  53140. */
  53141. private _ropeStep;
  53142. /**
  53143. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53144. * @param impostor imposter to match
  53145. */
  53146. private _softbodyOrClothStep;
  53147. private _tmpVector;
  53148. private _tmpMatrix;
  53149. /**
  53150. * Applies an impulse on the imposter
  53151. * @param impostor imposter to apply impulse to
  53152. * @param force amount of force to be applied to the imposter
  53153. * @param contactPoint the location to apply the impulse on the imposter
  53154. */
  53155. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53156. /**
  53157. * Applies a force on the imposter
  53158. * @param impostor imposter to apply force
  53159. * @param force amount of force to be applied to the imposter
  53160. * @param contactPoint the location to apply the force on the imposter
  53161. */
  53162. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53163. /**
  53164. * Creates a physics body using the plugin
  53165. * @param impostor the imposter to create the physics body on
  53166. */
  53167. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53168. /**
  53169. * Removes the physics body from the imposter and disposes of the body's memory
  53170. * @param impostor imposter to remove the physics body from
  53171. */
  53172. removePhysicsBody(impostor: PhysicsImpostor): void;
  53173. /**
  53174. * Generates a joint
  53175. * @param impostorJoint the imposter joint to create the joint with
  53176. */
  53177. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53178. /**
  53179. * Removes a joint
  53180. * @param impostorJoint the imposter joint to remove the joint from
  53181. */
  53182. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53183. private _addMeshVerts;
  53184. /**
  53185. * Initialise the soft body vertices to match its object's (mesh) vertices
  53186. * Softbody vertices (nodes) are in world space and to match this
  53187. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53188. * @param impostor to create the softbody for
  53189. */
  53190. private _softVertexData;
  53191. /**
  53192. * Create an impostor's soft body
  53193. * @param impostor to create the softbody for
  53194. */
  53195. private _createSoftbody;
  53196. /**
  53197. * Create cloth for an impostor
  53198. * @param impostor to create the softbody for
  53199. */
  53200. private _createCloth;
  53201. /**
  53202. * Create rope for an impostor
  53203. * @param impostor to create the softbody for
  53204. */
  53205. private _createRope;
  53206. /**
  53207. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  53208. * @param impostor to create the custom physics shape for
  53209. */
  53210. private _createCustom;
  53211. private _addHullVerts;
  53212. private _createShape;
  53213. /**
  53214. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53215. * @param impostor imposter containing the physics body and babylon object
  53216. */
  53217. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53218. /**
  53219. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53220. * @param impostor imposter containing the physics body and babylon object
  53221. * @param newPosition new position
  53222. * @param newRotation new rotation
  53223. */
  53224. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53225. /**
  53226. * If this plugin is supported
  53227. * @returns true if its supported
  53228. */
  53229. isSupported(): boolean;
  53230. /**
  53231. * Sets the linear velocity of the physics body
  53232. * @param impostor imposter to set the velocity on
  53233. * @param velocity velocity to set
  53234. */
  53235. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53236. /**
  53237. * Sets the angular velocity of the physics body
  53238. * @param impostor imposter to set the velocity on
  53239. * @param velocity velocity to set
  53240. */
  53241. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53242. /**
  53243. * gets the linear velocity
  53244. * @param impostor imposter to get linear velocity from
  53245. * @returns linear velocity
  53246. */
  53247. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53248. /**
  53249. * gets the angular velocity
  53250. * @param impostor imposter to get angular velocity from
  53251. * @returns angular velocity
  53252. */
  53253. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53254. /**
  53255. * Sets the mass of physics body
  53256. * @param impostor imposter to set the mass on
  53257. * @param mass mass to set
  53258. */
  53259. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53260. /**
  53261. * Gets the mass of the physics body
  53262. * @param impostor imposter to get the mass from
  53263. * @returns mass
  53264. */
  53265. getBodyMass(impostor: PhysicsImpostor): number;
  53266. /**
  53267. * Gets friction of the impostor
  53268. * @param impostor impostor to get friction from
  53269. * @returns friction value
  53270. */
  53271. getBodyFriction(impostor: PhysicsImpostor): number;
  53272. /**
  53273. * Sets friction of the impostor
  53274. * @param impostor impostor to set friction on
  53275. * @param friction friction value
  53276. */
  53277. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53278. /**
  53279. * Gets restitution of the impostor
  53280. * @param impostor impostor to get restitution from
  53281. * @returns restitution value
  53282. */
  53283. getBodyRestitution(impostor: PhysicsImpostor): number;
  53284. /**
  53285. * Sets resitution of the impostor
  53286. * @param impostor impostor to set resitution on
  53287. * @param restitution resitution value
  53288. */
  53289. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53290. /**
  53291. * Gets pressure inside the impostor
  53292. * @param impostor impostor to get pressure from
  53293. * @returns pressure value
  53294. */
  53295. getBodyPressure(impostor: PhysicsImpostor): number;
  53296. /**
  53297. * Sets pressure inside a soft body impostor
  53298. * Cloth and rope must remain 0 pressure
  53299. * @param impostor impostor to set pressure on
  53300. * @param pressure pressure value
  53301. */
  53302. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53303. /**
  53304. * Gets stiffness of the impostor
  53305. * @param impostor impostor to get stiffness from
  53306. * @returns pressure value
  53307. */
  53308. getBodyStiffness(impostor: PhysicsImpostor): number;
  53309. /**
  53310. * Sets stiffness of the impostor
  53311. * @param impostor impostor to set stiffness on
  53312. * @param stiffness stiffness value from 0 to 1
  53313. */
  53314. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53315. /**
  53316. * Gets velocityIterations of the impostor
  53317. * @param impostor impostor to get velocity iterations from
  53318. * @returns velocityIterations value
  53319. */
  53320. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53321. /**
  53322. * Sets velocityIterations of the impostor
  53323. * @param impostor impostor to set velocity iterations on
  53324. * @param velocityIterations velocityIterations value
  53325. */
  53326. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53327. /**
  53328. * Gets positionIterations of the impostor
  53329. * @param impostor impostor to get position iterations from
  53330. * @returns positionIterations value
  53331. */
  53332. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53333. /**
  53334. * Sets positionIterations of the impostor
  53335. * @param impostor impostor to set position on
  53336. * @param positionIterations positionIterations value
  53337. */
  53338. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53339. /**
  53340. * Append an anchor to a cloth object
  53341. * @param impostor is the cloth impostor to add anchor to
  53342. * @param otherImpostor is the rigid impostor to anchor to
  53343. * @param width ratio across width from 0 to 1
  53344. * @param height ratio up height from 0 to 1
  53345. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53346. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53347. */
  53348. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53349. /**
  53350. * Append an hook to a rope object
  53351. * @param impostor is the rope impostor to add hook to
  53352. * @param otherImpostor is the rigid impostor to hook to
  53353. * @param length ratio along the rope from 0 to 1
  53354. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53355. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53356. */
  53357. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53358. /**
  53359. * Sleeps the physics body and stops it from being active
  53360. * @param impostor impostor to sleep
  53361. */
  53362. sleepBody(impostor: PhysicsImpostor): void;
  53363. /**
  53364. * Activates the physics body
  53365. * @param impostor impostor to activate
  53366. */
  53367. wakeUpBody(impostor: PhysicsImpostor): void;
  53368. /**
  53369. * Updates the distance parameters of the joint
  53370. * @param joint joint to update
  53371. * @param maxDistance maximum distance of the joint
  53372. * @param minDistance minimum distance of the joint
  53373. */
  53374. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53375. /**
  53376. * Sets a motor on the joint
  53377. * @param joint joint to set motor on
  53378. * @param speed speed of the motor
  53379. * @param maxForce maximum force of the motor
  53380. * @param motorIndex index of the motor
  53381. */
  53382. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53383. /**
  53384. * Sets the motors limit
  53385. * @param joint joint to set limit on
  53386. * @param upperLimit upper limit
  53387. * @param lowerLimit lower limit
  53388. */
  53389. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53390. /**
  53391. * Syncs the position and rotation of a mesh with the impostor
  53392. * @param mesh mesh to sync
  53393. * @param impostor impostor to update the mesh with
  53394. */
  53395. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53396. /**
  53397. * Gets the radius of the impostor
  53398. * @param impostor impostor to get radius from
  53399. * @returns the radius
  53400. */
  53401. getRadius(impostor: PhysicsImpostor): number;
  53402. /**
  53403. * Gets the box size of the impostor
  53404. * @param impostor impostor to get box size from
  53405. * @param result the resulting box size
  53406. */
  53407. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53408. /**
  53409. * Disposes of the impostor
  53410. */
  53411. dispose(): void;
  53412. /**
  53413. * Does a raycast in the physics world
  53414. * @param from when should the ray start?
  53415. * @param to when should the ray end?
  53416. * @returns PhysicsRaycastResult
  53417. */
  53418. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53419. }
  53420. }
  53421. declare module BABYLON {
  53422. interface AbstractScene {
  53423. /**
  53424. * The list of reflection probes added to the scene
  53425. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53426. */
  53427. reflectionProbes: Array<ReflectionProbe>;
  53428. /**
  53429. * Removes the given reflection probe from this scene.
  53430. * @param toRemove The reflection probe to remove
  53431. * @returns The index of the removed reflection probe
  53432. */
  53433. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53434. /**
  53435. * Adds the given reflection probe to this scene.
  53436. * @param newReflectionProbe The reflection probe to add
  53437. */
  53438. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53439. }
  53440. /**
  53441. * Class used to generate realtime reflection / refraction cube textures
  53442. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53443. */
  53444. export class ReflectionProbe {
  53445. /** defines the name of the probe */
  53446. name: string;
  53447. private _scene;
  53448. private _renderTargetTexture;
  53449. private _projectionMatrix;
  53450. private _viewMatrix;
  53451. private _target;
  53452. private _add;
  53453. private _attachedMesh;
  53454. private _invertYAxis;
  53455. /** Gets or sets probe position (center of the cube map) */
  53456. position: Vector3;
  53457. /**
  53458. * Creates a new reflection probe
  53459. * @param name defines the name of the probe
  53460. * @param size defines the texture resolution (for each face)
  53461. * @param scene defines the hosting scene
  53462. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53463. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53464. */
  53465. constructor(
  53466. /** defines the name of the probe */
  53467. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53468. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53469. samples: number;
  53470. /** Gets or sets the refresh rate to use (on every frame by default) */
  53471. refreshRate: number;
  53472. /**
  53473. * Gets the hosting scene
  53474. * @returns a Scene
  53475. */
  53476. getScene(): Scene;
  53477. /** Gets the internal CubeTexture used to render to */
  53478. readonly cubeTexture: RenderTargetTexture;
  53479. /** Gets the list of meshes to render */
  53480. readonly renderList: Nullable<AbstractMesh[]>;
  53481. /**
  53482. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53483. * @param mesh defines the mesh to attach to
  53484. */
  53485. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53486. /**
  53487. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53488. * @param renderingGroupId The rendering group id corresponding to its index
  53489. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53490. */
  53491. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53492. /**
  53493. * Clean all associated resources
  53494. */
  53495. dispose(): void;
  53496. /**
  53497. * Converts the reflection probe information to a readable string for debug purpose.
  53498. * @param fullDetails Supports for multiple levels of logging within scene loading
  53499. * @returns the human readable reflection probe info
  53500. */
  53501. toString(fullDetails?: boolean): string;
  53502. /**
  53503. * Get the class name of the relfection probe.
  53504. * @returns "ReflectionProbe"
  53505. */
  53506. getClassName(): string;
  53507. /**
  53508. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53509. * @returns The JSON representation of the texture
  53510. */
  53511. serialize(): any;
  53512. /**
  53513. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53514. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53515. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53516. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53517. * @returns The parsed reflection probe if successful
  53518. */
  53519. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53520. }
  53521. }
  53522. declare module BABYLON {
  53523. /** @hidden */
  53524. export var _BabylonLoaderRegistered: boolean;
  53525. /**
  53526. * Helps setting up some configuration for the babylon file loader.
  53527. */
  53528. export class BabylonFileLoaderConfiguration {
  53529. /**
  53530. * The loader does not allow injecting custom physix engine into the plugins.
  53531. * Unfortunately in ES6, we need to manually inject them into the plugin.
  53532. * So you could set this variable to your engine import to make it work.
  53533. */
  53534. static LoaderInjectedPhysicsEngine: any;
  53535. }
  53536. }
  53537. declare module BABYLON {
  53538. /**
  53539. * The Physically based simple base material of BJS.
  53540. *
  53541. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53542. * It is used as the base class for both the specGloss and metalRough conventions.
  53543. */
  53544. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53545. /**
  53546. * Number of Simultaneous lights allowed on the material.
  53547. */
  53548. maxSimultaneousLights: number;
  53549. /**
  53550. * If sets to true, disables all the lights affecting the material.
  53551. */
  53552. disableLighting: boolean;
  53553. /**
  53554. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53555. */
  53556. environmentTexture: BaseTexture;
  53557. /**
  53558. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53559. */
  53560. invertNormalMapX: boolean;
  53561. /**
  53562. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53563. */
  53564. invertNormalMapY: boolean;
  53565. /**
  53566. * Normal map used in the model.
  53567. */
  53568. normalTexture: BaseTexture;
  53569. /**
  53570. * Emissivie color used to self-illuminate the model.
  53571. */
  53572. emissiveColor: Color3;
  53573. /**
  53574. * Emissivie texture used to self-illuminate the model.
  53575. */
  53576. emissiveTexture: BaseTexture;
  53577. /**
  53578. * Occlusion Channel Strenght.
  53579. */
  53580. occlusionStrength: number;
  53581. /**
  53582. * Occlusion Texture of the material (adding extra occlusion effects).
  53583. */
  53584. occlusionTexture: BaseTexture;
  53585. /**
  53586. * Defines the alpha limits in alpha test mode.
  53587. */
  53588. alphaCutOff: number;
  53589. /**
  53590. * Gets the current double sided mode.
  53591. */
  53592. /**
  53593. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53594. */
  53595. doubleSided: boolean;
  53596. /**
  53597. * Stores the pre-calculated light information of a mesh in a texture.
  53598. */
  53599. lightmapTexture: BaseTexture;
  53600. /**
  53601. * If true, the light map contains occlusion information instead of lighting info.
  53602. */
  53603. useLightmapAsShadowmap: boolean;
  53604. /**
  53605. * Instantiates a new PBRMaterial instance.
  53606. *
  53607. * @param name The material name
  53608. * @param scene The scene the material will be use in.
  53609. */
  53610. constructor(name: string, scene: Scene);
  53611. getClassName(): string;
  53612. }
  53613. }
  53614. declare module BABYLON {
  53615. /**
  53616. * The PBR material of BJS following the metal roughness convention.
  53617. *
  53618. * This fits to the PBR convention in the GLTF definition:
  53619. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53620. */
  53621. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53622. /**
  53623. * The base color has two different interpretations depending on the value of metalness.
  53624. * When the material is a metal, the base color is the specific measured reflectance value
  53625. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53626. * of the material.
  53627. */
  53628. baseColor: Color3;
  53629. /**
  53630. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53631. * well as opacity information in the alpha channel.
  53632. */
  53633. baseTexture: BaseTexture;
  53634. /**
  53635. * Specifies the metallic scalar value of the material.
  53636. * Can also be used to scale the metalness values of the metallic texture.
  53637. */
  53638. metallic: number;
  53639. /**
  53640. * Specifies the roughness scalar value of the material.
  53641. * Can also be used to scale the roughness values of the metallic texture.
  53642. */
  53643. roughness: number;
  53644. /**
  53645. * Texture containing both the metallic value in the B channel and the
  53646. * roughness value in the G channel to keep better precision.
  53647. */
  53648. metallicRoughnessTexture: BaseTexture;
  53649. /**
  53650. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53651. *
  53652. * @param name The material name
  53653. * @param scene The scene the material will be use in.
  53654. */
  53655. constructor(name: string, scene: Scene);
  53656. /**
  53657. * Return the currrent class name of the material.
  53658. */
  53659. getClassName(): string;
  53660. /**
  53661. * Makes a duplicate of the current material.
  53662. * @param name - name to use for the new material.
  53663. */
  53664. clone(name: string): PBRMetallicRoughnessMaterial;
  53665. /**
  53666. * Serialize the material to a parsable JSON object.
  53667. */
  53668. serialize(): any;
  53669. /**
  53670. * Parses a JSON object correponding to the serialize function.
  53671. */
  53672. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53673. }
  53674. }
  53675. declare module BABYLON {
  53676. /**
  53677. * The PBR material of BJS following the specular glossiness convention.
  53678. *
  53679. * This fits to the PBR convention in the GLTF definition:
  53680. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53681. */
  53682. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53683. /**
  53684. * Specifies the diffuse color of the material.
  53685. */
  53686. diffuseColor: Color3;
  53687. /**
  53688. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53689. * channel.
  53690. */
  53691. diffuseTexture: BaseTexture;
  53692. /**
  53693. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53694. */
  53695. specularColor: Color3;
  53696. /**
  53697. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53698. */
  53699. glossiness: number;
  53700. /**
  53701. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53702. */
  53703. specularGlossinessTexture: BaseTexture;
  53704. /**
  53705. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53706. *
  53707. * @param name The material name
  53708. * @param scene The scene the material will be use in.
  53709. */
  53710. constructor(name: string, scene: Scene);
  53711. /**
  53712. * Return the currrent class name of the material.
  53713. */
  53714. getClassName(): string;
  53715. /**
  53716. * Makes a duplicate of the current material.
  53717. * @param name - name to use for the new material.
  53718. */
  53719. clone(name: string): PBRSpecularGlossinessMaterial;
  53720. /**
  53721. * Serialize the material to a parsable JSON object.
  53722. */
  53723. serialize(): any;
  53724. /**
  53725. * Parses a JSON object correponding to the serialize function.
  53726. */
  53727. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53728. }
  53729. }
  53730. declare module BABYLON {
  53731. /**
  53732. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53733. * It can help converting any input color in a desired output one. This can then be used to create effects
  53734. * from sepia, black and white to sixties or futuristic rendering...
  53735. *
  53736. * The only supported format is currently 3dl.
  53737. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53738. */
  53739. export class ColorGradingTexture extends BaseTexture {
  53740. /**
  53741. * The current texture matrix. (will always be identity in color grading texture)
  53742. */
  53743. private _textureMatrix;
  53744. /**
  53745. * The texture URL.
  53746. */
  53747. url: string;
  53748. /**
  53749. * Empty line regex stored for GC.
  53750. */
  53751. private static _noneEmptyLineRegex;
  53752. private _engine;
  53753. /**
  53754. * Instantiates a ColorGradingTexture from the following parameters.
  53755. *
  53756. * @param url The location of the color gradind data (currently only supporting 3dl)
  53757. * @param scene The scene the texture will be used in
  53758. */
  53759. constructor(url: string, scene: Scene);
  53760. /**
  53761. * Returns the texture matrix used in most of the material.
  53762. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53763. */
  53764. getTextureMatrix(): Matrix;
  53765. /**
  53766. * Occurs when the file being loaded is a .3dl LUT file.
  53767. */
  53768. private load3dlTexture;
  53769. /**
  53770. * Starts the loading process of the texture.
  53771. */
  53772. private loadTexture;
  53773. /**
  53774. * Clones the color gradind texture.
  53775. */
  53776. clone(): ColorGradingTexture;
  53777. /**
  53778. * Called during delayed load for textures.
  53779. */
  53780. delayLoad(): void;
  53781. /**
  53782. * Parses a color grading texture serialized by Babylon.
  53783. * @param parsedTexture The texture information being parsedTexture
  53784. * @param scene The scene to load the texture in
  53785. * @param rootUrl The root url of the data assets to load
  53786. * @return A color gradind texture
  53787. */
  53788. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53789. /**
  53790. * Serializes the LUT texture to json format.
  53791. */
  53792. serialize(): any;
  53793. }
  53794. }
  53795. declare module BABYLON {
  53796. /**
  53797. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53798. */
  53799. export class EquiRectangularCubeTexture extends BaseTexture {
  53800. /** The six faces of the cube. */
  53801. private static _FacesMapping;
  53802. private _noMipmap;
  53803. private _onLoad;
  53804. private _onError;
  53805. /** The size of the cubemap. */
  53806. private _size;
  53807. /** The buffer of the image. */
  53808. private _buffer;
  53809. /** The width of the input image. */
  53810. private _width;
  53811. /** The height of the input image. */
  53812. private _height;
  53813. /** The URL to the image. */
  53814. url: string;
  53815. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53816. coordinatesMode: number;
  53817. /**
  53818. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53819. * @param url The location of the image
  53820. * @param scene The scene the texture will be used in
  53821. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53822. * @param noMipmap Forces to not generate the mipmap if true
  53823. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53824. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53825. * @param onLoad — defines a callback called when texture is loaded
  53826. * @param onError — defines a callback called if there is an error
  53827. */
  53828. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53829. /**
  53830. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53831. */
  53832. private loadImage;
  53833. /**
  53834. * Convert the image buffer into a cubemap and create a CubeTexture.
  53835. */
  53836. private loadTexture;
  53837. /**
  53838. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53839. * @param buffer The ArrayBuffer that should be converted.
  53840. * @returns The buffer as Float32Array.
  53841. */
  53842. private getFloat32ArrayFromArrayBuffer;
  53843. /**
  53844. * Get the current class name of the texture useful for serialization or dynamic coding.
  53845. * @returns "EquiRectangularCubeTexture"
  53846. */
  53847. getClassName(): string;
  53848. /**
  53849. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53850. * @returns A clone of the current EquiRectangularCubeTexture.
  53851. */
  53852. clone(): EquiRectangularCubeTexture;
  53853. }
  53854. }
  53855. declare module BABYLON {
  53856. /**
  53857. * Based on jsTGALoader - Javascript loader for TGA file
  53858. * By Vincent Thibault
  53859. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53860. */
  53861. export class TGATools {
  53862. private static _TYPE_INDEXED;
  53863. private static _TYPE_RGB;
  53864. private static _TYPE_GREY;
  53865. private static _TYPE_RLE_INDEXED;
  53866. private static _TYPE_RLE_RGB;
  53867. private static _TYPE_RLE_GREY;
  53868. private static _ORIGIN_MASK;
  53869. private static _ORIGIN_SHIFT;
  53870. private static _ORIGIN_BL;
  53871. private static _ORIGIN_BR;
  53872. private static _ORIGIN_UL;
  53873. private static _ORIGIN_UR;
  53874. /**
  53875. * Gets the header of a TGA file
  53876. * @param data defines the TGA data
  53877. * @returns the header
  53878. */
  53879. static GetTGAHeader(data: Uint8Array): any;
  53880. /**
  53881. * Uploads TGA content to a Babylon Texture
  53882. * @hidden
  53883. */
  53884. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53885. /** @hidden */
  53886. 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;
  53887. /** @hidden */
  53888. 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;
  53889. /** @hidden */
  53890. 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;
  53891. /** @hidden */
  53892. 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;
  53893. /** @hidden */
  53894. 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;
  53895. /** @hidden */
  53896. 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;
  53897. }
  53898. }
  53899. declare module BABYLON {
  53900. /**
  53901. * Implementation of the TGA Texture Loader.
  53902. * @hidden
  53903. */
  53904. export class _TGATextureLoader implements IInternalTextureLoader {
  53905. /**
  53906. * Defines wether the loader supports cascade loading the different faces.
  53907. */
  53908. readonly supportCascades: boolean;
  53909. /**
  53910. * This returns if the loader support the current file information.
  53911. * @param extension defines the file extension of the file being loaded
  53912. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53913. * @param fallback defines the fallback internal texture if any
  53914. * @param isBase64 defines whether the texture is encoded as a base64
  53915. * @param isBuffer defines whether the texture data are stored as a buffer
  53916. * @returns true if the loader can load the specified file
  53917. */
  53918. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53919. /**
  53920. * Transform the url before loading if required.
  53921. * @param rootUrl the url of the texture
  53922. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53923. * @returns the transformed texture
  53924. */
  53925. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53926. /**
  53927. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53928. * @param rootUrl the url of the texture
  53929. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53930. * @returns the fallback texture
  53931. */
  53932. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53933. /**
  53934. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53935. * @param data contains the texture data
  53936. * @param texture defines the BabylonJS internal texture
  53937. * @param createPolynomials will be true if polynomials have been requested
  53938. * @param onLoad defines the callback to trigger once the texture is ready
  53939. * @param onError defines the callback to trigger in case of error
  53940. */
  53941. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53942. /**
  53943. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53944. * @param data contains the texture data
  53945. * @param texture defines the BabylonJS internal texture
  53946. * @param callback defines the method to call once ready to upload
  53947. */
  53948. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53949. }
  53950. }
  53951. declare module BABYLON {
  53952. /**
  53953. * Info about the .basis files
  53954. */
  53955. class BasisFileInfo {
  53956. /**
  53957. * If the file has alpha
  53958. */
  53959. hasAlpha: boolean;
  53960. /**
  53961. * Info about each image of the basis file
  53962. */
  53963. images: Array<{
  53964. levels: Array<{
  53965. width: number;
  53966. height: number;
  53967. transcodedPixels: ArrayBufferView;
  53968. }>;
  53969. }>;
  53970. }
  53971. /**
  53972. * Result of transcoding a basis file
  53973. */
  53974. class TranscodeResult {
  53975. /**
  53976. * Info about the .basis file
  53977. */
  53978. fileInfo: BasisFileInfo;
  53979. /**
  53980. * Format to use when loading the file
  53981. */
  53982. format: number;
  53983. }
  53984. /**
  53985. * Configuration options for the Basis transcoder
  53986. */
  53987. export class BasisTranscodeConfiguration {
  53988. /**
  53989. * Supported compression formats used to determine the supported output format of the transcoder
  53990. */
  53991. supportedCompressionFormats?: {
  53992. /**
  53993. * etc1 compression format
  53994. */
  53995. etc1?: boolean;
  53996. /**
  53997. * s3tc compression format
  53998. */
  53999. s3tc?: boolean;
  54000. /**
  54001. * pvrtc compression format
  54002. */
  54003. pvrtc?: boolean;
  54004. /**
  54005. * etc2 compression format
  54006. */
  54007. etc2?: boolean;
  54008. };
  54009. /**
  54010. * If mipmap levels should be loaded for transcoded images (Default: true)
  54011. */
  54012. loadMipmapLevels?: boolean;
  54013. /**
  54014. * Index of a single image to load (Default: all images)
  54015. */
  54016. loadSingleImage?: number;
  54017. }
  54018. /**
  54019. * Used to load .Basis files
  54020. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54021. */
  54022. export class BasisTools {
  54023. private static _IgnoreSupportedFormats;
  54024. /**
  54025. * URL to use when loading the basis transcoder
  54026. */
  54027. static JSModuleURL: string;
  54028. /**
  54029. * URL to use when loading the wasm module for the transcoder
  54030. */
  54031. static WasmModuleURL: string;
  54032. /**
  54033. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54034. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54035. * @returns internal format corresponding to the Basis format
  54036. */
  54037. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54038. private static _WorkerPromise;
  54039. private static _Worker;
  54040. private static _actionId;
  54041. private static _CreateWorkerAsync;
  54042. /**
  54043. * Transcodes a loaded image file to compressed pixel data
  54044. * @param imageData image data to transcode
  54045. * @param config configuration options for the transcoding
  54046. * @returns a promise resulting in the transcoded image
  54047. */
  54048. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54049. /**
  54050. * Loads a texture from the transcode result
  54051. * @param texture texture load to
  54052. * @param transcodeResult the result of transcoding the basis file to load from
  54053. */
  54054. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54055. }
  54056. }
  54057. declare module BABYLON {
  54058. /**
  54059. * Loader for .basis file format
  54060. */
  54061. export class _BasisTextureLoader implements IInternalTextureLoader {
  54062. /**
  54063. * Defines whether the loader supports cascade loading the different faces.
  54064. */
  54065. readonly supportCascades: boolean;
  54066. /**
  54067. * This returns if the loader support the current file information.
  54068. * @param extension defines the file extension of the file being loaded
  54069. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54070. * @param fallback defines the fallback internal texture if any
  54071. * @param isBase64 defines whether the texture is encoded as a base64
  54072. * @param isBuffer defines whether the texture data are stored as a buffer
  54073. * @returns true if the loader can load the specified file
  54074. */
  54075. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54076. /**
  54077. * Transform the url before loading if required.
  54078. * @param rootUrl the url of the texture
  54079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54080. * @returns the transformed texture
  54081. */
  54082. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54083. /**
  54084. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54085. * @param rootUrl the url of the texture
  54086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54087. * @returns the fallback texture
  54088. */
  54089. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54090. /**
  54091. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54092. * @param data contains the texture data
  54093. * @param texture defines the BabylonJS internal texture
  54094. * @param createPolynomials will be true if polynomials have been requested
  54095. * @param onLoad defines the callback to trigger once the texture is ready
  54096. * @param onError defines the callback to trigger in case of error
  54097. */
  54098. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54099. /**
  54100. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54101. * @param data contains the texture data
  54102. * @param texture defines the BabylonJS internal texture
  54103. * @param callback defines the method to call once ready to upload
  54104. */
  54105. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54106. }
  54107. }
  54108. declare module BABYLON {
  54109. /**
  54110. * 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.
  54111. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54112. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54113. */
  54114. export class CustomProceduralTexture extends ProceduralTexture {
  54115. private _animate;
  54116. private _time;
  54117. private _config;
  54118. private _texturePath;
  54119. /**
  54120. * Instantiates a new Custom Procedural Texture.
  54121. * 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.
  54122. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54123. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54124. * @param name Define the name of the texture
  54125. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54126. * @param size Define the size of the texture to create
  54127. * @param scene Define the scene the texture belongs to
  54128. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54129. * @param generateMipMaps Define if the texture should creates mip maps or not
  54130. */
  54131. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54132. private _loadJson;
  54133. /**
  54134. * Is the texture ready to be used ? (rendered at least once)
  54135. * @returns true if ready, otherwise, false.
  54136. */
  54137. isReady(): boolean;
  54138. /**
  54139. * Render the texture to its associated render target.
  54140. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54141. */
  54142. render(useCameraPostProcess?: boolean): void;
  54143. /**
  54144. * Update the list of dependant textures samplers in the shader.
  54145. */
  54146. updateTextures(): void;
  54147. /**
  54148. * Update the uniform values of the procedural texture in the shader.
  54149. */
  54150. updateShaderUniforms(): void;
  54151. /**
  54152. * Define if the texture animates or not.
  54153. */
  54154. animate: boolean;
  54155. }
  54156. }
  54157. declare module BABYLON {
  54158. /** @hidden */
  54159. export var noisePixelShader: {
  54160. name: string;
  54161. shader: string;
  54162. };
  54163. }
  54164. declare module BABYLON {
  54165. /**
  54166. * Class used to generate noise procedural textures
  54167. */
  54168. export class NoiseProceduralTexture extends ProceduralTexture {
  54169. private _time;
  54170. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54171. brightness: number;
  54172. /** Defines the number of octaves to process */
  54173. octaves: number;
  54174. /** Defines the level of persistence (0.8 by default) */
  54175. persistence: number;
  54176. /** Gets or sets animation speed factor (default is 1) */
  54177. animationSpeedFactor: number;
  54178. /**
  54179. * Creates a new NoiseProceduralTexture
  54180. * @param name defines the name fo the texture
  54181. * @param size defines the size of the texture (default is 256)
  54182. * @param scene defines the hosting scene
  54183. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54184. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54185. */
  54186. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54187. private _updateShaderUniforms;
  54188. protected _getDefines(): string;
  54189. /** Generate the current state of the procedural texture */
  54190. render(useCameraPostProcess?: boolean): void;
  54191. /**
  54192. * Serializes this noise procedural texture
  54193. * @returns a serialized noise procedural texture object
  54194. */
  54195. serialize(): any;
  54196. /**
  54197. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54198. * @param parsedTexture defines parsed texture data
  54199. * @param scene defines the current scene
  54200. * @param rootUrl defines the root URL containing noise procedural texture information
  54201. * @returns a parsed NoiseProceduralTexture
  54202. */
  54203. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54204. }
  54205. }
  54206. declare module BABYLON {
  54207. /**
  54208. * Raw cube texture where the raw buffers are passed in
  54209. */
  54210. export class RawCubeTexture extends CubeTexture {
  54211. /**
  54212. * Creates a cube texture where the raw buffers are passed in.
  54213. * @param scene defines the scene the texture is attached to
  54214. * @param data defines the array of data to use to create each face
  54215. * @param size defines the size of the textures
  54216. * @param format defines the format of the data
  54217. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54218. * @param generateMipMaps defines if the engine should generate the mip levels
  54219. * @param invertY defines if data must be stored with Y axis inverted
  54220. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54221. * @param compression defines the compression used (null by default)
  54222. */
  54223. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54224. /**
  54225. * Updates the raw cube texture.
  54226. * @param data defines the data to store
  54227. * @param format defines the data format
  54228. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54229. * @param invertY defines if data must be stored with Y axis inverted
  54230. * @param compression defines the compression used (null by default)
  54231. * @param level defines which level of the texture to update
  54232. */
  54233. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54234. /**
  54235. * Updates a raw cube texture with RGBD encoded data.
  54236. * @param data defines the array of data [mipmap][face] to use to create each face
  54237. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54238. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54239. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54240. * @returns a promsie that resolves when the operation is complete
  54241. */
  54242. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54243. /**
  54244. * Clones the raw cube texture.
  54245. * @return a new cube texture
  54246. */
  54247. clone(): CubeTexture;
  54248. /** @hidden */
  54249. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54250. }
  54251. }
  54252. declare module BABYLON {
  54253. /**
  54254. * Class used to store 3D textures containing user data
  54255. */
  54256. export class RawTexture3D extends Texture {
  54257. /** Gets or sets the texture format to use */
  54258. format: number;
  54259. private _engine;
  54260. /**
  54261. * Create a new RawTexture3D
  54262. * @param data defines the data of the texture
  54263. * @param width defines the width of the texture
  54264. * @param height defines the height of the texture
  54265. * @param depth defines the depth of the texture
  54266. * @param format defines the texture format to use
  54267. * @param scene defines the hosting scene
  54268. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54269. * @param invertY defines if texture must be stored with Y axis inverted
  54270. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54271. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54272. */
  54273. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54274. /** Gets or sets the texture format to use */
  54275. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54276. /**
  54277. * Update the texture with new data
  54278. * @param data defines the data to store in the texture
  54279. */
  54280. update(data: ArrayBufferView): void;
  54281. }
  54282. }
  54283. declare module BABYLON {
  54284. /**
  54285. * Class used to store 2D array textures containing user data
  54286. */
  54287. export class RawTexture2DArray extends Texture {
  54288. /** Gets or sets the texture format to use */
  54289. format: number;
  54290. private _engine;
  54291. /**
  54292. * Create a new RawTexture2DArray
  54293. * @param data defines the data of the texture
  54294. * @param width defines the width of the texture
  54295. * @param height defines the height of the texture
  54296. * @param depth defines the number of layers of the texture
  54297. * @param format defines the texture format to use
  54298. * @param scene defines the hosting scene
  54299. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54300. * @param invertY defines if texture must be stored with Y axis inverted
  54301. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54302. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54303. */
  54304. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54305. /** Gets or sets the texture format to use */
  54306. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54307. /**
  54308. * Update the texture with new data
  54309. * @param data defines the data to store in the texture
  54310. */
  54311. update(data: ArrayBufferView): void;
  54312. }
  54313. }
  54314. declare module BABYLON {
  54315. /**
  54316. * Creates a refraction texture used by refraction channel of the standard material.
  54317. * It is like a mirror but to see through a material.
  54318. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54319. */
  54320. export class RefractionTexture extends RenderTargetTexture {
  54321. /**
  54322. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54323. * 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.
  54324. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54325. */
  54326. refractionPlane: Plane;
  54327. /**
  54328. * Define how deep under the surface we should see.
  54329. */
  54330. depth: number;
  54331. /**
  54332. * Creates a refraction texture used by refraction channel of the standard material.
  54333. * It is like a mirror but to see through a material.
  54334. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54335. * @param name Define the texture name
  54336. * @param size Define the size of the underlying texture
  54337. * @param scene Define the scene the refraction belongs to
  54338. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54339. */
  54340. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54341. /**
  54342. * Clone the refraction texture.
  54343. * @returns the cloned texture
  54344. */
  54345. clone(): RefractionTexture;
  54346. /**
  54347. * Serialize the texture to a JSON representation you could use in Parse later on
  54348. * @returns the serialized JSON representation
  54349. */
  54350. serialize(): any;
  54351. }
  54352. }
  54353. declare module BABYLON {
  54354. /**
  54355. * Defines the options related to the creation of an HtmlElementTexture
  54356. */
  54357. export interface IHtmlElementTextureOptions {
  54358. /**
  54359. * Defines wether mip maps should be created or not.
  54360. */
  54361. generateMipMaps?: boolean;
  54362. /**
  54363. * Defines the sampling mode of the texture.
  54364. */
  54365. samplingMode?: number;
  54366. /**
  54367. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54368. */
  54369. engine: Nullable<ThinEngine>;
  54370. /**
  54371. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54372. */
  54373. scene: Nullable<Scene>;
  54374. }
  54375. /**
  54376. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54377. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54378. * is automatically managed.
  54379. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54380. * in your application.
  54381. *
  54382. * As the update is not automatic, you need to call them manually.
  54383. */
  54384. export class HtmlElementTexture extends BaseTexture {
  54385. /**
  54386. * The texture URL.
  54387. */
  54388. element: HTMLVideoElement | HTMLCanvasElement;
  54389. private static readonly DefaultOptions;
  54390. private _textureMatrix;
  54391. private _engine;
  54392. private _isVideo;
  54393. private _generateMipMaps;
  54394. private _samplingMode;
  54395. /**
  54396. * Instantiates a HtmlElementTexture from the following parameters.
  54397. *
  54398. * @param name Defines the name of the texture
  54399. * @param element Defines the video or canvas the texture is filled with
  54400. * @param options Defines the other none mandatory texture creation options
  54401. */
  54402. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54403. private _createInternalTexture;
  54404. /**
  54405. * Returns the texture matrix used in most of the material.
  54406. */
  54407. getTextureMatrix(): Matrix;
  54408. /**
  54409. * Updates the content of the texture.
  54410. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54411. */
  54412. update(invertY?: Nullable<boolean>): void;
  54413. }
  54414. }
  54415. declare module BABYLON {
  54416. /**
  54417. * Enum used to define the target of a block
  54418. */
  54419. export enum NodeMaterialBlockTargets {
  54420. /** Vertex shader */
  54421. Vertex = 1,
  54422. /** Fragment shader */
  54423. Fragment = 2,
  54424. /** Neutral */
  54425. Neutral = 4,
  54426. /** Vertex and Fragment */
  54427. VertexAndFragment = 3
  54428. }
  54429. }
  54430. declare module BABYLON {
  54431. /**
  54432. * Defines the kind of connection point for node based material
  54433. */
  54434. export enum NodeMaterialBlockConnectionPointTypes {
  54435. /** Float */
  54436. Float = 1,
  54437. /** Int */
  54438. Int = 2,
  54439. /** Vector2 */
  54440. Vector2 = 4,
  54441. /** Vector3 */
  54442. Vector3 = 8,
  54443. /** Vector4 */
  54444. Vector4 = 16,
  54445. /** Color3 */
  54446. Color3 = 32,
  54447. /** Color4 */
  54448. Color4 = 64,
  54449. /** Matrix */
  54450. Matrix = 128,
  54451. /** Detect type based on connection */
  54452. AutoDetect = 1024,
  54453. /** Output type that will be defined by input type */
  54454. BasedOnInput = 2048
  54455. }
  54456. }
  54457. declare module BABYLON {
  54458. /**
  54459. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54460. */
  54461. export enum NodeMaterialBlockConnectionPointMode {
  54462. /** Value is an uniform */
  54463. Uniform = 0,
  54464. /** Value is a mesh attribute */
  54465. Attribute = 1,
  54466. /** Value is a varying between vertex and fragment shaders */
  54467. Varying = 2,
  54468. /** Mode is undefined */
  54469. Undefined = 3
  54470. }
  54471. }
  54472. declare module BABYLON {
  54473. /**
  54474. * Enum used to define system values e.g. values automatically provided by the system
  54475. */
  54476. export enum NodeMaterialSystemValues {
  54477. /** World */
  54478. World = 1,
  54479. /** View */
  54480. View = 2,
  54481. /** Projection */
  54482. Projection = 3,
  54483. /** ViewProjection */
  54484. ViewProjection = 4,
  54485. /** WorldView */
  54486. WorldView = 5,
  54487. /** WorldViewProjection */
  54488. WorldViewProjection = 6,
  54489. /** CameraPosition */
  54490. CameraPosition = 7,
  54491. /** Fog Color */
  54492. FogColor = 8,
  54493. /** Delta time */
  54494. DeltaTime = 9
  54495. }
  54496. }
  54497. declare module BABYLON {
  54498. /**
  54499. * Root class for all node material optimizers
  54500. */
  54501. export class NodeMaterialOptimizer {
  54502. /**
  54503. * Function used to optimize a NodeMaterial graph
  54504. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54505. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54506. */
  54507. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54508. }
  54509. }
  54510. declare module BABYLON {
  54511. /**
  54512. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54513. */
  54514. export class TransformBlock extends NodeMaterialBlock {
  54515. /**
  54516. * Defines the value to use to complement W value to transform it to a Vector4
  54517. */
  54518. complementW: number;
  54519. /**
  54520. * Defines the value to use to complement z value to transform it to a Vector4
  54521. */
  54522. complementZ: number;
  54523. /**
  54524. * Creates a new TransformBlock
  54525. * @param name defines the block name
  54526. */
  54527. constructor(name: string);
  54528. /**
  54529. * Gets the current class name
  54530. * @returns the class name
  54531. */
  54532. getClassName(): string;
  54533. /**
  54534. * Gets the vector input
  54535. */
  54536. readonly vector: NodeMaterialConnectionPoint;
  54537. /**
  54538. * Gets the output component
  54539. */
  54540. readonly output: NodeMaterialConnectionPoint;
  54541. /**
  54542. * Gets the matrix transform input
  54543. */
  54544. readonly transform: NodeMaterialConnectionPoint;
  54545. protected _buildBlock(state: NodeMaterialBuildState): this;
  54546. serialize(): any;
  54547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54548. protected _dumpPropertiesCode(): string;
  54549. }
  54550. }
  54551. declare module BABYLON {
  54552. /**
  54553. * Block used to output the vertex position
  54554. */
  54555. export class VertexOutputBlock extends NodeMaterialBlock {
  54556. /**
  54557. * Creates a new VertexOutputBlock
  54558. * @param name defines the block name
  54559. */
  54560. constructor(name: string);
  54561. /**
  54562. * Gets the current class name
  54563. * @returns the class name
  54564. */
  54565. getClassName(): string;
  54566. /**
  54567. * Gets the vector input component
  54568. */
  54569. readonly vector: NodeMaterialConnectionPoint;
  54570. protected _buildBlock(state: NodeMaterialBuildState): this;
  54571. }
  54572. }
  54573. declare module BABYLON {
  54574. /**
  54575. * Block used to output the final color
  54576. */
  54577. export class FragmentOutputBlock extends NodeMaterialBlock {
  54578. /**
  54579. * Create a new FragmentOutputBlock
  54580. * @param name defines the block name
  54581. */
  54582. constructor(name: string);
  54583. /**
  54584. * Gets the current class name
  54585. * @returns the class name
  54586. */
  54587. getClassName(): string;
  54588. /**
  54589. * Gets the rgba input component
  54590. */
  54591. readonly rgba: NodeMaterialConnectionPoint;
  54592. /**
  54593. * Gets the rgb input component
  54594. */
  54595. readonly rgb: NodeMaterialConnectionPoint;
  54596. /**
  54597. * Gets the a input component
  54598. */
  54599. readonly a: NodeMaterialConnectionPoint;
  54600. protected _buildBlock(state: NodeMaterialBuildState): this;
  54601. }
  54602. }
  54603. declare module BABYLON {
  54604. /**
  54605. * Block used to read a reflection texture from a sampler
  54606. */
  54607. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54608. private _define3DName;
  54609. private _defineCubicName;
  54610. private _defineExplicitName;
  54611. private _defineProjectionName;
  54612. private _defineLocalCubicName;
  54613. private _defineSphericalName;
  54614. private _definePlanarName;
  54615. private _defineEquirectangularName;
  54616. private _defineMirroredEquirectangularFixedName;
  54617. private _defineEquirectangularFixedName;
  54618. private _defineSkyboxName;
  54619. private _cubeSamplerName;
  54620. private _2DSamplerName;
  54621. private _positionUVWName;
  54622. private _directionWName;
  54623. private _reflectionCoordsName;
  54624. private _reflection2DCoordsName;
  54625. private _reflectionColorName;
  54626. private _reflectionMatrixName;
  54627. /**
  54628. * Gets or sets the texture associated with the node
  54629. */
  54630. texture: Nullable<BaseTexture>;
  54631. /**
  54632. * Create a new TextureBlock
  54633. * @param name defines the block name
  54634. */
  54635. constructor(name: string);
  54636. /**
  54637. * Gets the current class name
  54638. * @returns the class name
  54639. */
  54640. getClassName(): string;
  54641. /**
  54642. * Gets the world position input component
  54643. */
  54644. readonly position: NodeMaterialConnectionPoint;
  54645. /**
  54646. * Gets the world position input component
  54647. */
  54648. readonly worldPosition: NodeMaterialConnectionPoint;
  54649. /**
  54650. * Gets the world normal input component
  54651. */
  54652. readonly worldNormal: NodeMaterialConnectionPoint;
  54653. /**
  54654. * Gets the world input component
  54655. */
  54656. readonly world: NodeMaterialConnectionPoint;
  54657. /**
  54658. * Gets the camera (or eye) position component
  54659. */
  54660. readonly cameraPosition: NodeMaterialConnectionPoint;
  54661. /**
  54662. * Gets the view input component
  54663. */
  54664. readonly view: NodeMaterialConnectionPoint;
  54665. /**
  54666. * Gets the rgb output component
  54667. */
  54668. readonly rgb: NodeMaterialConnectionPoint;
  54669. /**
  54670. * Gets the r output component
  54671. */
  54672. readonly r: NodeMaterialConnectionPoint;
  54673. /**
  54674. * Gets the g output component
  54675. */
  54676. readonly g: NodeMaterialConnectionPoint;
  54677. /**
  54678. * Gets the b output component
  54679. */
  54680. readonly b: NodeMaterialConnectionPoint;
  54681. autoConfigure(material: NodeMaterial): void;
  54682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54683. isReady(): boolean;
  54684. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54685. private _injectVertexCode;
  54686. private _writeOutput;
  54687. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54688. protected _dumpPropertiesCode(): string;
  54689. serialize(): any;
  54690. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54691. }
  54692. }
  54693. declare module BABYLON {
  54694. /**
  54695. * Interface used to configure the node material editor
  54696. */
  54697. export interface INodeMaterialEditorOptions {
  54698. /** Define the URl to load node editor script */
  54699. editorURL?: string;
  54700. }
  54701. /** @hidden */
  54702. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54703. /** BONES */
  54704. NUM_BONE_INFLUENCERS: number;
  54705. BonesPerMesh: number;
  54706. BONETEXTURE: boolean;
  54707. /** MORPH TARGETS */
  54708. MORPHTARGETS: boolean;
  54709. MORPHTARGETS_NORMAL: boolean;
  54710. MORPHTARGETS_TANGENT: boolean;
  54711. MORPHTARGETS_UV: boolean;
  54712. NUM_MORPH_INFLUENCERS: number;
  54713. /** IMAGE PROCESSING */
  54714. IMAGEPROCESSING: boolean;
  54715. VIGNETTE: boolean;
  54716. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54717. VIGNETTEBLENDMODEOPAQUE: boolean;
  54718. TONEMAPPING: boolean;
  54719. TONEMAPPING_ACES: boolean;
  54720. CONTRAST: boolean;
  54721. EXPOSURE: boolean;
  54722. COLORCURVES: boolean;
  54723. COLORGRADING: boolean;
  54724. COLORGRADING3D: boolean;
  54725. SAMPLER3DGREENDEPTH: boolean;
  54726. SAMPLER3DBGRMAP: boolean;
  54727. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54728. /** MISC. */
  54729. BUMPDIRECTUV: number;
  54730. constructor();
  54731. setValue(name: string, value: boolean): void;
  54732. }
  54733. /**
  54734. * Class used to configure NodeMaterial
  54735. */
  54736. export interface INodeMaterialOptions {
  54737. /**
  54738. * Defines if blocks should emit comments
  54739. */
  54740. emitComments: boolean;
  54741. }
  54742. /**
  54743. * Class used to create a node based material built by assembling shader blocks
  54744. */
  54745. export class NodeMaterial extends PushMaterial {
  54746. private static _BuildIdGenerator;
  54747. private _options;
  54748. private _vertexCompilationState;
  54749. private _fragmentCompilationState;
  54750. private _sharedData;
  54751. private _buildId;
  54752. private _buildWasSuccessful;
  54753. private _cachedWorldViewMatrix;
  54754. private _cachedWorldViewProjectionMatrix;
  54755. private _optimizers;
  54756. private _animationFrame;
  54757. /** Define the URl to load node editor script */
  54758. static EditorURL: string;
  54759. private BJSNODEMATERIALEDITOR;
  54760. /** Get the inspector from bundle or global */
  54761. private _getGlobalNodeMaterialEditor;
  54762. /**
  54763. * Gets or sets data used by visual editor
  54764. * @see https://nme.babylonjs.com
  54765. */
  54766. editorData: any;
  54767. /**
  54768. * 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)
  54769. */
  54770. ignoreAlpha: boolean;
  54771. /**
  54772. * Defines the maximum number of lights that can be used in the material
  54773. */
  54774. maxSimultaneousLights: number;
  54775. /**
  54776. * Observable raised when the material is built
  54777. */
  54778. onBuildObservable: Observable<NodeMaterial>;
  54779. /**
  54780. * Gets or sets the root nodes of the material vertex shader
  54781. */
  54782. _vertexOutputNodes: NodeMaterialBlock[];
  54783. /**
  54784. * Gets or sets the root nodes of the material fragment (pixel) shader
  54785. */
  54786. _fragmentOutputNodes: NodeMaterialBlock[];
  54787. /** Gets or sets options to control the node material overall behavior */
  54788. options: INodeMaterialOptions;
  54789. /**
  54790. * Default configuration related to image processing available in the standard Material.
  54791. */
  54792. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54793. /**
  54794. * Gets the image processing configuration used either in this material.
  54795. */
  54796. /**
  54797. * Sets the Default image processing configuration used either in the this material.
  54798. *
  54799. * If sets to null, the scene one is in use.
  54800. */
  54801. imageProcessingConfiguration: ImageProcessingConfiguration;
  54802. /**
  54803. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54804. */
  54805. attachedBlocks: NodeMaterialBlock[];
  54806. /**
  54807. * Create a new node based material
  54808. * @param name defines the material name
  54809. * @param scene defines the hosting scene
  54810. * @param options defines creation option
  54811. */
  54812. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54813. /**
  54814. * Gets the current class name of the material e.g. "NodeMaterial"
  54815. * @returns the class name
  54816. */
  54817. getClassName(): string;
  54818. /**
  54819. * Keep track of the image processing observer to allow dispose and replace.
  54820. */
  54821. private _imageProcessingObserver;
  54822. /**
  54823. * Attaches a new image processing configuration to the Standard Material.
  54824. * @param configuration
  54825. */
  54826. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54827. /**
  54828. * Get a block by its name
  54829. * @param name defines the name of the block to retrieve
  54830. * @returns the required block or null if not found
  54831. */
  54832. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54833. /**
  54834. * Get a block by its name
  54835. * @param predicate defines the predicate used to find the good candidate
  54836. * @returns the required block or null if not found
  54837. */
  54838. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54839. /**
  54840. * Get an input block by its name
  54841. * @param predicate defines the predicate used to find the good candidate
  54842. * @returns the required input block or null if not found
  54843. */
  54844. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54845. /**
  54846. * Gets the list of input blocks attached to this material
  54847. * @returns an array of InputBlocks
  54848. */
  54849. getInputBlocks(): InputBlock[];
  54850. /**
  54851. * Adds a new optimizer to the list of optimizers
  54852. * @param optimizer defines the optimizers to add
  54853. * @returns the current material
  54854. */
  54855. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54856. /**
  54857. * Remove an optimizer from the list of optimizers
  54858. * @param optimizer defines the optimizers to remove
  54859. * @returns the current material
  54860. */
  54861. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54862. /**
  54863. * Add a new block to the list of output nodes
  54864. * @param node defines the node to add
  54865. * @returns the current material
  54866. */
  54867. addOutputNode(node: NodeMaterialBlock): this;
  54868. /**
  54869. * Remove a block from the list of root nodes
  54870. * @param node defines the node to remove
  54871. * @returns the current material
  54872. */
  54873. removeOutputNode(node: NodeMaterialBlock): this;
  54874. private _addVertexOutputNode;
  54875. private _removeVertexOutputNode;
  54876. private _addFragmentOutputNode;
  54877. private _removeFragmentOutputNode;
  54878. /**
  54879. * Specifies if the material will require alpha blending
  54880. * @returns a boolean specifying if alpha blending is needed
  54881. */
  54882. needAlphaBlending(): boolean;
  54883. /**
  54884. * Specifies if this material should be rendered in alpha test mode
  54885. * @returns a boolean specifying if an alpha test is needed.
  54886. */
  54887. needAlphaTesting(): boolean;
  54888. private _initializeBlock;
  54889. private _resetDualBlocks;
  54890. /**
  54891. * Remove a block from the current node material
  54892. * @param block defines the block to remove
  54893. */
  54894. removeBlock(block: NodeMaterialBlock): void;
  54895. /**
  54896. * Build the material and generates the inner effect
  54897. * @param verbose defines if the build should log activity
  54898. */
  54899. build(verbose?: boolean): void;
  54900. /**
  54901. * Runs an otpimization phase to try to improve the shader code
  54902. */
  54903. optimize(): void;
  54904. private _prepareDefinesForAttributes;
  54905. /**
  54906. * Get if the submesh is ready to be used and all its information available.
  54907. * Child classes can use it to update shaders
  54908. * @param mesh defines the mesh to check
  54909. * @param subMesh defines which submesh to check
  54910. * @param useInstances specifies that instances should be used
  54911. * @returns a boolean indicating that the submesh is ready or not
  54912. */
  54913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54914. /**
  54915. * Get a string representing the shaders built by the current node graph
  54916. */
  54917. readonly compiledShaders: string;
  54918. /**
  54919. * Binds the world matrix to the material
  54920. * @param world defines the world transformation matrix
  54921. */
  54922. bindOnlyWorldMatrix(world: Matrix): void;
  54923. /**
  54924. * Binds the submesh to this material by preparing the effect and shader to draw
  54925. * @param world defines the world transformation matrix
  54926. * @param mesh defines the mesh containing the submesh
  54927. * @param subMesh defines the submesh to bind the material to
  54928. */
  54929. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54930. /**
  54931. * Gets the active textures from the material
  54932. * @returns an array of textures
  54933. */
  54934. getActiveTextures(): BaseTexture[];
  54935. /**
  54936. * Gets the list of texture blocks
  54937. * @returns an array of texture blocks
  54938. */
  54939. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54940. /**
  54941. * Specifies if the material uses a texture
  54942. * @param texture defines the texture to check against the material
  54943. * @returns a boolean specifying if the material uses the texture
  54944. */
  54945. hasTexture(texture: BaseTexture): boolean;
  54946. /**
  54947. * Disposes the material
  54948. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54949. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54950. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54951. */
  54952. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54953. /** Creates the node editor window. */
  54954. private _createNodeEditor;
  54955. /**
  54956. * Launch the node material editor
  54957. * @param config Define the configuration of the editor
  54958. * @return a promise fulfilled when the node editor is visible
  54959. */
  54960. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54961. /**
  54962. * Clear the current material
  54963. */
  54964. clear(): void;
  54965. /**
  54966. * Clear the current material and set it to a default state
  54967. */
  54968. setToDefault(): void;
  54969. /**
  54970. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54971. * @param url defines the url to load from
  54972. * @returns a promise that will fullfil when the material is fully loaded
  54973. */
  54974. loadAsync(url: string): Promise<void>;
  54975. private _gatherBlocks;
  54976. /**
  54977. * Generate a string containing the code declaration required to create an equivalent of this material
  54978. * @returns a string
  54979. */
  54980. generateCode(): string;
  54981. /**
  54982. * Serializes this material in a JSON representation
  54983. * @returns the serialized material object
  54984. */
  54985. serialize(): any;
  54986. private _restoreConnections;
  54987. /**
  54988. * Clear the current graph and load a new one from a serialization object
  54989. * @param source defines the JSON representation of the material
  54990. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54991. */
  54992. loadFromSerialization(source: any, rootUrl?: string): void;
  54993. /**
  54994. * Creates a node material from parsed material data
  54995. * @param source defines the JSON representation of the material
  54996. * @param scene defines the hosting scene
  54997. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54998. * @returns a new node material
  54999. */
  55000. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55001. /**
  55002. * Creates a new node material set to default basic configuration
  55003. * @param name defines the name of the material
  55004. * @param scene defines the hosting scene
  55005. * @returns a new NodeMaterial
  55006. */
  55007. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55008. }
  55009. }
  55010. declare module BABYLON {
  55011. /**
  55012. * Block used to read a texture from a sampler
  55013. */
  55014. export class TextureBlock extends NodeMaterialBlock {
  55015. private _defineName;
  55016. private _linearDefineName;
  55017. private _tempTextureRead;
  55018. private _samplerName;
  55019. private _transformedUVName;
  55020. private _textureTransformName;
  55021. private _textureInfoName;
  55022. private _mainUVName;
  55023. private _mainUVDefineName;
  55024. /**
  55025. * Gets or sets the texture associated with the node
  55026. */
  55027. texture: Nullable<Texture>;
  55028. /**
  55029. * Create a new TextureBlock
  55030. * @param name defines the block name
  55031. */
  55032. constructor(name: string);
  55033. /**
  55034. * Gets the current class name
  55035. * @returns the class name
  55036. */
  55037. getClassName(): string;
  55038. /**
  55039. * Gets the uv input component
  55040. */
  55041. readonly uv: NodeMaterialConnectionPoint;
  55042. /**
  55043. * Gets the rgba output component
  55044. */
  55045. readonly rgba: NodeMaterialConnectionPoint;
  55046. /**
  55047. * Gets the rgb output component
  55048. */
  55049. readonly rgb: NodeMaterialConnectionPoint;
  55050. /**
  55051. * Gets the r output component
  55052. */
  55053. readonly r: NodeMaterialConnectionPoint;
  55054. /**
  55055. * Gets the g output component
  55056. */
  55057. readonly g: NodeMaterialConnectionPoint;
  55058. /**
  55059. * Gets the b output component
  55060. */
  55061. readonly b: NodeMaterialConnectionPoint;
  55062. /**
  55063. * Gets the a output component
  55064. */
  55065. readonly a: NodeMaterialConnectionPoint;
  55066. readonly target: NodeMaterialBlockTargets;
  55067. autoConfigure(material: NodeMaterial): void;
  55068. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55070. private _getTextureBase;
  55071. isReady(): boolean;
  55072. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55073. private readonly _isMixed;
  55074. private _injectVertexCode;
  55075. private _writeTextureRead;
  55076. private _writeOutput;
  55077. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55078. protected _dumpPropertiesCode(): string;
  55079. serialize(): any;
  55080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55081. }
  55082. }
  55083. declare module BABYLON {
  55084. /**
  55085. * Class used to store shared data between 2 NodeMaterialBuildState
  55086. */
  55087. export class NodeMaterialBuildStateSharedData {
  55088. /**
  55089. * Gets the list of emitted varyings
  55090. */
  55091. temps: string[];
  55092. /**
  55093. * Gets the list of emitted varyings
  55094. */
  55095. varyings: string[];
  55096. /**
  55097. * Gets the varying declaration string
  55098. */
  55099. varyingDeclaration: string;
  55100. /**
  55101. * Input blocks
  55102. */
  55103. inputBlocks: InputBlock[];
  55104. /**
  55105. * Input blocks
  55106. */
  55107. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55108. /**
  55109. * Bindable blocks (Blocks that need to set data to the effect)
  55110. */
  55111. bindableBlocks: NodeMaterialBlock[];
  55112. /**
  55113. * List of blocks that can provide a compilation fallback
  55114. */
  55115. blocksWithFallbacks: NodeMaterialBlock[];
  55116. /**
  55117. * List of blocks that can provide a define update
  55118. */
  55119. blocksWithDefines: NodeMaterialBlock[];
  55120. /**
  55121. * List of blocks that can provide a repeatable content
  55122. */
  55123. repeatableContentBlocks: NodeMaterialBlock[];
  55124. /**
  55125. * List of blocks that can provide a dynamic list of uniforms
  55126. */
  55127. dynamicUniformBlocks: NodeMaterialBlock[];
  55128. /**
  55129. * List of blocks that can block the isReady function for the material
  55130. */
  55131. blockingBlocks: NodeMaterialBlock[];
  55132. /**
  55133. * Gets the list of animated inputs
  55134. */
  55135. animatedInputs: InputBlock[];
  55136. /**
  55137. * Build Id used to avoid multiple recompilations
  55138. */
  55139. buildId: number;
  55140. /** List of emitted variables */
  55141. variableNames: {
  55142. [key: string]: number;
  55143. };
  55144. /** List of emitted defines */
  55145. defineNames: {
  55146. [key: string]: number;
  55147. };
  55148. /** Should emit comments? */
  55149. emitComments: boolean;
  55150. /** Emit build activity */
  55151. verbose: boolean;
  55152. /** Gets or sets the hosting scene */
  55153. scene: Scene;
  55154. /**
  55155. * Gets the compilation hints emitted at compilation time
  55156. */
  55157. hints: {
  55158. needWorldViewMatrix: boolean;
  55159. needWorldViewProjectionMatrix: boolean;
  55160. needAlphaBlending: boolean;
  55161. needAlphaTesting: boolean;
  55162. };
  55163. /**
  55164. * List of compilation checks
  55165. */
  55166. checks: {
  55167. emitVertex: boolean;
  55168. emitFragment: boolean;
  55169. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55170. };
  55171. /** Creates a new shared data */
  55172. constructor();
  55173. /**
  55174. * Emits console errors and exceptions if there is a failing check
  55175. */
  55176. emitErrors(): void;
  55177. }
  55178. }
  55179. declare module BABYLON {
  55180. /**
  55181. * Class used to store node based material build state
  55182. */
  55183. export class NodeMaterialBuildState {
  55184. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55185. supportUniformBuffers: boolean;
  55186. /**
  55187. * Gets the list of emitted attributes
  55188. */
  55189. attributes: string[];
  55190. /**
  55191. * Gets the list of emitted uniforms
  55192. */
  55193. uniforms: string[];
  55194. /**
  55195. * Gets the list of emitted constants
  55196. */
  55197. constants: string[];
  55198. /**
  55199. * Gets the list of emitted samplers
  55200. */
  55201. samplers: string[];
  55202. /**
  55203. * Gets the list of emitted functions
  55204. */
  55205. functions: {
  55206. [key: string]: string;
  55207. };
  55208. /**
  55209. * Gets the list of emitted extensions
  55210. */
  55211. extensions: {
  55212. [key: string]: string;
  55213. };
  55214. /**
  55215. * Gets the target of the compilation state
  55216. */
  55217. target: NodeMaterialBlockTargets;
  55218. /**
  55219. * Gets the list of emitted counters
  55220. */
  55221. counters: {
  55222. [key: string]: number;
  55223. };
  55224. /**
  55225. * Shared data between multiple NodeMaterialBuildState instances
  55226. */
  55227. sharedData: NodeMaterialBuildStateSharedData;
  55228. /** @hidden */
  55229. _vertexState: NodeMaterialBuildState;
  55230. /** @hidden */
  55231. _attributeDeclaration: string;
  55232. /** @hidden */
  55233. _uniformDeclaration: string;
  55234. /** @hidden */
  55235. _constantDeclaration: string;
  55236. /** @hidden */
  55237. _samplerDeclaration: string;
  55238. /** @hidden */
  55239. _varyingTransfer: string;
  55240. private _repeatableContentAnchorIndex;
  55241. /** @hidden */
  55242. _builtCompilationString: string;
  55243. /**
  55244. * Gets the emitted compilation strings
  55245. */
  55246. compilationString: string;
  55247. /**
  55248. * Finalize the compilation strings
  55249. * @param state defines the current compilation state
  55250. */
  55251. finalize(state: NodeMaterialBuildState): void;
  55252. /** @hidden */
  55253. readonly _repeatableContentAnchor: string;
  55254. /** @hidden */
  55255. _getFreeVariableName(prefix: string): string;
  55256. /** @hidden */
  55257. _getFreeDefineName(prefix: string): string;
  55258. /** @hidden */
  55259. _excludeVariableName(name: string): void;
  55260. /** @hidden */
  55261. _emit2DSampler(name: string): void;
  55262. /** @hidden */
  55263. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55264. /** @hidden */
  55265. _emitExtension(name: string, extension: string): void;
  55266. /** @hidden */
  55267. _emitFunction(name: string, code: string, comments: string): void;
  55268. /** @hidden */
  55269. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55270. replaceStrings?: {
  55271. search: RegExp;
  55272. replace: string;
  55273. }[];
  55274. repeatKey?: string;
  55275. }): string;
  55276. /** @hidden */
  55277. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55278. repeatKey?: string;
  55279. removeAttributes?: boolean;
  55280. removeUniforms?: boolean;
  55281. removeVaryings?: boolean;
  55282. removeIfDef?: boolean;
  55283. replaceStrings?: {
  55284. search: RegExp;
  55285. replace: string;
  55286. }[];
  55287. }, storeKey?: string): void;
  55288. /** @hidden */
  55289. _registerTempVariable(name: string): boolean;
  55290. /** @hidden */
  55291. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55292. /** @hidden */
  55293. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55294. /** @hidden */
  55295. _emitFloat(value: number): string;
  55296. }
  55297. }
  55298. declare module BABYLON {
  55299. /**
  55300. * Defines a block that can be used inside a node based material
  55301. */
  55302. export class NodeMaterialBlock {
  55303. private _buildId;
  55304. private _buildTarget;
  55305. private _target;
  55306. private _isFinalMerger;
  55307. private _isInput;
  55308. protected _isUnique: boolean;
  55309. /** @hidden */
  55310. _codeVariableName: string;
  55311. /** @hidden */
  55312. _inputs: NodeMaterialConnectionPoint[];
  55313. /** @hidden */
  55314. _outputs: NodeMaterialConnectionPoint[];
  55315. /** @hidden */
  55316. _preparationId: number;
  55317. /**
  55318. * Gets or sets the name of the block
  55319. */
  55320. name: string;
  55321. /**
  55322. * Gets or sets the unique id of the node
  55323. */
  55324. uniqueId: number;
  55325. /**
  55326. * Gets or sets the comments associated with this block
  55327. */
  55328. comments: string;
  55329. /**
  55330. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  55331. */
  55332. readonly isUnique: boolean;
  55333. /**
  55334. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55335. */
  55336. readonly isFinalMerger: boolean;
  55337. /**
  55338. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55339. */
  55340. readonly isInput: boolean;
  55341. /**
  55342. * Gets or sets the build Id
  55343. */
  55344. buildId: number;
  55345. /**
  55346. * Gets or sets the target of the block
  55347. */
  55348. target: NodeMaterialBlockTargets;
  55349. /**
  55350. * Gets the list of input points
  55351. */
  55352. readonly inputs: NodeMaterialConnectionPoint[];
  55353. /** Gets the list of output points */
  55354. readonly outputs: NodeMaterialConnectionPoint[];
  55355. /**
  55356. * Find an input by its name
  55357. * @param name defines the name of the input to look for
  55358. * @returns the input or null if not found
  55359. */
  55360. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55361. /**
  55362. * Find an output by its name
  55363. * @param name defines the name of the outputto look for
  55364. * @returns the output or null if not found
  55365. */
  55366. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55367. /**
  55368. * Creates a new NodeMaterialBlock
  55369. * @param name defines the block name
  55370. * @param target defines the target of that block (Vertex by default)
  55371. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55372. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55373. */
  55374. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55375. /**
  55376. * Initialize the block and prepare the context for build
  55377. * @param state defines the state that will be used for the build
  55378. */
  55379. initialize(state: NodeMaterialBuildState): void;
  55380. /**
  55381. * Bind data to effect. Will only be called for blocks with isBindable === true
  55382. * @param effect defines the effect to bind data to
  55383. * @param nodeMaterial defines the hosting NodeMaterial
  55384. * @param mesh defines the mesh that will be rendered
  55385. */
  55386. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55387. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55388. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55389. protected _writeFloat(value: number): string;
  55390. /**
  55391. * Gets the current class name e.g. "NodeMaterialBlock"
  55392. * @returns the class name
  55393. */
  55394. getClassName(): string;
  55395. /**
  55396. * Register a new input. Must be called inside a block constructor
  55397. * @param name defines the connection point name
  55398. * @param type defines the connection point type
  55399. * @param isOptional defines a boolean indicating that this input can be omitted
  55400. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55401. * @returns the current block
  55402. */
  55403. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55404. /**
  55405. * Register a new output. Must be called inside a block constructor
  55406. * @param name defines the connection point name
  55407. * @param type defines the connection point type
  55408. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55409. * @returns the current block
  55410. */
  55411. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55412. /**
  55413. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55414. * @param forOutput defines an optional connection point to check compatibility with
  55415. * @returns the first available input or null
  55416. */
  55417. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55418. /**
  55419. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55420. * @param forBlock defines an optional block to check compatibility with
  55421. * @returns the first available input or null
  55422. */
  55423. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55424. /**
  55425. * Gets the sibling of the given output
  55426. * @param current defines the current output
  55427. * @returns the next output in the list or null
  55428. */
  55429. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55430. /**
  55431. * Connect current block with another block
  55432. * @param other defines the block to connect with
  55433. * @param options define the various options to help pick the right connections
  55434. * @returns the current block
  55435. */
  55436. connectTo(other: NodeMaterialBlock, options?: {
  55437. input?: string;
  55438. output?: string;
  55439. outputSwizzle?: string;
  55440. }): this | undefined;
  55441. protected _buildBlock(state: NodeMaterialBuildState): void;
  55442. /**
  55443. * Add uniforms, samplers and uniform buffers at compilation time
  55444. * @param state defines the state to update
  55445. * @param nodeMaterial defines the node material requesting the update
  55446. * @param defines defines the material defines to update
  55447. * @param uniformBuffers defines the list of uniform buffer names
  55448. */
  55449. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55450. /**
  55451. * Add potential fallbacks if shader compilation fails
  55452. * @param mesh defines the mesh to be rendered
  55453. * @param fallbacks defines the current prioritized list of fallbacks
  55454. */
  55455. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55456. /**
  55457. * Initialize defines for shader compilation
  55458. * @param mesh defines the mesh to be rendered
  55459. * @param nodeMaterial defines the node material requesting the update
  55460. * @param defines defines the material defines to update
  55461. * @param useInstances specifies that instances should be used
  55462. */
  55463. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55464. /**
  55465. * Update defines for shader compilation
  55466. * @param mesh defines the mesh to be rendered
  55467. * @param nodeMaterial defines the node material requesting the update
  55468. * @param defines defines the material defines to update
  55469. * @param useInstances specifies that instances should be used
  55470. */
  55471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55472. /**
  55473. * Lets the block try to connect some inputs automatically
  55474. * @param material defines the hosting NodeMaterial
  55475. */
  55476. autoConfigure(material: NodeMaterial): void;
  55477. /**
  55478. * Function called when a block is declared as repeatable content generator
  55479. * @param vertexShaderState defines the current compilation state for the vertex shader
  55480. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55481. * @param mesh defines the mesh to be rendered
  55482. * @param defines defines the material defines to update
  55483. */
  55484. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55485. /**
  55486. * Checks if the block is ready
  55487. * @param mesh defines the mesh to be rendered
  55488. * @param nodeMaterial defines the node material requesting the update
  55489. * @param defines defines the material defines to update
  55490. * @param useInstances specifies that instances should be used
  55491. * @returns true if the block is ready
  55492. */
  55493. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55494. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55495. private _processBuild;
  55496. /**
  55497. * Compile the current node and generate the shader code
  55498. * @param state defines the current compilation state (uniforms, samplers, current string)
  55499. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55500. * @returns true if already built
  55501. */
  55502. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55503. protected _inputRename(name: string): string;
  55504. protected _outputRename(name: string): string;
  55505. protected _dumpPropertiesCode(): string;
  55506. /** @hidden */
  55507. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55508. /** @hidden */
  55509. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  55510. /**
  55511. * Clone the current block to a new identical block
  55512. * @param scene defines the hosting scene
  55513. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55514. * @returns a copy of the current block
  55515. */
  55516. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55517. /**
  55518. * Serializes this block in a JSON representation
  55519. * @returns the serialized block object
  55520. */
  55521. serialize(): any;
  55522. /** @hidden */
  55523. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55524. /**
  55525. * Release resources
  55526. */
  55527. dispose(): void;
  55528. }
  55529. }
  55530. declare module BABYLON {
  55531. /**
  55532. * Enum defining the type of animations supported by InputBlock
  55533. */
  55534. export enum AnimatedInputBlockTypes {
  55535. /** No animation */
  55536. None = 0,
  55537. /** Time based animation. Will only work for floats */
  55538. Time = 1
  55539. }
  55540. }
  55541. declare module BABYLON {
  55542. /**
  55543. * Block used to expose an input value
  55544. */
  55545. export class InputBlock extends NodeMaterialBlock {
  55546. private _mode;
  55547. private _associatedVariableName;
  55548. private _storedValue;
  55549. private _valueCallback;
  55550. private _type;
  55551. private _animationType;
  55552. /** Gets or set a value used to limit the range of float values */
  55553. min: number;
  55554. /** Gets or set a value used to limit the range of float values */
  55555. max: number;
  55556. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55557. matrixMode: number;
  55558. /** @hidden */
  55559. _systemValue: Nullable<NodeMaterialSystemValues>;
  55560. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55561. visibleInInspector: boolean;
  55562. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  55563. isConstant: boolean;
  55564. /** Gets or sets the group to use to display this block in the Inspector */
  55565. groupInInspector: string;
  55566. /**
  55567. * Gets or sets the connection point type (default is float)
  55568. */
  55569. readonly type: NodeMaterialBlockConnectionPointTypes;
  55570. /**
  55571. * Creates a new InputBlock
  55572. * @param name defines the block name
  55573. * @param target defines the target of that block (Vertex by default)
  55574. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55575. */
  55576. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55577. /**
  55578. * Gets the output component
  55579. */
  55580. readonly output: NodeMaterialConnectionPoint;
  55581. /**
  55582. * Set the source of this connection point to a vertex attribute
  55583. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55584. * @returns the current connection point
  55585. */
  55586. setAsAttribute(attributeName?: string): InputBlock;
  55587. /**
  55588. * Set the source of this connection point to a system value
  55589. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55590. * @returns the current connection point
  55591. */
  55592. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55593. /**
  55594. * Gets or sets the value of that point.
  55595. * Please note that this value will be ignored if valueCallback is defined
  55596. */
  55597. value: any;
  55598. /**
  55599. * Gets or sets a callback used to get the value of that point.
  55600. * Please note that setting this value will force the connection point to ignore the value property
  55601. */
  55602. valueCallback: () => any;
  55603. /**
  55604. * Gets or sets the associated variable name in the shader
  55605. */
  55606. associatedVariableName: string;
  55607. /** Gets or sets the type of animation applied to the input */
  55608. animationType: AnimatedInputBlockTypes;
  55609. /**
  55610. * Gets a boolean indicating that this connection point not defined yet
  55611. */
  55612. readonly isUndefined: boolean;
  55613. /**
  55614. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55615. * In this case the connection point name must be the name of the uniform to use.
  55616. * Can only be set on inputs
  55617. */
  55618. isUniform: boolean;
  55619. /**
  55620. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55621. * In this case the connection point name must be the name of the attribute to use
  55622. * Can only be set on inputs
  55623. */
  55624. isAttribute: boolean;
  55625. /**
  55626. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55627. * Can only be set on exit points
  55628. */
  55629. isVarying: boolean;
  55630. /**
  55631. * Gets a boolean indicating that the current connection point is a system value
  55632. */
  55633. readonly isSystemValue: boolean;
  55634. /**
  55635. * Gets or sets the current well known value or null if not defined as a system value
  55636. */
  55637. systemValue: Nullable<NodeMaterialSystemValues>;
  55638. /**
  55639. * Gets the current class name
  55640. * @returns the class name
  55641. */
  55642. getClassName(): string;
  55643. /**
  55644. * Animate the input if animationType !== None
  55645. * @param scene defines the rendering scene
  55646. */
  55647. animate(scene: Scene): void;
  55648. private _emitDefine;
  55649. initialize(state: NodeMaterialBuildState): void;
  55650. /**
  55651. * Set the input block to its default value (based on its type)
  55652. */
  55653. setDefaultValue(): void;
  55654. private _emitConstant;
  55655. private _emit;
  55656. /** @hidden */
  55657. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55658. /** @hidden */
  55659. _transmit(effect: Effect, scene: Scene): void;
  55660. protected _buildBlock(state: NodeMaterialBuildState): void;
  55661. protected _dumpPropertiesCode(): string;
  55662. serialize(): any;
  55663. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55664. }
  55665. }
  55666. declare module BABYLON {
  55667. /**
  55668. * Enum used to define the compatibility state between two connection points
  55669. */
  55670. export enum NodeMaterialConnectionPointCompatibilityStates {
  55671. /** Points are compatibles */
  55672. Compatible = 0,
  55673. /** Points are incompatible because of their types */
  55674. TypeIncompatible = 1,
  55675. /** Points are incompatible because of their targets (vertex vs fragment) */
  55676. TargetIncompatible = 2
  55677. }
  55678. /**
  55679. * Defines the direction of a connection point
  55680. */
  55681. export enum NodeMaterialConnectionPointDirection {
  55682. /** Input */
  55683. Input = 0,
  55684. /** Output */
  55685. Output = 1
  55686. }
  55687. /**
  55688. * Defines a connection point for a block
  55689. */
  55690. export class NodeMaterialConnectionPoint {
  55691. /** @hidden */
  55692. _ownerBlock: NodeMaterialBlock;
  55693. /** @hidden */
  55694. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55695. private _endpoints;
  55696. private _associatedVariableName;
  55697. private _direction;
  55698. /** @hidden */
  55699. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55700. /** @hidden */
  55701. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55702. private _type;
  55703. /** @hidden */
  55704. _enforceAssociatedVariableName: boolean;
  55705. /** Gets the direction of the point */
  55706. readonly direction: NodeMaterialConnectionPointDirection;
  55707. /**
  55708. * Gets or sets the additional types supported by this connection point
  55709. */
  55710. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55711. /**
  55712. * Gets or sets the additional types excluded by this connection point
  55713. */
  55714. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55715. /**
  55716. * Observable triggered when this point is connected
  55717. */
  55718. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  55719. /**
  55720. * Gets or sets the associated variable name in the shader
  55721. */
  55722. associatedVariableName: string;
  55723. /**
  55724. * Gets or sets the connection point type (default is float)
  55725. */
  55726. type: NodeMaterialBlockConnectionPointTypes;
  55727. /**
  55728. * Gets or sets the connection point name
  55729. */
  55730. name: string;
  55731. /**
  55732. * Gets or sets a boolean indicating that this connection point can be omitted
  55733. */
  55734. isOptional: boolean;
  55735. /**
  55736. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55737. */
  55738. define: string;
  55739. /** @hidden */
  55740. _prioritizeVertex: boolean;
  55741. private _target;
  55742. /** Gets or sets the target of that connection point */
  55743. target: NodeMaterialBlockTargets;
  55744. /**
  55745. * Gets a boolean indicating that the current point is connected
  55746. */
  55747. readonly isConnected: boolean;
  55748. /**
  55749. * Gets a boolean indicating that the current point is connected to an input block
  55750. */
  55751. readonly isConnectedToInputBlock: boolean;
  55752. /**
  55753. * Gets a the connected input block (if any)
  55754. */
  55755. readonly connectInputBlock: Nullable<InputBlock>;
  55756. /** Get the other side of the connection (if any) */
  55757. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55758. /** Get the block that owns this connection point */
  55759. readonly ownerBlock: NodeMaterialBlock;
  55760. /** Get the block connected on the other side of this connection (if any) */
  55761. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55762. /** Get the block connected on the endpoints of this connection (if any) */
  55763. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55764. /** Gets the list of connected endpoints */
  55765. readonly endpoints: NodeMaterialConnectionPoint[];
  55766. /** Gets a boolean indicating if that output point is connected to at least one input */
  55767. readonly hasEndpoints: boolean;
  55768. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  55769. readonly isConnectedInVertexShader: boolean;
  55770. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  55771. readonly isConnectedInFragmentShader: boolean;
  55772. /**
  55773. * Creates a new connection point
  55774. * @param name defines the connection point name
  55775. * @param ownerBlock defines the block hosting this connection point
  55776. * @param direction defines the direction of the connection point
  55777. */
  55778. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  55779. /**
  55780. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55781. * @returns the class name
  55782. */
  55783. getClassName(): string;
  55784. /**
  55785. * Gets a boolean indicating if the current point can be connected to another point
  55786. * @param connectionPoint defines the other connection point
  55787. * @returns a boolean
  55788. */
  55789. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55790. /**
  55791. * Gets a number indicating if the current point can be connected to another point
  55792. * @param connectionPoint defines the other connection point
  55793. * @returns a number defining the compatibility state
  55794. */
  55795. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  55796. /**
  55797. * Connect this point to another connection point
  55798. * @param connectionPoint defines the other connection point
  55799. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55800. * @returns the current connection point
  55801. */
  55802. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55803. /**
  55804. * Disconnect this point from one of his endpoint
  55805. * @param endpoint defines the other connection point
  55806. * @returns the current connection point
  55807. */
  55808. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55809. /**
  55810. * Serializes this point in a JSON representation
  55811. * @returns the serialized point object
  55812. */
  55813. serialize(): any;
  55814. /**
  55815. * Release resources
  55816. */
  55817. dispose(): void;
  55818. }
  55819. }
  55820. declare module BABYLON {
  55821. /**
  55822. * Block used to add support for vertex skinning (bones)
  55823. */
  55824. export class BonesBlock extends NodeMaterialBlock {
  55825. /**
  55826. * Creates a new BonesBlock
  55827. * @param name defines the block name
  55828. */
  55829. constructor(name: string);
  55830. /**
  55831. * Initialize the block and prepare the context for build
  55832. * @param state defines the state that will be used for the build
  55833. */
  55834. initialize(state: NodeMaterialBuildState): void;
  55835. /**
  55836. * Gets the current class name
  55837. * @returns the class name
  55838. */
  55839. getClassName(): string;
  55840. /**
  55841. * Gets the matrix indices input component
  55842. */
  55843. readonly matricesIndices: NodeMaterialConnectionPoint;
  55844. /**
  55845. * Gets the matrix weights input component
  55846. */
  55847. readonly matricesWeights: NodeMaterialConnectionPoint;
  55848. /**
  55849. * Gets the extra matrix indices input component
  55850. */
  55851. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55852. /**
  55853. * Gets the extra matrix weights input component
  55854. */
  55855. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55856. /**
  55857. * Gets the world input component
  55858. */
  55859. readonly world: NodeMaterialConnectionPoint;
  55860. /**
  55861. * Gets the output component
  55862. */
  55863. readonly output: NodeMaterialConnectionPoint;
  55864. autoConfigure(material: NodeMaterial): void;
  55865. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55866. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55867. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55868. protected _buildBlock(state: NodeMaterialBuildState): this;
  55869. }
  55870. }
  55871. declare module BABYLON {
  55872. /**
  55873. * Block used to add support for instances
  55874. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55875. */
  55876. export class InstancesBlock extends NodeMaterialBlock {
  55877. /**
  55878. * Creates a new InstancesBlock
  55879. * @param name defines the block name
  55880. */
  55881. constructor(name: string);
  55882. /**
  55883. * Gets the current class name
  55884. * @returns the class name
  55885. */
  55886. getClassName(): string;
  55887. /**
  55888. * Gets the first world row input component
  55889. */
  55890. readonly world0: NodeMaterialConnectionPoint;
  55891. /**
  55892. * Gets the second world row input component
  55893. */
  55894. readonly world1: NodeMaterialConnectionPoint;
  55895. /**
  55896. * Gets the third world row input component
  55897. */
  55898. readonly world2: NodeMaterialConnectionPoint;
  55899. /**
  55900. * Gets the forth world row input component
  55901. */
  55902. readonly world3: NodeMaterialConnectionPoint;
  55903. /**
  55904. * Gets the world input component
  55905. */
  55906. readonly world: NodeMaterialConnectionPoint;
  55907. /**
  55908. * Gets the output component
  55909. */
  55910. readonly output: NodeMaterialConnectionPoint;
  55911. autoConfigure(material: NodeMaterial): void;
  55912. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55913. protected _buildBlock(state: NodeMaterialBuildState): this;
  55914. }
  55915. }
  55916. declare module BABYLON {
  55917. /**
  55918. * Block used to add morph targets support to vertex shader
  55919. */
  55920. export class MorphTargetsBlock extends NodeMaterialBlock {
  55921. private _repeatableContentAnchor;
  55922. private _repeatebleContentGenerated;
  55923. /**
  55924. * Create a new MorphTargetsBlock
  55925. * @param name defines the block name
  55926. */
  55927. constructor(name: string);
  55928. /**
  55929. * Gets the current class name
  55930. * @returns the class name
  55931. */
  55932. getClassName(): string;
  55933. /**
  55934. * Gets the position input component
  55935. */
  55936. readonly position: NodeMaterialConnectionPoint;
  55937. /**
  55938. * Gets the normal input component
  55939. */
  55940. readonly normal: NodeMaterialConnectionPoint;
  55941. /**
  55942. * Gets the tangent input component
  55943. */
  55944. readonly tangent: NodeMaterialConnectionPoint;
  55945. /**
  55946. * Gets the tangent input component
  55947. */
  55948. readonly uv: NodeMaterialConnectionPoint;
  55949. /**
  55950. * Gets the position output component
  55951. */
  55952. readonly positionOutput: NodeMaterialConnectionPoint;
  55953. /**
  55954. * Gets the normal output component
  55955. */
  55956. readonly normalOutput: NodeMaterialConnectionPoint;
  55957. /**
  55958. * Gets the tangent output component
  55959. */
  55960. readonly tangentOutput: NodeMaterialConnectionPoint;
  55961. /**
  55962. * Gets the tangent output component
  55963. */
  55964. readonly uvOutput: NodeMaterialConnectionPoint;
  55965. initialize(state: NodeMaterialBuildState): void;
  55966. autoConfigure(material: NodeMaterial): void;
  55967. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55968. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55969. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55970. protected _buildBlock(state: NodeMaterialBuildState): this;
  55971. }
  55972. }
  55973. declare module BABYLON {
  55974. /**
  55975. * Block used to get data information from a light
  55976. */
  55977. export class LightInformationBlock extends NodeMaterialBlock {
  55978. private _lightDataUniformName;
  55979. private _lightColorUniformName;
  55980. private _lightTypeDefineName;
  55981. /**
  55982. * Gets or sets the light associated with this block
  55983. */
  55984. light: Nullable<Light>;
  55985. /**
  55986. * Creates a new LightInformationBlock
  55987. * @param name defines the block name
  55988. */
  55989. constructor(name: string);
  55990. /**
  55991. * Gets the current class name
  55992. * @returns the class name
  55993. */
  55994. getClassName(): string;
  55995. /**
  55996. * Gets the world position input component
  55997. */
  55998. readonly worldPosition: NodeMaterialConnectionPoint;
  55999. /**
  56000. * Gets the direction output component
  56001. */
  56002. readonly direction: NodeMaterialConnectionPoint;
  56003. /**
  56004. * Gets the direction output component
  56005. */
  56006. readonly color: NodeMaterialConnectionPoint;
  56007. /**
  56008. * Gets the direction output component
  56009. */
  56010. readonly intensity: NodeMaterialConnectionPoint;
  56011. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56012. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56013. protected _buildBlock(state: NodeMaterialBuildState): this;
  56014. serialize(): any;
  56015. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56016. }
  56017. }
  56018. declare module BABYLON {
  56019. /**
  56020. * Block used to add image processing support to fragment shader
  56021. */
  56022. export class ImageProcessingBlock extends NodeMaterialBlock {
  56023. /**
  56024. * Create a new ImageProcessingBlock
  56025. * @param name defines the block name
  56026. */
  56027. constructor(name: string);
  56028. /**
  56029. * Gets the current class name
  56030. * @returns the class name
  56031. */
  56032. getClassName(): string;
  56033. /**
  56034. * Gets the color input component
  56035. */
  56036. readonly color: NodeMaterialConnectionPoint;
  56037. /**
  56038. * Gets the output component
  56039. */
  56040. readonly output: NodeMaterialConnectionPoint;
  56041. /**
  56042. * Initialize the block and prepare the context for build
  56043. * @param state defines the state that will be used for the build
  56044. */
  56045. initialize(state: NodeMaterialBuildState): void;
  56046. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56047. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56048. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56049. protected _buildBlock(state: NodeMaterialBuildState): this;
  56050. }
  56051. }
  56052. declare module BABYLON {
  56053. /**
  56054. * Block used to pertub normals based on a normal map
  56055. */
  56056. export class PerturbNormalBlock extends NodeMaterialBlock {
  56057. private _tangentSpaceParameterName;
  56058. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56059. invertX: boolean;
  56060. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56061. invertY: boolean;
  56062. /**
  56063. * Create a new PerturbNormalBlock
  56064. * @param name defines the block name
  56065. */
  56066. constructor(name: string);
  56067. /**
  56068. * Gets the current class name
  56069. * @returns the class name
  56070. */
  56071. getClassName(): string;
  56072. /**
  56073. * Gets the world position input component
  56074. */
  56075. readonly worldPosition: NodeMaterialConnectionPoint;
  56076. /**
  56077. * Gets the world normal input component
  56078. */
  56079. readonly worldNormal: NodeMaterialConnectionPoint;
  56080. /**
  56081. * Gets the uv input component
  56082. */
  56083. readonly uv: NodeMaterialConnectionPoint;
  56084. /**
  56085. * Gets the normal map color input component
  56086. */
  56087. readonly normalMapColor: NodeMaterialConnectionPoint;
  56088. /**
  56089. * Gets the strength input component
  56090. */
  56091. readonly strength: NodeMaterialConnectionPoint;
  56092. /**
  56093. * Gets the output component
  56094. */
  56095. readonly output: NodeMaterialConnectionPoint;
  56096. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56098. autoConfigure(material: NodeMaterial): void;
  56099. protected _buildBlock(state: NodeMaterialBuildState): this;
  56100. protected _dumpPropertiesCode(): string;
  56101. serialize(): any;
  56102. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56103. }
  56104. }
  56105. declare module BABYLON {
  56106. /**
  56107. * Block used to discard a pixel if a value is smaller than a cutoff
  56108. */
  56109. export class DiscardBlock extends NodeMaterialBlock {
  56110. /**
  56111. * Create a new DiscardBlock
  56112. * @param name defines the block name
  56113. */
  56114. constructor(name: string);
  56115. /**
  56116. * Gets the current class name
  56117. * @returns the class name
  56118. */
  56119. getClassName(): string;
  56120. /**
  56121. * Gets the color input component
  56122. */
  56123. readonly value: NodeMaterialConnectionPoint;
  56124. /**
  56125. * Gets the cutoff input component
  56126. */
  56127. readonly cutoff: NodeMaterialConnectionPoint;
  56128. protected _buildBlock(state: NodeMaterialBuildState): this;
  56129. }
  56130. }
  56131. declare module BABYLON {
  56132. /**
  56133. * Block used to test if the fragment shader is front facing
  56134. */
  56135. export class FrontFacingBlock extends NodeMaterialBlock {
  56136. /**
  56137. * Creates a new FrontFacingBlock
  56138. * @param name defines the block name
  56139. */
  56140. constructor(name: string);
  56141. /**
  56142. * Gets the current class name
  56143. * @returns the class name
  56144. */
  56145. getClassName(): string;
  56146. /**
  56147. * Gets the output component
  56148. */
  56149. readonly output: NodeMaterialConnectionPoint;
  56150. protected _buildBlock(state: NodeMaterialBuildState): this;
  56151. }
  56152. }
  56153. declare module BABYLON {
  56154. /**
  56155. * Block used to get the derivative value on x and y of a given input
  56156. */
  56157. export class DerivativeBlock extends NodeMaterialBlock {
  56158. /**
  56159. * Create a new DerivativeBlock
  56160. * @param name defines the block name
  56161. */
  56162. constructor(name: string);
  56163. /**
  56164. * Gets the current class name
  56165. * @returns the class name
  56166. */
  56167. getClassName(): string;
  56168. /**
  56169. * Gets the input component
  56170. */
  56171. readonly input: NodeMaterialConnectionPoint;
  56172. /**
  56173. * Gets the derivative output on x
  56174. */
  56175. readonly dx: NodeMaterialConnectionPoint;
  56176. /**
  56177. * Gets the derivative output on y
  56178. */
  56179. readonly dy: NodeMaterialConnectionPoint;
  56180. protected _buildBlock(state: NodeMaterialBuildState): this;
  56181. }
  56182. }
  56183. declare module BABYLON {
  56184. /**
  56185. * Block used to add support for scene fog
  56186. */
  56187. export class FogBlock extends NodeMaterialBlock {
  56188. private _fogDistanceName;
  56189. private _fogParameters;
  56190. /**
  56191. * Create a new FogBlock
  56192. * @param name defines the block name
  56193. */
  56194. constructor(name: string);
  56195. /**
  56196. * Gets the current class name
  56197. * @returns the class name
  56198. */
  56199. getClassName(): string;
  56200. /**
  56201. * Gets the world position input component
  56202. */
  56203. readonly worldPosition: NodeMaterialConnectionPoint;
  56204. /**
  56205. * Gets the view input component
  56206. */
  56207. readonly view: NodeMaterialConnectionPoint;
  56208. /**
  56209. * Gets the color input component
  56210. */
  56211. readonly input: NodeMaterialConnectionPoint;
  56212. /**
  56213. * Gets the fog color input component
  56214. */
  56215. readonly fogColor: NodeMaterialConnectionPoint;
  56216. /**
  56217. * Gets the output component
  56218. */
  56219. readonly output: NodeMaterialConnectionPoint;
  56220. autoConfigure(material: NodeMaterial): void;
  56221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56222. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56223. protected _buildBlock(state: NodeMaterialBuildState): this;
  56224. }
  56225. }
  56226. declare module BABYLON {
  56227. /**
  56228. * Block used to add light in the fragment shader
  56229. */
  56230. export class LightBlock extends NodeMaterialBlock {
  56231. private _lightId;
  56232. /**
  56233. * Gets or sets the light associated with this block
  56234. */
  56235. light: Nullable<Light>;
  56236. /**
  56237. * Create a new LightBlock
  56238. * @param name defines the block name
  56239. */
  56240. constructor(name: string);
  56241. /**
  56242. * Gets the current class name
  56243. * @returns the class name
  56244. */
  56245. getClassName(): string;
  56246. /**
  56247. * Gets the world position input component
  56248. */
  56249. readonly worldPosition: NodeMaterialConnectionPoint;
  56250. /**
  56251. * Gets the world normal input component
  56252. */
  56253. readonly worldNormal: NodeMaterialConnectionPoint;
  56254. /**
  56255. * Gets the camera (or eye) position component
  56256. */
  56257. readonly cameraPosition: NodeMaterialConnectionPoint;
  56258. /**
  56259. * Gets the glossiness component
  56260. */
  56261. readonly glossiness: NodeMaterialConnectionPoint;
  56262. /**
  56263. * Gets the glossinness power component
  56264. */
  56265. readonly glossPower: NodeMaterialConnectionPoint;
  56266. /**
  56267. * Gets the diffuse color component
  56268. */
  56269. readonly diffuseColor: NodeMaterialConnectionPoint;
  56270. /**
  56271. * Gets the specular color component
  56272. */
  56273. readonly specularColor: NodeMaterialConnectionPoint;
  56274. /**
  56275. * Gets the diffuse output component
  56276. */
  56277. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56278. /**
  56279. * Gets the specular output component
  56280. */
  56281. readonly specularOutput: NodeMaterialConnectionPoint;
  56282. autoConfigure(material: NodeMaterial): void;
  56283. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56284. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56285. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56286. private _injectVertexCode;
  56287. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56288. serialize(): any;
  56289. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56290. }
  56291. }
  56292. declare module BABYLON {
  56293. /**
  56294. * Block used to multiply 2 values
  56295. */
  56296. export class MultiplyBlock extends NodeMaterialBlock {
  56297. /**
  56298. * Creates a new MultiplyBlock
  56299. * @param name defines the block name
  56300. */
  56301. constructor(name: string);
  56302. /**
  56303. * Gets the current class name
  56304. * @returns the class name
  56305. */
  56306. getClassName(): string;
  56307. /**
  56308. * Gets the left operand input component
  56309. */
  56310. readonly left: NodeMaterialConnectionPoint;
  56311. /**
  56312. * Gets the right operand input component
  56313. */
  56314. readonly right: NodeMaterialConnectionPoint;
  56315. /**
  56316. * Gets the output component
  56317. */
  56318. readonly output: NodeMaterialConnectionPoint;
  56319. protected _buildBlock(state: NodeMaterialBuildState): this;
  56320. }
  56321. }
  56322. declare module BABYLON {
  56323. /**
  56324. * Block used to add 2 vectors
  56325. */
  56326. export class AddBlock extends NodeMaterialBlock {
  56327. /**
  56328. * Creates a new AddBlock
  56329. * @param name defines the block name
  56330. */
  56331. constructor(name: string);
  56332. /**
  56333. * Gets the current class name
  56334. * @returns the class name
  56335. */
  56336. getClassName(): string;
  56337. /**
  56338. * Gets the left operand input component
  56339. */
  56340. readonly left: NodeMaterialConnectionPoint;
  56341. /**
  56342. * Gets the right operand input component
  56343. */
  56344. readonly right: NodeMaterialConnectionPoint;
  56345. /**
  56346. * Gets the output component
  56347. */
  56348. readonly output: NodeMaterialConnectionPoint;
  56349. protected _buildBlock(state: NodeMaterialBuildState): this;
  56350. }
  56351. }
  56352. declare module BABYLON {
  56353. /**
  56354. * Block used to scale a vector by a float
  56355. */
  56356. export class ScaleBlock extends NodeMaterialBlock {
  56357. /**
  56358. * Creates a new ScaleBlock
  56359. * @param name defines the block name
  56360. */
  56361. constructor(name: string);
  56362. /**
  56363. * Gets the current class name
  56364. * @returns the class name
  56365. */
  56366. getClassName(): string;
  56367. /**
  56368. * Gets the input component
  56369. */
  56370. readonly input: NodeMaterialConnectionPoint;
  56371. /**
  56372. * Gets the factor input component
  56373. */
  56374. readonly factor: NodeMaterialConnectionPoint;
  56375. /**
  56376. * Gets the output component
  56377. */
  56378. readonly output: NodeMaterialConnectionPoint;
  56379. protected _buildBlock(state: NodeMaterialBuildState): this;
  56380. }
  56381. }
  56382. declare module BABYLON {
  56383. /**
  56384. * Block used to clamp a float
  56385. */
  56386. export class ClampBlock extends NodeMaterialBlock {
  56387. /** Gets or sets the minimum range */
  56388. minimum: number;
  56389. /** Gets or sets the maximum range */
  56390. maximum: number;
  56391. /**
  56392. * Creates a new ClampBlock
  56393. * @param name defines the block name
  56394. */
  56395. constructor(name: string);
  56396. /**
  56397. * Gets the current class name
  56398. * @returns the class name
  56399. */
  56400. getClassName(): string;
  56401. /**
  56402. * Gets the value input component
  56403. */
  56404. readonly value: NodeMaterialConnectionPoint;
  56405. /**
  56406. * Gets the output component
  56407. */
  56408. readonly output: NodeMaterialConnectionPoint;
  56409. protected _buildBlock(state: NodeMaterialBuildState): this;
  56410. protected _dumpPropertiesCode(): string;
  56411. serialize(): any;
  56412. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56413. }
  56414. }
  56415. declare module BABYLON {
  56416. /**
  56417. * Block used to apply a cross product between 2 vectors
  56418. */
  56419. export class CrossBlock extends NodeMaterialBlock {
  56420. /**
  56421. * Creates a new CrossBlock
  56422. * @param name defines the block name
  56423. */
  56424. constructor(name: string);
  56425. /**
  56426. * Gets the current class name
  56427. * @returns the class name
  56428. */
  56429. getClassName(): string;
  56430. /**
  56431. * Gets the left operand input component
  56432. */
  56433. readonly left: NodeMaterialConnectionPoint;
  56434. /**
  56435. * Gets the right operand input component
  56436. */
  56437. readonly right: NodeMaterialConnectionPoint;
  56438. /**
  56439. * Gets the output component
  56440. */
  56441. readonly output: NodeMaterialConnectionPoint;
  56442. protected _buildBlock(state: NodeMaterialBuildState): this;
  56443. }
  56444. }
  56445. declare module BABYLON {
  56446. /**
  56447. * Block used to apply a dot product between 2 vectors
  56448. */
  56449. export class DotBlock extends NodeMaterialBlock {
  56450. /**
  56451. * Creates a new DotBlock
  56452. * @param name defines the block name
  56453. */
  56454. constructor(name: string);
  56455. /**
  56456. * Gets the current class name
  56457. * @returns the class name
  56458. */
  56459. getClassName(): string;
  56460. /**
  56461. * Gets the left operand input component
  56462. */
  56463. readonly left: NodeMaterialConnectionPoint;
  56464. /**
  56465. * Gets the right operand input component
  56466. */
  56467. readonly right: NodeMaterialConnectionPoint;
  56468. /**
  56469. * Gets the output component
  56470. */
  56471. readonly output: NodeMaterialConnectionPoint;
  56472. protected _buildBlock(state: NodeMaterialBuildState): this;
  56473. }
  56474. }
  56475. declare module BABYLON {
  56476. /**
  56477. * Block used to remap a float from a range to a new one
  56478. */
  56479. export class RemapBlock extends NodeMaterialBlock {
  56480. /**
  56481. * Gets or sets the source range
  56482. */
  56483. sourceRange: Vector2;
  56484. /**
  56485. * Gets or sets the target range
  56486. */
  56487. targetRange: Vector2;
  56488. /**
  56489. * Creates a new RemapBlock
  56490. * @param name defines the block name
  56491. */
  56492. constructor(name: string);
  56493. /**
  56494. * Gets the current class name
  56495. * @returns the class name
  56496. */
  56497. getClassName(): string;
  56498. /**
  56499. * Gets the input component
  56500. */
  56501. readonly input: NodeMaterialConnectionPoint;
  56502. /**
  56503. * Gets the source min input component
  56504. */
  56505. readonly sourceMin: NodeMaterialConnectionPoint;
  56506. /**
  56507. * Gets the source max input component
  56508. */
  56509. readonly sourceMax: NodeMaterialConnectionPoint;
  56510. /**
  56511. * Gets the target min input component
  56512. */
  56513. readonly targetMin: NodeMaterialConnectionPoint;
  56514. /**
  56515. * Gets the target max input component
  56516. */
  56517. readonly targetMax: NodeMaterialConnectionPoint;
  56518. /**
  56519. * Gets the output component
  56520. */
  56521. readonly output: NodeMaterialConnectionPoint;
  56522. protected _buildBlock(state: NodeMaterialBuildState): this;
  56523. protected _dumpPropertiesCode(): string;
  56524. serialize(): any;
  56525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56526. }
  56527. }
  56528. declare module BABYLON {
  56529. /**
  56530. * Block used to normalize a vector
  56531. */
  56532. export class NormalizeBlock extends NodeMaterialBlock {
  56533. /**
  56534. * Creates a new NormalizeBlock
  56535. * @param name defines the block name
  56536. */
  56537. constructor(name: string);
  56538. /**
  56539. * Gets the current class name
  56540. * @returns the class name
  56541. */
  56542. getClassName(): string;
  56543. /**
  56544. * Gets the input component
  56545. */
  56546. readonly input: NodeMaterialConnectionPoint;
  56547. /**
  56548. * Gets the output component
  56549. */
  56550. readonly output: NodeMaterialConnectionPoint;
  56551. protected _buildBlock(state: NodeMaterialBuildState): this;
  56552. }
  56553. }
  56554. declare module BABYLON {
  56555. /**
  56556. * Operations supported by the Trigonometry block
  56557. */
  56558. export enum TrigonometryBlockOperations {
  56559. /** Cos */
  56560. Cos = 0,
  56561. /** Sin */
  56562. Sin = 1,
  56563. /** Abs */
  56564. Abs = 2,
  56565. /** Exp */
  56566. Exp = 3,
  56567. /** Exp2 */
  56568. Exp2 = 4,
  56569. /** Round */
  56570. Round = 5,
  56571. /** Floor */
  56572. Floor = 6,
  56573. /** Ceiling */
  56574. Ceiling = 7,
  56575. /** Square root */
  56576. Sqrt = 8,
  56577. /** Log */
  56578. Log = 9,
  56579. /** Tangent */
  56580. Tan = 10,
  56581. /** Arc tangent */
  56582. ArcTan = 11,
  56583. /** Arc cosinus */
  56584. ArcCos = 12,
  56585. /** Arc sinus */
  56586. ArcSin = 13,
  56587. /** Fraction */
  56588. Fract = 14,
  56589. /** Sign */
  56590. Sign = 15,
  56591. /** To radians (from degrees) */
  56592. Radians = 16,
  56593. /** To degrees (from radians) */
  56594. Degrees = 17
  56595. }
  56596. /**
  56597. * Block used to apply trigonometry operation to floats
  56598. */
  56599. export class TrigonometryBlock extends NodeMaterialBlock {
  56600. /**
  56601. * Gets or sets the operation applied by the block
  56602. */
  56603. operation: TrigonometryBlockOperations;
  56604. /**
  56605. * Creates a new TrigonometryBlock
  56606. * @param name defines the block name
  56607. */
  56608. constructor(name: string);
  56609. /**
  56610. * Gets the current class name
  56611. * @returns the class name
  56612. */
  56613. getClassName(): string;
  56614. /**
  56615. * Gets the input component
  56616. */
  56617. readonly input: NodeMaterialConnectionPoint;
  56618. /**
  56619. * Gets the output component
  56620. */
  56621. readonly output: NodeMaterialConnectionPoint;
  56622. protected _buildBlock(state: NodeMaterialBuildState): this;
  56623. serialize(): any;
  56624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56625. protected _dumpPropertiesCode(): string;
  56626. }
  56627. }
  56628. declare module BABYLON {
  56629. /**
  56630. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56631. */
  56632. export class ColorMergerBlock extends NodeMaterialBlock {
  56633. /**
  56634. * Create a new ColorMergerBlock
  56635. * @param name defines the block name
  56636. */
  56637. constructor(name: string);
  56638. /**
  56639. * Gets the current class name
  56640. * @returns the class name
  56641. */
  56642. getClassName(): string;
  56643. /**
  56644. * Gets the rgb component (input)
  56645. */
  56646. readonly rgbIn: NodeMaterialConnectionPoint;
  56647. /**
  56648. * Gets the r component (input)
  56649. */
  56650. readonly r: NodeMaterialConnectionPoint;
  56651. /**
  56652. * Gets the g component (input)
  56653. */
  56654. readonly g: NodeMaterialConnectionPoint;
  56655. /**
  56656. * Gets the b component (input)
  56657. */
  56658. readonly b: NodeMaterialConnectionPoint;
  56659. /**
  56660. * Gets the a component (input)
  56661. */
  56662. readonly a: NodeMaterialConnectionPoint;
  56663. /**
  56664. * Gets the rgba component (output)
  56665. */
  56666. readonly rgba: NodeMaterialConnectionPoint;
  56667. /**
  56668. * Gets the rgb component (output)
  56669. */
  56670. readonly rgbOut: NodeMaterialConnectionPoint;
  56671. /**
  56672. * Gets the rgb component (output)
  56673. * @deprecated Please use rgbOut instead.
  56674. */
  56675. readonly rgb: NodeMaterialConnectionPoint;
  56676. protected _buildBlock(state: NodeMaterialBuildState): this;
  56677. }
  56678. }
  56679. declare module BABYLON {
  56680. /**
  56681. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56682. */
  56683. export class VectorMergerBlock extends NodeMaterialBlock {
  56684. /**
  56685. * Create a new VectorMergerBlock
  56686. * @param name defines the block name
  56687. */
  56688. constructor(name: string);
  56689. /**
  56690. * Gets the current class name
  56691. * @returns the class name
  56692. */
  56693. getClassName(): string;
  56694. /**
  56695. * Gets the xyz component (input)
  56696. */
  56697. readonly xyzIn: NodeMaterialConnectionPoint;
  56698. /**
  56699. * Gets the xy component (input)
  56700. */
  56701. readonly xyIn: NodeMaterialConnectionPoint;
  56702. /**
  56703. * Gets the x component (input)
  56704. */
  56705. readonly x: NodeMaterialConnectionPoint;
  56706. /**
  56707. * Gets the y component (input)
  56708. */
  56709. readonly y: NodeMaterialConnectionPoint;
  56710. /**
  56711. * Gets the z component (input)
  56712. */
  56713. readonly z: NodeMaterialConnectionPoint;
  56714. /**
  56715. * Gets the w component (input)
  56716. */
  56717. readonly w: NodeMaterialConnectionPoint;
  56718. /**
  56719. * Gets the xyzw component (output)
  56720. */
  56721. readonly xyzw: NodeMaterialConnectionPoint;
  56722. /**
  56723. * Gets the xyz component (output)
  56724. */
  56725. readonly xyzOut: NodeMaterialConnectionPoint;
  56726. /**
  56727. * Gets the xy component (output)
  56728. */
  56729. readonly xyOut: NodeMaterialConnectionPoint;
  56730. /**
  56731. * Gets the xy component (output)
  56732. * @deprecated Please use xyOut instead.
  56733. */
  56734. readonly xy: NodeMaterialConnectionPoint;
  56735. /**
  56736. * Gets the xyz component (output)
  56737. * @deprecated Please use xyzOut instead.
  56738. */
  56739. readonly xyz: NodeMaterialConnectionPoint;
  56740. protected _buildBlock(state: NodeMaterialBuildState): this;
  56741. }
  56742. }
  56743. declare module BABYLON {
  56744. /**
  56745. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56746. */
  56747. export class ColorSplitterBlock extends NodeMaterialBlock {
  56748. /**
  56749. * Create a new ColorSplitterBlock
  56750. * @param name defines the block name
  56751. */
  56752. constructor(name: string);
  56753. /**
  56754. * Gets the current class name
  56755. * @returns the class name
  56756. */
  56757. getClassName(): string;
  56758. /**
  56759. * Gets the rgba component (input)
  56760. */
  56761. readonly rgba: NodeMaterialConnectionPoint;
  56762. /**
  56763. * Gets the rgb component (input)
  56764. */
  56765. readonly rgbIn: NodeMaterialConnectionPoint;
  56766. /**
  56767. * Gets the rgb component (output)
  56768. */
  56769. readonly rgbOut: NodeMaterialConnectionPoint;
  56770. /**
  56771. * Gets the r component (output)
  56772. */
  56773. readonly r: NodeMaterialConnectionPoint;
  56774. /**
  56775. * Gets the g component (output)
  56776. */
  56777. readonly g: NodeMaterialConnectionPoint;
  56778. /**
  56779. * Gets the b component (output)
  56780. */
  56781. readonly b: NodeMaterialConnectionPoint;
  56782. /**
  56783. * Gets the a component (output)
  56784. */
  56785. readonly a: NodeMaterialConnectionPoint;
  56786. protected _inputRename(name: string): string;
  56787. protected _outputRename(name: string): string;
  56788. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56789. }
  56790. }
  56791. declare module BABYLON {
  56792. /**
  56793. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56794. */
  56795. export class VectorSplitterBlock extends NodeMaterialBlock {
  56796. /**
  56797. * Create a new VectorSplitterBlock
  56798. * @param name defines the block name
  56799. */
  56800. constructor(name: string);
  56801. /**
  56802. * Gets the current class name
  56803. * @returns the class name
  56804. */
  56805. getClassName(): string;
  56806. /**
  56807. * Gets the xyzw component (input)
  56808. */
  56809. readonly xyzw: NodeMaterialConnectionPoint;
  56810. /**
  56811. * Gets the xyz component (input)
  56812. */
  56813. readonly xyzIn: NodeMaterialConnectionPoint;
  56814. /**
  56815. * Gets the xy component (input)
  56816. */
  56817. readonly xyIn: NodeMaterialConnectionPoint;
  56818. /**
  56819. * Gets the xyz component (output)
  56820. */
  56821. readonly xyzOut: NodeMaterialConnectionPoint;
  56822. /**
  56823. * Gets the xy component (output)
  56824. */
  56825. readonly xyOut: NodeMaterialConnectionPoint;
  56826. /**
  56827. * Gets the x component (output)
  56828. */
  56829. readonly x: NodeMaterialConnectionPoint;
  56830. /**
  56831. * Gets the y component (output)
  56832. */
  56833. readonly y: NodeMaterialConnectionPoint;
  56834. /**
  56835. * Gets the z component (output)
  56836. */
  56837. readonly z: NodeMaterialConnectionPoint;
  56838. /**
  56839. * Gets the w component (output)
  56840. */
  56841. readonly w: NodeMaterialConnectionPoint;
  56842. protected _inputRename(name: string): string;
  56843. protected _outputRename(name: string): string;
  56844. protected _buildBlock(state: NodeMaterialBuildState): this;
  56845. }
  56846. }
  56847. declare module BABYLON {
  56848. /**
  56849. * Block used to lerp between 2 values
  56850. */
  56851. export class LerpBlock extends NodeMaterialBlock {
  56852. /**
  56853. * Creates a new LerpBlock
  56854. * @param name defines the block name
  56855. */
  56856. constructor(name: string);
  56857. /**
  56858. * Gets the current class name
  56859. * @returns the class name
  56860. */
  56861. getClassName(): string;
  56862. /**
  56863. * Gets the left operand input component
  56864. */
  56865. readonly left: NodeMaterialConnectionPoint;
  56866. /**
  56867. * Gets the right operand input component
  56868. */
  56869. readonly right: NodeMaterialConnectionPoint;
  56870. /**
  56871. * Gets the gradient operand input component
  56872. */
  56873. readonly gradient: NodeMaterialConnectionPoint;
  56874. /**
  56875. * Gets the output component
  56876. */
  56877. readonly output: NodeMaterialConnectionPoint;
  56878. protected _buildBlock(state: NodeMaterialBuildState): this;
  56879. }
  56880. }
  56881. declare module BABYLON {
  56882. /**
  56883. * Block used to divide 2 vectors
  56884. */
  56885. export class DivideBlock extends NodeMaterialBlock {
  56886. /**
  56887. * Creates a new DivideBlock
  56888. * @param name defines the block name
  56889. */
  56890. constructor(name: string);
  56891. /**
  56892. * Gets the current class name
  56893. * @returns the class name
  56894. */
  56895. getClassName(): string;
  56896. /**
  56897. * Gets the left operand input component
  56898. */
  56899. readonly left: NodeMaterialConnectionPoint;
  56900. /**
  56901. * Gets the right operand input component
  56902. */
  56903. readonly right: NodeMaterialConnectionPoint;
  56904. /**
  56905. * Gets the output component
  56906. */
  56907. readonly output: NodeMaterialConnectionPoint;
  56908. protected _buildBlock(state: NodeMaterialBuildState): this;
  56909. }
  56910. }
  56911. declare module BABYLON {
  56912. /**
  56913. * Block used to subtract 2 vectors
  56914. */
  56915. export class SubtractBlock extends NodeMaterialBlock {
  56916. /**
  56917. * Creates a new SubtractBlock
  56918. * @param name defines the block name
  56919. */
  56920. constructor(name: string);
  56921. /**
  56922. * Gets the current class name
  56923. * @returns the class name
  56924. */
  56925. getClassName(): string;
  56926. /**
  56927. * Gets the left operand input component
  56928. */
  56929. readonly left: NodeMaterialConnectionPoint;
  56930. /**
  56931. * Gets the right operand input component
  56932. */
  56933. readonly right: NodeMaterialConnectionPoint;
  56934. /**
  56935. * Gets the output component
  56936. */
  56937. readonly output: NodeMaterialConnectionPoint;
  56938. protected _buildBlock(state: NodeMaterialBuildState): this;
  56939. }
  56940. }
  56941. declare module BABYLON {
  56942. /**
  56943. * Block used to step a value
  56944. */
  56945. export class StepBlock extends NodeMaterialBlock {
  56946. /**
  56947. * Creates a new StepBlock
  56948. * @param name defines the block name
  56949. */
  56950. constructor(name: string);
  56951. /**
  56952. * Gets the current class name
  56953. * @returns the class name
  56954. */
  56955. getClassName(): string;
  56956. /**
  56957. * Gets the value operand input component
  56958. */
  56959. readonly value: NodeMaterialConnectionPoint;
  56960. /**
  56961. * Gets the edge operand input component
  56962. */
  56963. readonly edge: NodeMaterialConnectionPoint;
  56964. /**
  56965. * Gets the output component
  56966. */
  56967. readonly output: NodeMaterialConnectionPoint;
  56968. protected _buildBlock(state: NodeMaterialBuildState): this;
  56969. }
  56970. }
  56971. declare module BABYLON {
  56972. /**
  56973. * Block used to get the opposite (1 - x) of a value
  56974. */
  56975. export class OneMinusBlock extends NodeMaterialBlock {
  56976. /**
  56977. * Creates a new OneMinusBlock
  56978. * @param name defines the block name
  56979. */
  56980. constructor(name: string);
  56981. /**
  56982. * Gets the current class name
  56983. * @returns the class name
  56984. */
  56985. getClassName(): string;
  56986. /**
  56987. * Gets the input component
  56988. */
  56989. readonly input: NodeMaterialConnectionPoint;
  56990. /**
  56991. * Gets the output component
  56992. */
  56993. readonly output: NodeMaterialConnectionPoint;
  56994. protected _buildBlock(state: NodeMaterialBuildState): this;
  56995. }
  56996. }
  56997. declare module BABYLON {
  56998. /**
  56999. * Block used to get the view direction
  57000. */
  57001. export class ViewDirectionBlock extends NodeMaterialBlock {
  57002. /**
  57003. * Creates a new ViewDirectionBlock
  57004. * @param name defines the block name
  57005. */
  57006. constructor(name: string);
  57007. /**
  57008. * Gets the current class name
  57009. * @returns the class name
  57010. */
  57011. getClassName(): string;
  57012. /**
  57013. * Gets the world position component
  57014. */
  57015. readonly worldPosition: NodeMaterialConnectionPoint;
  57016. /**
  57017. * Gets the camera position component
  57018. */
  57019. readonly cameraPosition: NodeMaterialConnectionPoint;
  57020. /**
  57021. * Gets the output component
  57022. */
  57023. readonly output: NodeMaterialConnectionPoint;
  57024. autoConfigure(material: NodeMaterial): void;
  57025. protected _buildBlock(state: NodeMaterialBuildState): this;
  57026. }
  57027. }
  57028. declare module BABYLON {
  57029. /**
  57030. * Block used to compute fresnel value
  57031. */
  57032. export class FresnelBlock extends NodeMaterialBlock {
  57033. /**
  57034. * Create a new FresnelBlock
  57035. * @param name defines the block name
  57036. */
  57037. constructor(name: string);
  57038. /**
  57039. * Gets the current class name
  57040. * @returns the class name
  57041. */
  57042. getClassName(): string;
  57043. /**
  57044. * Gets the world normal input component
  57045. */
  57046. readonly worldNormal: NodeMaterialConnectionPoint;
  57047. /**
  57048. * Gets the view direction input component
  57049. */
  57050. readonly viewDirection: NodeMaterialConnectionPoint;
  57051. /**
  57052. * Gets the bias input component
  57053. */
  57054. readonly bias: NodeMaterialConnectionPoint;
  57055. /**
  57056. * Gets the camera (or eye) position component
  57057. */
  57058. readonly power: NodeMaterialConnectionPoint;
  57059. /**
  57060. * Gets the fresnel output component
  57061. */
  57062. readonly fresnel: NodeMaterialConnectionPoint;
  57063. autoConfigure(material: NodeMaterial): void;
  57064. protected _buildBlock(state: NodeMaterialBuildState): this;
  57065. }
  57066. }
  57067. declare module BABYLON {
  57068. /**
  57069. * Block used to get the max of 2 values
  57070. */
  57071. export class MaxBlock extends NodeMaterialBlock {
  57072. /**
  57073. * Creates a new MaxBlock
  57074. * @param name defines the block name
  57075. */
  57076. constructor(name: string);
  57077. /**
  57078. * Gets the current class name
  57079. * @returns the class name
  57080. */
  57081. getClassName(): string;
  57082. /**
  57083. * Gets the left operand input component
  57084. */
  57085. readonly left: NodeMaterialConnectionPoint;
  57086. /**
  57087. * Gets the right operand input component
  57088. */
  57089. readonly right: NodeMaterialConnectionPoint;
  57090. /**
  57091. * Gets the output component
  57092. */
  57093. readonly output: NodeMaterialConnectionPoint;
  57094. protected _buildBlock(state: NodeMaterialBuildState): this;
  57095. }
  57096. }
  57097. declare module BABYLON {
  57098. /**
  57099. * Block used to get the min of 2 values
  57100. */
  57101. export class MinBlock extends NodeMaterialBlock {
  57102. /**
  57103. * Creates a new MinBlock
  57104. * @param name defines the block name
  57105. */
  57106. constructor(name: string);
  57107. /**
  57108. * Gets the current class name
  57109. * @returns the class name
  57110. */
  57111. getClassName(): string;
  57112. /**
  57113. * Gets the left operand input component
  57114. */
  57115. readonly left: NodeMaterialConnectionPoint;
  57116. /**
  57117. * Gets the right operand input component
  57118. */
  57119. readonly right: NodeMaterialConnectionPoint;
  57120. /**
  57121. * Gets the output component
  57122. */
  57123. readonly output: NodeMaterialConnectionPoint;
  57124. protected _buildBlock(state: NodeMaterialBuildState): this;
  57125. }
  57126. }
  57127. declare module BABYLON {
  57128. /**
  57129. * Block used to get the distance between 2 values
  57130. */
  57131. export class DistanceBlock extends NodeMaterialBlock {
  57132. /**
  57133. * Creates a new DistanceBlock
  57134. * @param name defines the block name
  57135. */
  57136. constructor(name: string);
  57137. /**
  57138. * Gets the current class name
  57139. * @returns the class name
  57140. */
  57141. getClassName(): string;
  57142. /**
  57143. * Gets the left operand input component
  57144. */
  57145. readonly left: NodeMaterialConnectionPoint;
  57146. /**
  57147. * Gets the right operand input component
  57148. */
  57149. readonly right: NodeMaterialConnectionPoint;
  57150. /**
  57151. * Gets the output component
  57152. */
  57153. readonly output: NodeMaterialConnectionPoint;
  57154. protected _buildBlock(state: NodeMaterialBuildState): this;
  57155. }
  57156. }
  57157. declare module BABYLON {
  57158. /**
  57159. * Block used to get the length of a vector
  57160. */
  57161. export class LengthBlock extends NodeMaterialBlock {
  57162. /**
  57163. * Creates a new LengthBlock
  57164. * @param name defines the block name
  57165. */
  57166. constructor(name: string);
  57167. /**
  57168. * Gets the current class name
  57169. * @returns the class name
  57170. */
  57171. getClassName(): string;
  57172. /**
  57173. * Gets the value input component
  57174. */
  57175. readonly value: NodeMaterialConnectionPoint;
  57176. /**
  57177. * Gets the output component
  57178. */
  57179. readonly output: NodeMaterialConnectionPoint;
  57180. protected _buildBlock(state: NodeMaterialBuildState): this;
  57181. }
  57182. }
  57183. declare module BABYLON {
  57184. /**
  57185. * Block used to get negative version of a value (i.e. x * -1)
  57186. */
  57187. export class NegateBlock extends NodeMaterialBlock {
  57188. /**
  57189. * Creates a new NegateBlock
  57190. * @param name defines the block name
  57191. */
  57192. constructor(name: string);
  57193. /**
  57194. * Gets the current class name
  57195. * @returns the class name
  57196. */
  57197. getClassName(): string;
  57198. /**
  57199. * Gets the value input component
  57200. */
  57201. readonly value: NodeMaterialConnectionPoint;
  57202. /**
  57203. * Gets the output component
  57204. */
  57205. readonly output: NodeMaterialConnectionPoint;
  57206. protected _buildBlock(state: NodeMaterialBuildState): this;
  57207. }
  57208. }
  57209. declare module BABYLON {
  57210. /**
  57211. * Block used to get the value of the first parameter raised to the power of the second
  57212. */
  57213. export class PowBlock extends NodeMaterialBlock {
  57214. /**
  57215. * Creates a new PowBlock
  57216. * @param name defines the block name
  57217. */
  57218. constructor(name: string);
  57219. /**
  57220. * Gets the current class name
  57221. * @returns the class name
  57222. */
  57223. getClassName(): string;
  57224. /**
  57225. * Gets the value operand input component
  57226. */
  57227. readonly value: NodeMaterialConnectionPoint;
  57228. /**
  57229. * Gets the power operand input component
  57230. */
  57231. readonly power: NodeMaterialConnectionPoint;
  57232. /**
  57233. * Gets the output component
  57234. */
  57235. readonly output: NodeMaterialConnectionPoint;
  57236. protected _buildBlock(state: NodeMaterialBuildState): this;
  57237. }
  57238. }
  57239. declare module BABYLON {
  57240. /**
  57241. * Block used to get a random number
  57242. */
  57243. export class RandomNumberBlock extends NodeMaterialBlock {
  57244. /**
  57245. * Creates a new RandomNumberBlock
  57246. * @param name defines the block name
  57247. */
  57248. constructor(name: string);
  57249. /**
  57250. * Gets the current class name
  57251. * @returns the class name
  57252. */
  57253. getClassName(): string;
  57254. /**
  57255. * Gets the seed input component
  57256. */
  57257. readonly seed: NodeMaterialConnectionPoint;
  57258. /**
  57259. * Gets the output component
  57260. */
  57261. readonly output: NodeMaterialConnectionPoint;
  57262. protected _buildBlock(state: NodeMaterialBuildState): this;
  57263. }
  57264. }
  57265. declare module BABYLON {
  57266. /**
  57267. * Block used to compute arc tangent of 2 values
  57268. */
  57269. export class ArcTan2Block extends NodeMaterialBlock {
  57270. /**
  57271. * Creates a new ArcTan2Block
  57272. * @param name defines the block name
  57273. */
  57274. constructor(name: string);
  57275. /**
  57276. * Gets the current class name
  57277. * @returns the class name
  57278. */
  57279. getClassName(): string;
  57280. /**
  57281. * Gets the x operand input component
  57282. */
  57283. readonly x: NodeMaterialConnectionPoint;
  57284. /**
  57285. * Gets the y operand input component
  57286. */
  57287. readonly y: NodeMaterialConnectionPoint;
  57288. /**
  57289. * Gets the output component
  57290. */
  57291. readonly output: NodeMaterialConnectionPoint;
  57292. protected _buildBlock(state: NodeMaterialBuildState): this;
  57293. }
  57294. }
  57295. declare module BABYLON {
  57296. /**
  57297. * Block used to smooth step a value
  57298. */
  57299. export class SmoothStepBlock extends NodeMaterialBlock {
  57300. /**
  57301. * Creates a new SmoothStepBlock
  57302. * @param name defines the block name
  57303. */
  57304. constructor(name: string);
  57305. /**
  57306. * Gets the current class name
  57307. * @returns the class name
  57308. */
  57309. getClassName(): string;
  57310. /**
  57311. * Gets the value operand input component
  57312. */
  57313. readonly value: NodeMaterialConnectionPoint;
  57314. /**
  57315. * Gets the first edge operand input component
  57316. */
  57317. readonly edge0: NodeMaterialConnectionPoint;
  57318. /**
  57319. * Gets the second edge operand input component
  57320. */
  57321. readonly edge1: NodeMaterialConnectionPoint;
  57322. /**
  57323. * Gets the output component
  57324. */
  57325. readonly output: NodeMaterialConnectionPoint;
  57326. protected _buildBlock(state: NodeMaterialBuildState): this;
  57327. }
  57328. }
  57329. declare module BABYLON {
  57330. /**
  57331. * Block used to get the reciprocal (1 / x) of a value
  57332. */
  57333. export class ReciprocalBlock extends NodeMaterialBlock {
  57334. /**
  57335. * Creates a new ReciprocalBlock
  57336. * @param name defines the block name
  57337. */
  57338. constructor(name: string);
  57339. /**
  57340. * Gets the current class name
  57341. * @returns the class name
  57342. */
  57343. getClassName(): string;
  57344. /**
  57345. * Gets the input component
  57346. */
  57347. readonly input: NodeMaterialConnectionPoint;
  57348. /**
  57349. * Gets the output component
  57350. */
  57351. readonly output: NodeMaterialConnectionPoint;
  57352. protected _buildBlock(state: NodeMaterialBuildState): this;
  57353. }
  57354. }
  57355. declare module BABYLON {
  57356. /**
  57357. * Block used to replace a color by another one
  57358. */
  57359. export class ReplaceColorBlock extends NodeMaterialBlock {
  57360. /**
  57361. * Creates a new ReplaceColorBlock
  57362. * @param name defines the block name
  57363. */
  57364. constructor(name: string);
  57365. /**
  57366. * Gets the current class name
  57367. * @returns the class name
  57368. */
  57369. getClassName(): string;
  57370. /**
  57371. * Gets the value input component
  57372. */
  57373. readonly value: NodeMaterialConnectionPoint;
  57374. /**
  57375. * Gets the reference input component
  57376. */
  57377. readonly reference: NodeMaterialConnectionPoint;
  57378. /**
  57379. * Gets the distance input component
  57380. */
  57381. readonly distance: NodeMaterialConnectionPoint;
  57382. /**
  57383. * Gets the replacement input component
  57384. */
  57385. readonly replacement: NodeMaterialConnectionPoint;
  57386. /**
  57387. * Gets the output component
  57388. */
  57389. readonly output: NodeMaterialConnectionPoint;
  57390. protected _buildBlock(state: NodeMaterialBuildState): this;
  57391. }
  57392. }
  57393. declare module BABYLON {
  57394. /**
  57395. * Block used to posterize a value
  57396. * @see https://en.wikipedia.org/wiki/Posterization
  57397. */
  57398. export class PosterizeBlock extends NodeMaterialBlock {
  57399. /**
  57400. * Creates a new PosterizeBlock
  57401. * @param name defines the block name
  57402. */
  57403. constructor(name: string);
  57404. /**
  57405. * Gets the current class name
  57406. * @returns the class name
  57407. */
  57408. getClassName(): string;
  57409. /**
  57410. * Gets the value input component
  57411. */
  57412. readonly value: NodeMaterialConnectionPoint;
  57413. /**
  57414. * Gets the steps input component
  57415. */
  57416. readonly steps: NodeMaterialConnectionPoint;
  57417. /**
  57418. * Gets the output component
  57419. */
  57420. readonly output: NodeMaterialConnectionPoint;
  57421. protected _buildBlock(state: NodeMaterialBuildState): this;
  57422. }
  57423. }
  57424. declare module BABYLON {
  57425. /**
  57426. * Operations supported by the Wave block
  57427. */
  57428. export enum WaveBlockKind {
  57429. /** SawTooth */
  57430. SawTooth = 0,
  57431. /** Square */
  57432. Square = 1,
  57433. /** Triangle */
  57434. Triangle = 2
  57435. }
  57436. /**
  57437. * Block used to apply wave operation to floats
  57438. */
  57439. export class WaveBlock extends NodeMaterialBlock {
  57440. /**
  57441. * Gets or sets the kibnd of wave to be applied by the block
  57442. */
  57443. kind: WaveBlockKind;
  57444. /**
  57445. * Creates a new WaveBlock
  57446. * @param name defines the block name
  57447. */
  57448. constructor(name: string);
  57449. /**
  57450. * Gets the current class name
  57451. * @returns the class name
  57452. */
  57453. getClassName(): string;
  57454. /**
  57455. * Gets the input component
  57456. */
  57457. readonly input: NodeMaterialConnectionPoint;
  57458. /**
  57459. * Gets the output component
  57460. */
  57461. readonly output: NodeMaterialConnectionPoint;
  57462. protected _buildBlock(state: NodeMaterialBuildState): this;
  57463. serialize(): any;
  57464. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57465. }
  57466. }
  57467. declare module BABYLON {
  57468. /**
  57469. * Class used to store a color step for the GradientBlock
  57470. */
  57471. export class GradientBlockColorStep {
  57472. /**
  57473. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  57474. */
  57475. step: number;
  57476. /**
  57477. * Gets or sets the color associated with this step
  57478. */
  57479. color: Color3;
  57480. /**
  57481. * Creates a new GradientBlockColorStep
  57482. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  57483. * @param color defines the color associated with this step
  57484. */
  57485. constructor(
  57486. /**
  57487. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  57488. */
  57489. step: number,
  57490. /**
  57491. * Gets or sets the color associated with this step
  57492. */
  57493. color: Color3);
  57494. }
  57495. /**
  57496. * Block used to return a color from a gradient based on an input value between 0 and 1
  57497. */
  57498. export class GradientBlock extends NodeMaterialBlock {
  57499. /**
  57500. * Gets or sets the list of color steps
  57501. */
  57502. colorSteps: GradientBlockColorStep[];
  57503. /**
  57504. * Creates a new GradientBlock
  57505. * @param name defines the block name
  57506. */
  57507. constructor(name: string);
  57508. /**
  57509. * Gets the current class name
  57510. * @returns the class name
  57511. */
  57512. getClassName(): string;
  57513. /**
  57514. * Gets the gradient input component
  57515. */
  57516. readonly gradient: NodeMaterialConnectionPoint;
  57517. /**
  57518. * Gets the output component
  57519. */
  57520. readonly output: NodeMaterialConnectionPoint;
  57521. private _writeColorConstant;
  57522. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57523. serialize(): any;
  57524. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57525. protected _dumpPropertiesCode(): string;
  57526. }
  57527. }
  57528. declare module BABYLON {
  57529. /**
  57530. * Block used to normalize lerp between 2 values
  57531. */
  57532. export class NLerpBlock extends NodeMaterialBlock {
  57533. /**
  57534. * Creates a new NLerpBlock
  57535. * @param name defines the block name
  57536. */
  57537. constructor(name: string);
  57538. /**
  57539. * Gets the current class name
  57540. * @returns the class name
  57541. */
  57542. getClassName(): string;
  57543. /**
  57544. * Gets the left operand input component
  57545. */
  57546. readonly left: NodeMaterialConnectionPoint;
  57547. /**
  57548. * Gets the right operand input component
  57549. */
  57550. readonly right: NodeMaterialConnectionPoint;
  57551. /**
  57552. * Gets the gradient operand input component
  57553. */
  57554. readonly gradient: NodeMaterialConnectionPoint;
  57555. /**
  57556. * Gets the output component
  57557. */
  57558. readonly output: NodeMaterialConnectionPoint;
  57559. protected _buildBlock(state: NodeMaterialBuildState): this;
  57560. }
  57561. }
  57562. declare module BABYLON {
  57563. /**
  57564. * block used to Generate a Worley Noise 3D Noise Pattern
  57565. */
  57566. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  57567. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57568. manhattanDistance: boolean;
  57569. /**
  57570. * Creates a new WorleyNoise3DBlock
  57571. * @param name defines the block name
  57572. */
  57573. constructor(name: string);
  57574. /**
  57575. * Gets the current class name
  57576. * @returns the class name
  57577. */
  57578. getClassName(): string;
  57579. /**
  57580. * Gets the seed input component
  57581. */
  57582. readonly seed: NodeMaterialConnectionPoint;
  57583. /**
  57584. * Gets the jitter input component
  57585. */
  57586. readonly jitter: NodeMaterialConnectionPoint;
  57587. /**
  57588. * Gets the output component
  57589. */
  57590. readonly output: NodeMaterialConnectionPoint;
  57591. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57592. /**
  57593. * Exposes the properties to the UI?
  57594. */
  57595. protected _dumpPropertiesCode(): string;
  57596. /**
  57597. * Exposes the properties to the Seralize?
  57598. */
  57599. serialize(): any;
  57600. /**
  57601. * Exposes the properties to the deseralize?
  57602. */
  57603. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57604. }
  57605. }
  57606. declare module BABYLON {
  57607. /**
  57608. * block used to Generate a Simplex Perlin 3d Noise Pattern
  57609. */
  57610. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  57611. /**
  57612. * Creates a new SimplexPerlin3DBlock
  57613. * @param name defines the block name
  57614. */
  57615. constructor(name: string);
  57616. /**
  57617. * Gets the current class name
  57618. * @returns the class name
  57619. */
  57620. getClassName(): string;
  57621. /**
  57622. * Gets the seed operand input component
  57623. */
  57624. readonly seed: NodeMaterialConnectionPoint;
  57625. /**
  57626. * Gets the output component
  57627. */
  57628. readonly output: NodeMaterialConnectionPoint;
  57629. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57630. }
  57631. }
  57632. declare module BABYLON {
  57633. /**
  57634. * Block used to blend normals
  57635. */
  57636. export class NormalBlendBlock extends NodeMaterialBlock {
  57637. /**
  57638. * Creates a new NormalBlendBlock
  57639. * @param name defines the block name
  57640. */
  57641. constructor(name: string);
  57642. /**
  57643. * Gets the current class name
  57644. * @returns the class name
  57645. */
  57646. getClassName(): string;
  57647. /**
  57648. * Gets the first input component
  57649. */
  57650. readonly normalMap0: NodeMaterialConnectionPoint;
  57651. /**
  57652. * Gets the second input component
  57653. */
  57654. readonly normalMap1: NodeMaterialConnectionPoint;
  57655. /**
  57656. * Gets the output component
  57657. */
  57658. readonly output: NodeMaterialConnectionPoint;
  57659. protected _buildBlock(state: NodeMaterialBuildState): this;
  57660. }
  57661. }
  57662. declare module BABYLON {
  57663. /**
  57664. * Block used to rotate a 2d vector by a given angle
  57665. */
  57666. export class Rotate2dBlock extends NodeMaterialBlock {
  57667. /**
  57668. * Creates a new Rotate2dBlock
  57669. * @param name defines the block name
  57670. */
  57671. constructor(name: string);
  57672. /**
  57673. * Gets the current class name
  57674. * @returns the class name
  57675. */
  57676. getClassName(): string;
  57677. /**
  57678. * Gets the input vector
  57679. */
  57680. readonly input: NodeMaterialConnectionPoint;
  57681. /**
  57682. * Gets the input angle
  57683. */
  57684. readonly angle: NodeMaterialConnectionPoint;
  57685. /**
  57686. * Gets the output component
  57687. */
  57688. readonly output: NodeMaterialConnectionPoint;
  57689. autoConfigure(material: NodeMaterial): void;
  57690. protected _buildBlock(state: NodeMaterialBuildState): this;
  57691. }
  57692. }
  57693. declare module BABYLON {
  57694. /**
  57695. * Block used to get the reflected vector from a direction and a normal
  57696. */
  57697. export class ReflectBlock extends NodeMaterialBlock {
  57698. /**
  57699. * Creates a new ReflectBlock
  57700. * @param name defines the block name
  57701. */
  57702. constructor(name: string);
  57703. /**
  57704. * Gets the current class name
  57705. * @returns the class name
  57706. */
  57707. getClassName(): string;
  57708. /**
  57709. * Gets the incident component
  57710. */
  57711. readonly incident: NodeMaterialConnectionPoint;
  57712. /**
  57713. * Gets the normal component
  57714. */
  57715. readonly normal: NodeMaterialConnectionPoint;
  57716. /**
  57717. * Gets the output component
  57718. */
  57719. readonly output: NodeMaterialConnectionPoint;
  57720. protected _buildBlock(state: NodeMaterialBuildState): this;
  57721. }
  57722. }
  57723. declare module BABYLON {
  57724. /**
  57725. * Block used to get the refracted vector from a direction and a normal
  57726. */
  57727. export class RefractBlock extends NodeMaterialBlock {
  57728. /**
  57729. * Creates a new RefractBlock
  57730. * @param name defines the block name
  57731. */
  57732. constructor(name: string);
  57733. /**
  57734. * Gets the current class name
  57735. * @returns the class name
  57736. */
  57737. getClassName(): string;
  57738. /**
  57739. * Gets the incident component
  57740. */
  57741. readonly incident: NodeMaterialConnectionPoint;
  57742. /**
  57743. * Gets the normal component
  57744. */
  57745. readonly normal: NodeMaterialConnectionPoint;
  57746. /**
  57747. * Gets the index of refraction component
  57748. */
  57749. readonly ior: NodeMaterialConnectionPoint;
  57750. /**
  57751. * Gets the output component
  57752. */
  57753. readonly output: NodeMaterialConnectionPoint;
  57754. protected _buildBlock(state: NodeMaterialBuildState): this;
  57755. }
  57756. }
  57757. declare module BABYLON {
  57758. /**
  57759. * Block used to desaturate a color
  57760. */
  57761. export class DesaturateBlock extends NodeMaterialBlock {
  57762. /**
  57763. * Creates a new DesaturateBlock
  57764. * @param name defines the block name
  57765. */
  57766. constructor(name: string);
  57767. /**
  57768. * Gets the current class name
  57769. * @returns the class name
  57770. */
  57771. getClassName(): string;
  57772. /**
  57773. * Gets the color operand input component
  57774. */
  57775. readonly color: NodeMaterialConnectionPoint;
  57776. /**
  57777. * Gets the level operand input component
  57778. */
  57779. readonly level: NodeMaterialConnectionPoint;
  57780. /**
  57781. * Gets the output component
  57782. */
  57783. readonly output: NodeMaterialConnectionPoint;
  57784. protected _buildBlock(state: NodeMaterialBuildState): this;
  57785. }
  57786. }
  57787. declare module BABYLON {
  57788. /**
  57789. * Effect Render Options
  57790. */
  57791. export interface IEffectRendererOptions {
  57792. /**
  57793. * Defines the vertices positions.
  57794. */
  57795. positions?: number[];
  57796. /**
  57797. * Defines the indices.
  57798. */
  57799. indices?: number[];
  57800. }
  57801. /**
  57802. * Helper class to render one or more effects
  57803. */
  57804. export class EffectRenderer {
  57805. private engine;
  57806. private static _DefaultOptions;
  57807. private _vertexBuffers;
  57808. private _indexBuffer;
  57809. private _ringBufferIndex;
  57810. private _ringScreenBuffer;
  57811. private _fullscreenViewport;
  57812. private _getNextFrameBuffer;
  57813. /**
  57814. * Creates an effect renderer
  57815. * @param engine the engine to use for rendering
  57816. * @param options defines the options of the effect renderer
  57817. */
  57818. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  57819. /**
  57820. * Sets the current viewport in normalized coordinates 0-1
  57821. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57822. */
  57823. setViewport(viewport?: Viewport): void;
  57824. /**
  57825. * Binds the embedded attributes buffer to the effect.
  57826. * @param effect Defines the effect to bind the attributes for
  57827. */
  57828. bindBuffers(effect: Effect): void;
  57829. /**
  57830. * Sets the current effect wrapper to use during draw.
  57831. * The effect needs to be ready before calling this api.
  57832. * This also sets the default full screen position attribute.
  57833. * @param effectWrapper Defines the effect to draw with
  57834. */
  57835. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57836. /**
  57837. * Draws a full screen quad.
  57838. */
  57839. draw(): void;
  57840. /**
  57841. * renders one or more effects to a specified texture
  57842. * @param effectWrappers list of effects to renderer
  57843. * @param outputTexture texture to draw to, if null it will render to the screen
  57844. */
  57845. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57846. /**
  57847. * Disposes of the effect renderer
  57848. */
  57849. dispose(): void;
  57850. }
  57851. /**
  57852. * Options to create an EffectWrapper
  57853. */
  57854. interface EffectWrapperCreationOptions {
  57855. /**
  57856. * Engine to use to create the effect
  57857. */
  57858. engine: ThinEngine;
  57859. /**
  57860. * Fragment shader for the effect
  57861. */
  57862. fragmentShader: string;
  57863. /**
  57864. * Vertex shader for the effect
  57865. */
  57866. vertexShader?: string;
  57867. /**
  57868. * Attributes to use in the shader
  57869. */
  57870. attributeNames?: Array<string>;
  57871. /**
  57872. * Uniforms to use in the shader
  57873. */
  57874. uniformNames?: Array<string>;
  57875. /**
  57876. * Texture sampler names to use in the shader
  57877. */
  57878. samplerNames?: Array<string>;
  57879. /**
  57880. * The friendly name of the effect displayed in Spector.
  57881. */
  57882. name?: string;
  57883. }
  57884. /**
  57885. * Wraps an effect to be used for rendering
  57886. */
  57887. export class EffectWrapper {
  57888. /**
  57889. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57890. */
  57891. onApplyObservable: Observable<{}>;
  57892. /**
  57893. * The underlying effect
  57894. */
  57895. effect: Effect;
  57896. /**
  57897. * Creates an effect to be renderer
  57898. * @param creationOptions options to create the effect
  57899. */
  57900. constructor(creationOptions: EffectWrapperCreationOptions);
  57901. /**
  57902. * Disposes of the effect wrapper
  57903. */
  57904. dispose(): void;
  57905. }
  57906. }
  57907. declare module BABYLON {
  57908. /**
  57909. * Helper class to push actions to a pool of workers.
  57910. */
  57911. export class WorkerPool implements IDisposable {
  57912. private _workerInfos;
  57913. private _pendingActions;
  57914. /**
  57915. * Constructor
  57916. * @param workers Array of workers to use for actions
  57917. */
  57918. constructor(workers: Array<Worker>);
  57919. /**
  57920. * Terminates all workers and clears any pending actions.
  57921. */
  57922. dispose(): void;
  57923. /**
  57924. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57925. * pended until a worker has completed its action.
  57926. * @param action The action to perform. Call onComplete when the action is complete.
  57927. */
  57928. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57929. private _execute;
  57930. }
  57931. }
  57932. declare module BABYLON {
  57933. /**
  57934. * Configuration for Draco compression
  57935. */
  57936. export interface IDracoCompressionConfiguration {
  57937. /**
  57938. * Configuration for the decoder.
  57939. */
  57940. decoder: {
  57941. /**
  57942. * The url to the WebAssembly module.
  57943. */
  57944. wasmUrl?: string;
  57945. /**
  57946. * The url to the WebAssembly binary.
  57947. */
  57948. wasmBinaryUrl?: string;
  57949. /**
  57950. * The url to the fallback JavaScript module.
  57951. */
  57952. fallbackUrl?: string;
  57953. };
  57954. }
  57955. /**
  57956. * Draco compression (https://google.github.io/draco/)
  57957. *
  57958. * This class wraps the Draco module.
  57959. *
  57960. * **Encoder**
  57961. *
  57962. * The encoder is not currently implemented.
  57963. *
  57964. * **Decoder**
  57965. *
  57966. * 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.
  57967. *
  57968. * To update the configuration, use the following code:
  57969. * ```javascript
  57970. * DracoCompression.Configuration = {
  57971. * decoder: {
  57972. * wasmUrl: "<url to the WebAssembly library>",
  57973. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57974. * fallbackUrl: "<url to the fallback JavaScript library>",
  57975. * }
  57976. * };
  57977. * ```
  57978. *
  57979. * 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.
  57980. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57981. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57982. *
  57983. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57984. * ```javascript
  57985. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57986. * ```
  57987. *
  57988. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57989. */
  57990. export class DracoCompression implements IDisposable {
  57991. private _workerPoolPromise?;
  57992. private _decoderModulePromise?;
  57993. /**
  57994. * The configuration. Defaults to the following urls:
  57995. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57996. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57997. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57998. */
  57999. static Configuration: IDracoCompressionConfiguration;
  58000. /**
  58001. * Returns true if the decoder configuration is available.
  58002. */
  58003. static readonly DecoderAvailable: boolean;
  58004. /**
  58005. * Default number of workers to create when creating the draco compression object.
  58006. */
  58007. static DefaultNumWorkers: number;
  58008. private static GetDefaultNumWorkers;
  58009. private static _Default;
  58010. /**
  58011. * Default instance for the draco compression object.
  58012. */
  58013. static readonly Default: DracoCompression;
  58014. /**
  58015. * Constructor
  58016. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58017. */
  58018. constructor(numWorkers?: number);
  58019. /**
  58020. * Stop all async operations and release resources.
  58021. */
  58022. dispose(): void;
  58023. /**
  58024. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58025. * @returns a promise that resolves when ready
  58026. */
  58027. whenReadyAsync(): Promise<void>;
  58028. /**
  58029. * Decode Draco compressed mesh data to vertex data.
  58030. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58031. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58032. * @returns A promise that resolves with the decoded vertex data
  58033. */
  58034. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58035. [kind: string]: number;
  58036. }): Promise<VertexData>;
  58037. }
  58038. }
  58039. declare module BABYLON {
  58040. /**
  58041. * Class for building Constructive Solid Geometry
  58042. */
  58043. export class CSG {
  58044. private polygons;
  58045. /**
  58046. * The world matrix
  58047. */
  58048. matrix: Matrix;
  58049. /**
  58050. * Stores the position
  58051. */
  58052. position: Vector3;
  58053. /**
  58054. * Stores the rotation
  58055. */
  58056. rotation: Vector3;
  58057. /**
  58058. * Stores the rotation quaternion
  58059. */
  58060. rotationQuaternion: Nullable<Quaternion>;
  58061. /**
  58062. * Stores the scaling vector
  58063. */
  58064. scaling: Vector3;
  58065. /**
  58066. * Convert the Mesh to CSG
  58067. * @param mesh The Mesh to convert to CSG
  58068. * @returns A new CSG from the Mesh
  58069. */
  58070. static FromMesh(mesh: Mesh): CSG;
  58071. /**
  58072. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58073. * @param polygons Polygons used to construct a CSG solid
  58074. */
  58075. private static FromPolygons;
  58076. /**
  58077. * Clones, or makes a deep copy, of the CSG
  58078. * @returns A new CSG
  58079. */
  58080. clone(): CSG;
  58081. /**
  58082. * Unions this CSG with another CSG
  58083. * @param csg The CSG to union against this CSG
  58084. * @returns The unioned CSG
  58085. */
  58086. union(csg: CSG): CSG;
  58087. /**
  58088. * Unions this CSG with another CSG in place
  58089. * @param csg The CSG to union against this CSG
  58090. */
  58091. unionInPlace(csg: CSG): void;
  58092. /**
  58093. * Subtracts this CSG with another CSG
  58094. * @param csg The CSG to subtract against this CSG
  58095. * @returns A new CSG
  58096. */
  58097. subtract(csg: CSG): CSG;
  58098. /**
  58099. * Subtracts this CSG with another CSG in place
  58100. * @param csg The CSG to subtact against this CSG
  58101. */
  58102. subtractInPlace(csg: CSG): void;
  58103. /**
  58104. * Intersect this CSG with another CSG
  58105. * @param csg The CSG to intersect against this CSG
  58106. * @returns A new CSG
  58107. */
  58108. intersect(csg: CSG): CSG;
  58109. /**
  58110. * Intersects this CSG with another CSG in place
  58111. * @param csg The CSG to intersect against this CSG
  58112. */
  58113. intersectInPlace(csg: CSG): void;
  58114. /**
  58115. * Return a new CSG solid with solid and empty space switched. This solid is
  58116. * not modified.
  58117. * @returns A new CSG solid with solid and empty space switched
  58118. */
  58119. inverse(): CSG;
  58120. /**
  58121. * Inverses the CSG in place
  58122. */
  58123. inverseInPlace(): void;
  58124. /**
  58125. * This is used to keep meshes transformations so they can be restored
  58126. * when we build back a Babylon Mesh
  58127. * NB : All CSG operations are performed in world coordinates
  58128. * @param csg The CSG to copy the transform attributes from
  58129. * @returns This CSG
  58130. */
  58131. copyTransformAttributes(csg: CSG): CSG;
  58132. /**
  58133. * Build Raw mesh from CSG
  58134. * Coordinates here are in world space
  58135. * @param name The name of the mesh geometry
  58136. * @param scene The Scene
  58137. * @param keepSubMeshes Specifies if the submeshes should be kept
  58138. * @returns A new Mesh
  58139. */
  58140. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58141. /**
  58142. * Build Mesh from CSG taking material and transforms into account
  58143. * @param name The name of the Mesh
  58144. * @param material The material of the Mesh
  58145. * @param scene The Scene
  58146. * @param keepSubMeshes Specifies if submeshes should be kept
  58147. * @returns The new Mesh
  58148. */
  58149. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58150. }
  58151. }
  58152. declare module BABYLON {
  58153. /**
  58154. * Class used to create a trail following a mesh
  58155. */
  58156. export class TrailMesh extends Mesh {
  58157. private _generator;
  58158. private _autoStart;
  58159. private _running;
  58160. private _diameter;
  58161. private _length;
  58162. private _sectionPolygonPointsCount;
  58163. private _sectionVectors;
  58164. private _sectionNormalVectors;
  58165. private _beforeRenderObserver;
  58166. /**
  58167. * @constructor
  58168. * @param name The value used by scene.getMeshByName() to do a lookup.
  58169. * @param generator The mesh to generate a trail.
  58170. * @param scene The scene to add this mesh to.
  58171. * @param diameter Diameter of trailing mesh. Default is 1.
  58172. * @param length Length of trailing mesh. Default is 60.
  58173. * @param autoStart Automatically start trailing mesh. Default true.
  58174. */
  58175. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58176. /**
  58177. * "TrailMesh"
  58178. * @returns "TrailMesh"
  58179. */
  58180. getClassName(): string;
  58181. private _createMesh;
  58182. /**
  58183. * Start trailing mesh.
  58184. */
  58185. start(): void;
  58186. /**
  58187. * Stop trailing mesh.
  58188. */
  58189. stop(): void;
  58190. /**
  58191. * Update trailing mesh geometry.
  58192. */
  58193. update(): void;
  58194. /**
  58195. * Returns a new TrailMesh object.
  58196. * @param name is a string, the name given to the new mesh
  58197. * @param newGenerator use new generator object for cloned trail mesh
  58198. * @returns a new mesh
  58199. */
  58200. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58201. /**
  58202. * Serializes this trail mesh
  58203. * @param serializationObject object to write serialization to
  58204. */
  58205. serialize(serializationObject: any): void;
  58206. /**
  58207. * Parses a serialized trail mesh
  58208. * @param parsedMesh the serialized mesh
  58209. * @param scene the scene to create the trail mesh in
  58210. * @returns the created trail mesh
  58211. */
  58212. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58213. }
  58214. }
  58215. declare module BABYLON {
  58216. /**
  58217. * Class containing static functions to help procedurally build meshes
  58218. */
  58219. export class TiledBoxBuilder {
  58220. /**
  58221. * Creates a box mesh
  58222. * 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)
  58223. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58225. * * 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
  58226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58227. * @param name defines the name of the mesh
  58228. * @param options defines the options used to create the mesh
  58229. * @param scene defines the hosting scene
  58230. * @returns the box mesh
  58231. */
  58232. static CreateTiledBox(name: string, options: {
  58233. pattern?: number;
  58234. width?: number;
  58235. height?: number;
  58236. depth?: number;
  58237. tileSize?: number;
  58238. tileWidth?: number;
  58239. tileHeight?: number;
  58240. alignHorizontal?: number;
  58241. alignVertical?: number;
  58242. faceUV?: Vector4[];
  58243. faceColors?: Color4[];
  58244. sideOrientation?: number;
  58245. updatable?: boolean;
  58246. }, scene?: Nullable<Scene>): Mesh;
  58247. }
  58248. }
  58249. declare module BABYLON {
  58250. /**
  58251. * Class containing static functions to help procedurally build meshes
  58252. */
  58253. export class TorusKnotBuilder {
  58254. /**
  58255. * Creates a torus knot mesh
  58256. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58257. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58258. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58259. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58261. * * 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
  58262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58263. * @param name defines the name of the mesh
  58264. * @param options defines the options used to create the mesh
  58265. * @param scene defines the hosting scene
  58266. * @returns the torus knot mesh
  58267. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58268. */
  58269. static CreateTorusKnot(name: string, options: {
  58270. radius?: number;
  58271. tube?: number;
  58272. radialSegments?: number;
  58273. tubularSegments?: number;
  58274. p?: number;
  58275. q?: number;
  58276. updatable?: boolean;
  58277. sideOrientation?: number;
  58278. frontUVs?: Vector4;
  58279. backUVs?: Vector4;
  58280. }, scene: any): Mesh;
  58281. }
  58282. }
  58283. declare module BABYLON {
  58284. /**
  58285. * Polygon
  58286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58287. */
  58288. export class Polygon {
  58289. /**
  58290. * Creates a rectangle
  58291. * @param xmin bottom X coord
  58292. * @param ymin bottom Y coord
  58293. * @param xmax top X coord
  58294. * @param ymax top Y coord
  58295. * @returns points that make the resulting rectation
  58296. */
  58297. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58298. /**
  58299. * Creates a circle
  58300. * @param radius radius of circle
  58301. * @param cx scale in x
  58302. * @param cy scale in y
  58303. * @param numberOfSides number of sides that make up the circle
  58304. * @returns points that make the resulting circle
  58305. */
  58306. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58307. /**
  58308. * Creates a polygon from input string
  58309. * @param input Input polygon data
  58310. * @returns the parsed points
  58311. */
  58312. static Parse(input: string): Vector2[];
  58313. /**
  58314. * Starts building a polygon from x and y coordinates
  58315. * @param x x coordinate
  58316. * @param y y coordinate
  58317. * @returns the started path2
  58318. */
  58319. static StartingAt(x: number, y: number): Path2;
  58320. }
  58321. /**
  58322. * Builds a polygon
  58323. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58324. */
  58325. export class PolygonMeshBuilder {
  58326. private _points;
  58327. private _outlinepoints;
  58328. private _holes;
  58329. private _name;
  58330. private _scene;
  58331. private _epoints;
  58332. private _eholes;
  58333. private _addToepoint;
  58334. /**
  58335. * Babylon reference to the earcut plugin.
  58336. */
  58337. bjsEarcut: any;
  58338. /**
  58339. * Creates a PolygonMeshBuilder
  58340. * @param name name of the builder
  58341. * @param contours Path of the polygon
  58342. * @param scene scene to add to when creating the mesh
  58343. * @param earcutInjection can be used to inject your own earcut reference
  58344. */
  58345. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58346. /**
  58347. * Adds a whole within the polygon
  58348. * @param hole Array of points defining the hole
  58349. * @returns this
  58350. */
  58351. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58352. /**
  58353. * Creates the polygon
  58354. * @param updatable If the mesh should be updatable
  58355. * @param depth The depth of the mesh created
  58356. * @returns the created mesh
  58357. */
  58358. build(updatable?: boolean, depth?: number): Mesh;
  58359. /**
  58360. * Creates the polygon
  58361. * @param depth The depth of the mesh created
  58362. * @returns the created VertexData
  58363. */
  58364. buildVertexData(depth?: number): VertexData;
  58365. /**
  58366. * Adds a side to the polygon
  58367. * @param positions points that make the polygon
  58368. * @param normals normals of the polygon
  58369. * @param uvs uvs of the polygon
  58370. * @param indices indices of the polygon
  58371. * @param bounds bounds of the polygon
  58372. * @param points points of the polygon
  58373. * @param depth depth of the polygon
  58374. * @param flip flip of the polygon
  58375. */
  58376. private addSide;
  58377. }
  58378. }
  58379. declare module BABYLON {
  58380. /**
  58381. * Class containing static functions to help procedurally build meshes
  58382. */
  58383. export class PolygonBuilder {
  58384. /**
  58385. * Creates a polygon mesh
  58386. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58387. * * 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
  58388. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58390. * * 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)
  58391. * * Remember you can only change the shape positions, not their number when updating a polygon
  58392. * @param name defines the name of the mesh
  58393. * @param options defines the options used to create the mesh
  58394. * @param scene defines the hosting scene
  58395. * @param earcutInjection can be used to inject your own earcut reference
  58396. * @returns the polygon mesh
  58397. */
  58398. static CreatePolygon(name: string, options: {
  58399. shape: Vector3[];
  58400. holes?: Vector3[][];
  58401. depth?: number;
  58402. faceUV?: Vector4[];
  58403. faceColors?: Color4[];
  58404. updatable?: boolean;
  58405. sideOrientation?: number;
  58406. frontUVs?: Vector4;
  58407. backUVs?: Vector4;
  58408. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58409. /**
  58410. * Creates an extruded polygon mesh, with depth in the Y direction.
  58411. * * 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)
  58412. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58413. * @param name defines the name of the mesh
  58414. * @param options defines the options used to create the mesh
  58415. * @param scene defines the hosting scene
  58416. * @param earcutInjection can be used to inject your own earcut reference
  58417. * @returns the polygon mesh
  58418. */
  58419. static ExtrudePolygon(name: string, options: {
  58420. shape: Vector3[];
  58421. holes?: Vector3[][];
  58422. depth?: number;
  58423. faceUV?: Vector4[];
  58424. faceColors?: Color4[];
  58425. updatable?: boolean;
  58426. sideOrientation?: number;
  58427. frontUVs?: Vector4;
  58428. backUVs?: Vector4;
  58429. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58430. }
  58431. }
  58432. declare module BABYLON {
  58433. /**
  58434. * Class containing static functions to help procedurally build meshes
  58435. */
  58436. export class LatheBuilder {
  58437. /**
  58438. * Creates lathe mesh.
  58439. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58440. * * 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
  58441. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58442. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58443. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58444. * * 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
  58445. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58446. * * 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
  58447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58448. * * 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
  58449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58451. * @param name defines the name of the mesh
  58452. * @param options defines the options used to create the mesh
  58453. * @param scene defines the hosting scene
  58454. * @returns the lathe mesh
  58455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58456. */
  58457. static CreateLathe(name: string, options: {
  58458. shape: Vector3[];
  58459. radius?: number;
  58460. tessellation?: number;
  58461. clip?: number;
  58462. arc?: number;
  58463. closed?: boolean;
  58464. updatable?: boolean;
  58465. sideOrientation?: number;
  58466. frontUVs?: Vector4;
  58467. backUVs?: Vector4;
  58468. cap?: number;
  58469. invertUV?: boolean;
  58470. }, scene?: Nullable<Scene>): Mesh;
  58471. }
  58472. }
  58473. declare module BABYLON {
  58474. /**
  58475. * Class containing static functions to help procedurally build meshes
  58476. */
  58477. export class TiledPlaneBuilder {
  58478. /**
  58479. * Creates a tiled plane mesh
  58480. * * The parameter `pattern` will, depending on value, do nothing or
  58481. * * * flip (reflect about central vertical) alternate tiles across and up
  58482. * * * flip every tile on alternate rows
  58483. * * * rotate (180 degs) alternate tiles across and up
  58484. * * * rotate every tile on alternate rows
  58485. * * * flip and rotate alternate tiles across and up
  58486. * * * flip and rotate every tile on alternate rows
  58487. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58488. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58489. * * 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
  58490. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58491. * * 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)
  58492. * * 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)
  58493. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58494. * @param name defines the name of the mesh
  58495. * @param options defines the options used to create the mesh
  58496. * @param scene defines the hosting scene
  58497. * @returns the box mesh
  58498. */
  58499. static CreateTiledPlane(name: string, options: {
  58500. pattern?: number;
  58501. tileSize?: number;
  58502. tileWidth?: number;
  58503. tileHeight?: number;
  58504. size?: number;
  58505. width?: number;
  58506. height?: number;
  58507. alignHorizontal?: number;
  58508. alignVertical?: number;
  58509. sideOrientation?: number;
  58510. frontUVs?: Vector4;
  58511. backUVs?: Vector4;
  58512. updatable?: boolean;
  58513. }, scene?: Nullable<Scene>): Mesh;
  58514. }
  58515. }
  58516. declare module BABYLON {
  58517. /**
  58518. * Class containing static functions to help procedurally build meshes
  58519. */
  58520. export class TubeBuilder {
  58521. /**
  58522. * Creates a tube mesh.
  58523. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58524. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58525. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58526. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58527. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58528. * * 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)
  58529. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58530. * * 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
  58531. * * 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
  58532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58533. * * 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
  58534. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58536. * @param name defines the name of the mesh
  58537. * @param options defines the options used to create the mesh
  58538. * @param scene defines the hosting scene
  58539. * @returns the tube mesh
  58540. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58541. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58542. */
  58543. static CreateTube(name: string, options: {
  58544. path: Vector3[];
  58545. radius?: number;
  58546. tessellation?: number;
  58547. radiusFunction?: {
  58548. (i: number, distance: number): number;
  58549. };
  58550. cap?: number;
  58551. arc?: number;
  58552. updatable?: boolean;
  58553. sideOrientation?: number;
  58554. frontUVs?: Vector4;
  58555. backUVs?: Vector4;
  58556. instance?: Mesh;
  58557. invertUV?: boolean;
  58558. }, scene?: Nullable<Scene>): Mesh;
  58559. }
  58560. }
  58561. declare module BABYLON {
  58562. /**
  58563. * Class containing static functions to help procedurally build meshes
  58564. */
  58565. export class IcoSphereBuilder {
  58566. /**
  58567. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58568. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58569. * * 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`)
  58570. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58571. * * 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
  58572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58573. * * 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
  58574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58575. * @param name defines the name of the mesh
  58576. * @param options defines the options used to create the mesh
  58577. * @param scene defines the hosting scene
  58578. * @returns the icosahedron mesh
  58579. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58580. */
  58581. static CreateIcoSphere(name: string, options: {
  58582. radius?: number;
  58583. radiusX?: number;
  58584. radiusY?: number;
  58585. radiusZ?: number;
  58586. flat?: boolean;
  58587. subdivisions?: number;
  58588. sideOrientation?: number;
  58589. frontUVs?: Vector4;
  58590. backUVs?: Vector4;
  58591. updatable?: boolean;
  58592. }, scene?: Nullable<Scene>): Mesh;
  58593. }
  58594. }
  58595. declare module BABYLON {
  58596. /**
  58597. * Class containing static functions to help procedurally build meshes
  58598. */
  58599. export class DecalBuilder {
  58600. /**
  58601. * Creates a decal mesh.
  58602. * 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
  58603. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58604. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58605. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58606. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58607. * @param name defines the name of the mesh
  58608. * @param sourceMesh defines the mesh where the decal must be applied
  58609. * @param options defines the options used to create the mesh
  58610. * @param scene defines the hosting scene
  58611. * @returns the decal mesh
  58612. * @see https://doc.babylonjs.com/how_to/decals
  58613. */
  58614. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58615. position?: Vector3;
  58616. normal?: Vector3;
  58617. size?: Vector3;
  58618. angle?: number;
  58619. }): Mesh;
  58620. }
  58621. }
  58622. declare module BABYLON {
  58623. /**
  58624. * Class containing static functions to help procedurally build meshes
  58625. */
  58626. export class MeshBuilder {
  58627. /**
  58628. * Creates a box mesh
  58629. * * The parameter `size` sets the size (float) of each box side (default 1)
  58630. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58631. * * 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)
  58632. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58634. * * 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
  58635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58636. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58637. * @param name defines the name of the mesh
  58638. * @param options defines the options used to create the mesh
  58639. * @param scene defines the hosting scene
  58640. * @returns the box mesh
  58641. */
  58642. static CreateBox(name: string, options: {
  58643. size?: number;
  58644. width?: number;
  58645. height?: number;
  58646. depth?: number;
  58647. faceUV?: Vector4[];
  58648. faceColors?: Color4[];
  58649. sideOrientation?: number;
  58650. frontUVs?: Vector4;
  58651. backUVs?: Vector4;
  58652. updatable?: boolean;
  58653. }, scene?: Nullable<Scene>): Mesh;
  58654. /**
  58655. * Creates a tiled box mesh
  58656. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58658. * @param name defines the name of the mesh
  58659. * @param options defines the options used to create the mesh
  58660. * @param scene defines the hosting scene
  58661. * @returns the tiled box mesh
  58662. */
  58663. static CreateTiledBox(name: string, options: {
  58664. pattern?: number;
  58665. size?: number;
  58666. width?: number;
  58667. height?: number;
  58668. depth: number;
  58669. tileSize?: number;
  58670. tileWidth?: number;
  58671. tileHeight?: number;
  58672. faceUV?: Vector4[];
  58673. faceColors?: Color4[];
  58674. alignHorizontal?: number;
  58675. alignVertical?: number;
  58676. sideOrientation?: number;
  58677. updatable?: boolean;
  58678. }, scene?: Nullable<Scene>): Mesh;
  58679. /**
  58680. * Creates a sphere mesh
  58681. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58682. * * 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`)
  58683. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58684. * * 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
  58685. * * 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)
  58686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58687. * * 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
  58688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58689. * @param name defines the name of the mesh
  58690. * @param options defines the options used to create the mesh
  58691. * @param scene defines the hosting scene
  58692. * @returns the sphere mesh
  58693. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58694. */
  58695. static CreateSphere(name: string, options: {
  58696. segments?: number;
  58697. diameter?: number;
  58698. diameterX?: number;
  58699. diameterY?: number;
  58700. diameterZ?: number;
  58701. arc?: number;
  58702. slice?: number;
  58703. sideOrientation?: number;
  58704. frontUVs?: Vector4;
  58705. backUVs?: Vector4;
  58706. updatable?: boolean;
  58707. }, scene?: Nullable<Scene>): Mesh;
  58708. /**
  58709. * Creates a plane polygonal mesh. By default, this is a disc
  58710. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58711. * * 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
  58712. * * 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
  58713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58714. * * 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
  58715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58716. * @param name defines the name of the mesh
  58717. * @param options defines the options used to create the mesh
  58718. * @param scene defines the hosting scene
  58719. * @returns the plane polygonal mesh
  58720. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58721. */
  58722. static CreateDisc(name: string, options: {
  58723. radius?: number;
  58724. tessellation?: number;
  58725. arc?: number;
  58726. updatable?: boolean;
  58727. sideOrientation?: number;
  58728. frontUVs?: Vector4;
  58729. backUVs?: Vector4;
  58730. }, scene?: Nullable<Scene>): Mesh;
  58731. /**
  58732. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58733. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58734. * * 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`)
  58735. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58736. * * 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
  58737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58738. * * 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
  58739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58740. * @param name defines the name of the mesh
  58741. * @param options defines the options used to create the mesh
  58742. * @param scene defines the hosting scene
  58743. * @returns the icosahedron mesh
  58744. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58745. */
  58746. static CreateIcoSphere(name: string, options: {
  58747. radius?: number;
  58748. radiusX?: number;
  58749. radiusY?: number;
  58750. radiusZ?: number;
  58751. flat?: boolean;
  58752. subdivisions?: number;
  58753. sideOrientation?: number;
  58754. frontUVs?: Vector4;
  58755. backUVs?: Vector4;
  58756. updatable?: boolean;
  58757. }, scene?: Nullable<Scene>): Mesh;
  58758. /**
  58759. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58760. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58761. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58762. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58763. * * 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
  58764. * * 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
  58765. * * 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
  58766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58767. * * 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
  58768. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58769. * * 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
  58770. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58771. * * 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
  58772. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58774. * @param name defines the name of the mesh
  58775. * @param options defines the options used to create the mesh
  58776. * @param scene defines the hosting scene
  58777. * @returns the ribbon mesh
  58778. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58780. */
  58781. static CreateRibbon(name: string, options: {
  58782. pathArray: Vector3[][];
  58783. closeArray?: boolean;
  58784. closePath?: boolean;
  58785. offset?: number;
  58786. updatable?: boolean;
  58787. sideOrientation?: number;
  58788. frontUVs?: Vector4;
  58789. backUVs?: Vector4;
  58790. instance?: Mesh;
  58791. invertUV?: boolean;
  58792. uvs?: Vector2[];
  58793. colors?: Color4[];
  58794. }, scene?: Nullable<Scene>): Mesh;
  58795. /**
  58796. * Creates a cylinder or a cone mesh
  58797. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58798. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58799. * * 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.
  58800. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58801. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58802. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58803. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58804. * * 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).
  58805. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58806. * * 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).
  58807. * * 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
  58808. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58809. * * 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
  58810. * * 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.
  58811. * * If `enclose` is false, a ring surface is one element.
  58812. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58813. * * 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
  58814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58815. * * 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
  58816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58817. * @param name defines the name of the mesh
  58818. * @param options defines the options used to create the mesh
  58819. * @param scene defines the hosting scene
  58820. * @returns the cylinder mesh
  58821. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58822. */
  58823. static CreateCylinder(name: string, options: {
  58824. height?: number;
  58825. diameterTop?: number;
  58826. diameterBottom?: number;
  58827. diameter?: number;
  58828. tessellation?: number;
  58829. subdivisions?: number;
  58830. arc?: number;
  58831. faceColors?: Color4[];
  58832. faceUV?: Vector4[];
  58833. updatable?: boolean;
  58834. hasRings?: boolean;
  58835. enclose?: boolean;
  58836. cap?: number;
  58837. sideOrientation?: number;
  58838. frontUVs?: Vector4;
  58839. backUVs?: Vector4;
  58840. }, scene?: Nullable<Scene>): Mesh;
  58841. /**
  58842. * Creates a torus mesh
  58843. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58844. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58845. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58847. * * 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
  58848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58849. * @param name defines the name of the mesh
  58850. * @param options defines the options used to create the mesh
  58851. * @param scene defines the hosting scene
  58852. * @returns the torus mesh
  58853. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58854. */
  58855. static CreateTorus(name: string, options: {
  58856. diameter?: number;
  58857. thickness?: number;
  58858. tessellation?: number;
  58859. updatable?: boolean;
  58860. sideOrientation?: number;
  58861. frontUVs?: Vector4;
  58862. backUVs?: Vector4;
  58863. }, scene?: Nullable<Scene>): Mesh;
  58864. /**
  58865. * Creates a torus knot mesh
  58866. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58867. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58868. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58869. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58871. * * 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
  58872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58873. * @param name defines the name of the mesh
  58874. * @param options defines the options used to create the mesh
  58875. * @param scene defines the hosting scene
  58876. * @returns the torus knot mesh
  58877. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58878. */
  58879. static CreateTorusKnot(name: string, options: {
  58880. radius?: number;
  58881. tube?: number;
  58882. radialSegments?: number;
  58883. tubularSegments?: number;
  58884. p?: number;
  58885. q?: number;
  58886. updatable?: boolean;
  58887. sideOrientation?: number;
  58888. frontUVs?: Vector4;
  58889. backUVs?: Vector4;
  58890. }, scene?: Nullable<Scene>): Mesh;
  58891. /**
  58892. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58893. * * 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
  58894. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58895. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58896. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58897. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58898. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58899. * * 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
  58900. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58903. * @param name defines the name of the new line system
  58904. * @param options defines the options used to create the line system
  58905. * @param scene defines the hosting scene
  58906. * @returns a new line system mesh
  58907. */
  58908. static CreateLineSystem(name: string, options: {
  58909. lines: Vector3[][];
  58910. updatable?: boolean;
  58911. instance?: Nullable<LinesMesh>;
  58912. colors?: Nullable<Color4[][]>;
  58913. useVertexAlpha?: boolean;
  58914. }, scene: Nullable<Scene>): LinesMesh;
  58915. /**
  58916. * Creates a line mesh
  58917. * 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
  58918. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58919. * * The parameter `points` is an array successive Vector3
  58920. * * 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
  58921. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58922. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58923. * * When updating an instance, remember that only point positions can change, not the number of points
  58924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58925. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58926. * @param name defines the name of the new line system
  58927. * @param options defines the options used to create the line system
  58928. * @param scene defines the hosting scene
  58929. * @returns a new line mesh
  58930. */
  58931. static CreateLines(name: string, options: {
  58932. points: Vector3[];
  58933. updatable?: boolean;
  58934. instance?: Nullable<LinesMesh>;
  58935. colors?: Color4[];
  58936. useVertexAlpha?: boolean;
  58937. }, scene?: Nullable<Scene>): LinesMesh;
  58938. /**
  58939. * Creates a dashed line mesh
  58940. * * 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
  58941. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58942. * * The parameter `points` is an array successive Vector3
  58943. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58944. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58945. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58946. * * 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
  58947. * * When updating an instance, remember that only point positions can change, not the number of points
  58948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58949. * @param name defines the name of the mesh
  58950. * @param options defines the options used to create the mesh
  58951. * @param scene defines the hosting scene
  58952. * @returns the dashed line mesh
  58953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58954. */
  58955. static CreateDashedLines(name: string, options: {
  58956. points: Vector3[];
  58957. dashSize?: number;
  58958. gapSize?: number;
  58959. dashNb?: number;
  58960. updatable?: boolean;
  58961. instance?: LinesMesh;
  58962. }, scene?: Nullable<Scene>): LinesMesh;
  58963. /**
  58964. * 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.
  58965. * * 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.
  58966. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58967. * * 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.
  58968. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58969. * * 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
  58970. * * 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
  58971. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58973. * * 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
  58974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58976. * @param name defines the name of the mesh
  58977. * @param options defines the options used to create the mesh
  58978. * @param scene defines the hosting scene
  58979. * @returns the extruded shape mesh
  58980. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58982. */
  58983. static ExtrudeShape(name: string, options: {
  58984. shape: Vector3[];
  58985. path: Vector3[];
  58986. scale?: number;
  58987. rotation?: number;
  58988. cap?: number;
  58989. updatable?: boolean;
  58990. sideOrientation?: number;
  58991. frontUVs?: Vector4;
  58992. backUVs?: Vector4;
  58993. instance?: Mesh;
  58994. invertUV?: boolean;
  58995. }, scene?: Nullable<Scene>): Mesh;
  58996. /**
  58997. * Creates an custom extruded shape mesh.
  58998. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58999. * * 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.
  59000. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59001. * * 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
  59002. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59003. * * 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
  59004. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59005. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59006. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59007. * * 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
  59008. * * 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
  59009. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59011. * * 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
  59012. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59014. * @param name defines the name of the mesh
  59015. * @param options defines the options used to create the mesh
  59016. * @param scene defines the hosting scene
  59017. * @returns the custom extruded shape mesh
  59018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59019. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59020. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59021. */
  59022. static ExtrudeShapeCustom(name: string, options: {
  59023. shape: Vector3[];
  59024. path: Vector3[];
  59025. scaleFunction?: any;
  59026. rotationFunction?: any;
  59027. ribbonCloseArray?: boolean;
  59028. ribbonClosePath?: boolean;
  59029. cap?: number;
  59030. updatable?: boolean;
  59031. sideOrientation?: number;
  59032. frontUVs?: Vector4;
  59033. backUVs?: Vector4;
  59034. instance?: Mesh;
  59035. invertUV?: boolean;
  59036. }, scene?: Nullable<Scene>): Mesh;
  59037. /**
  59038. * Creates lathe mesh.
  59039. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59040. * * 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
  59041. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59042. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59043. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59044. * * 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
  59045. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59046. * * 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
  59047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59048. * * 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
  59049. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59051. * @param name defines the name of the mesh
  59052. * @param options defines the options used to create the mesh
  59053. * @param scene defines the hosting scene
  59054. * @returns the lathe mesh
  59055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59056. */
  59057. static CreateLathe(name: string, options: {
  59058. shape: Vector3[];
  59059. radius?: number;
  59060. tessellation?: number;
  59061. clip?: number;
  59062. arc?: number;
  59063. closed?: boolean;
  59064. updatable?: boolean;
  59065. sideOrientation?: number;
  59066. frontUVs?: Vector4;
  59067. backUVs?: Vector4;
  59068. cap?: number;
  59069. invertUV?: boolean;
  59070. }, scene?: Nullable<Scene>): Mesh;
  59071. /**
  59072. * Creates a tiled plane mesh
  59073. * * You can set a limited pattern arrangement with the tiles
  59074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59075. * * 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
  59076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59077. * @param name defines the name of the mesh
  59078. * @param options defines the options used to create the mesh
  59079. * @param scene defines the hosting scene
  59080. * @returns the plane mesh
  59081. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59082. */
  59083. static CreateTiledPlane(name: string, options: {
  59084. pattern?: number;
  59085. tileSize?: number;
  59086. tileWidth?: number;
  59087. tileHeight?: number;
  59088. size?: number;
  59089. width?: number;
  59090. height?: number;
  59091. alignHorizontal?: number;
  59092. alignVertical?: number;
  59093. sideOrientation?: number;
  59094. frontUVs?: Vector4;
  59095. backUVs?: Vector4;
  59096. updatable?: boolean;
  59097. }, scene?: Nullable<Scene>): Mesh;
  59098. /**
  59099. * Creates a plane mesh
  59100. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59101. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59102. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59104. * * 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
  59105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59106. * @param name defines the name of the mesh
  59107. * @param options defines the options used to create the mesh
  59108. * @param scene defines the hosting scene
  59109. * @returns the plane mesh
  59110. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59111. */
  59112. static CreatePlane(name: string, options: {
  59113. size?: number;
  59114. width?: number;
  59115. height?: number;
  59116. sideOrientation?: number;
  59117. frontUVs?: Vector4;
  59118. backUVs?: Vector4;
  59119. updatable?: boolean;
  59120. sourcePlane?: Plane;
  59121. }, scene?: Nullable<Scene>): Mesh;
  59122. /**
  59123. * Creates a ground mesh
  59124. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59125. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59127. * @param name defines the name of the mesh
  59128. * @param options defines the options used to create the mesh
  59129. * @param scene defines the hosting scene
  59130. * @returns the ground mesh
  59131. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59132. */
  59133. static CreateGround(name: string, options: {
  59134. width?: number;
  59135. height?: number;
  59136. subdivisions?: number;
  59137. subdivisionsX?: number;
  59138. subdivisionsY?: number;
  59139. updatable?: boolean;
  59140. }, scene?: Nullable<Scene>): Mesh;
  59141. /**
  59142. * Creates a tiled ground mesh
  59143. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59144. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59145. * * 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
  59146. * * 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
  59147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59148. * @param name defines the name of the mesh
  59149. * @param options defines the options used to create the mesh
  59150. * @param scene defines the hosting scene
  59151. * @returns the tiled ground mesh
  59152. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59153. */
  59154. static CreateTiledGround(name: string, options: {
  59155. xmin: number;
  59156. zmin: number;
  59157. xmax: number;
  59158. zmax: number;
  59159. subdivisions?: {
  59160. w: number;
  59161. h: number;
  59162. };
  59163. precision?: {
  59164. w: number;
  59165. h: number;
  59166. };
  59167. updatable?: boolean;
  59168. }, scene?: Nullable<Scene>): Mesh;
  59169. /**
  59170. * Creates a ground mesh from a height map
  59171. * * The parameter `url` sets the URL of the height map image resource.
  59172. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59173. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59174. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59175. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59176. * * 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.
  59177. * * 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).
  59178. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59180. * @param name defines the name of the mesh
  59181. * @param url defines the url to the height map
  59182. * @param options defines the options used to create the mesh
  59183. * @param scene defines the hosting scene
  59184. * @returns the ground mesh
  59185. * @see https://doc.babylonjs.com/babylon101/height_map
  59186. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59187. */
  59188. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59189. width?: number;
  59190. height?: number;
  59191. subdivisions?: number;
  59192. minHeight?: number;
  59193. maxHeight?: number;
  59194. colorFilter?: Color3;
  59195. alphaFilter?: number;
  59196. updatable?: boolean;
  59197. onReady?: (mesh: GroundMesh) => void;
  59198. }, scene?: Nullable<Scene>): GroundMesh;
  59199. /**
  59200. * Creates a polygon mesh
  59201. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59202. * * 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
  59203. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59205. * * 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)
  59206. * * Remember you can only change the shape positions, not their number when updating a polygon
  59207. * @param name defines the name of the mesh
  59208. * @param options defines the options used to create the mesh
  59209. * @param scene defines the hosting scene
  59210. * @param earcutInjection can be used to inject your own earcut reference
  59211. * @returns the polygon mesh
  59212. */
  59213. static CreatePolygon(name: string, options: {
  59214. shape: Vector3[];
  59215. holes?: Vector3[][];
  59216. depth?: number;
  59217. faceUV?: Vector4[];
  59218. faceColors?: Color4[];
  59219. updatable?: boolean;
  59220. sideOrientation?: number;
  59221. frontUVs?: Vector4;
  59222. backUVs?: Vector4;
  59223. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59224. /**
  59225. * Creates an extruded polygon mesh, with depth in the Y direction.
  59226. * * 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)
  59227. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59228. * @param name defines the name of the mesh
  59229. * @param options defines the options used to create the mesh
  59230. * @param scene defines the hosting scene
  59231. * @param earcutInjection can be used to inject your own earcut reference
  59232. * @returns the polygon mesh
  59233. */
  59234. static ExtrudePolygon(name: string, options: {
  59235. shape: Vector3[];
  59236. holes?: Vector3[][];
  59237. depth?: number;
  59238. faceUV?: Vector4[];
  59239. faceColors?: Color4[];
  59240. updatable?: boolean;
  59241. sideOrientation?: number;
  59242. frontUVs?: Vector4;
  59243. backUVs?: Vector4;
  59244. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59245. /**
  59246. * Creates a tube mesh.
  59247. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59248. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59249. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59250. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59251. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59252. * * 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)
  59253. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59254. * * 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
  59255. * * 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
  59256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59257. * * 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
  59258. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59260. * @param name defines the name of the mesh
  59261. * @param options defines the options used to create the mesh
  59262. * @param scene defines the hosting scene
  59263. * @returns the tube mesh
  59264. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59265. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59266. */
  59267. static CreateTube(name: string, options: {
  59268. path: Vector3[];
  59269. radius?: number;
  59270. tessellation?: number;
  59271. radiusFunction?: {
  59272. (i: number, distance: number): number;
  59273. };
  59274. cap?: number;
  59275. arc?: number;
  59276. updatable?: boolean;
  59277. sideOrientation?: number;
  59278. frontUVs?: Vector4;
  59279. backUVs?: Vector4;
  59280. instance?: Mesh;
  59281. invertUV?: boolean;
  59282. }, scene?: Nullable<Scene>): Mesh;
  59283. /**
  59284. * Creates a polyhedron mesh
  59285. * * 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
  59286. * * The parameter `size` (positive float, default 1) sets the polygon size
  59287. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59288. * * 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`
  59289. * * 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
  59290. * * 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)`)
  59291. * * 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
  59292. * * 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
  59293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59294. * * 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
  59295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59296. * @param name defines the name of the mesh
  59297. * @param options defines the options used to create the mesh
  59298. * @param scene defines the hosting scene
  59299. * @returns the polyhedron mesh
  59300. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59301. */
  59302. static CreatePolyhedron(name: string, options: {
  59303. type?: number;
  59304. size?: number;
  59305. sizeX?: number;
  59306. sizeY?: number;
  59307. sizeZ?: number;
  59308. custom?: any;
  59309. faceUV?: Vector4[];
  59310. faceColors?: Color4[];
  59311. flat?: boolean;
  59312. updatable?: boolean;
  59313. sideOrientation?: number;
  59314. frontUVs?: Vector4;
  59315. backUVs?: Vector4;
  59316. }, scene?: Nullable<Scene>): Mesh;
  59317. /**
  59318. * Creates a decal mesh.
  59319. * 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
  59320. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59321. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59322. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59323. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59324. * @param name defines the name of the mesh
  59325. * @param sourceMesh defines the mesh where the decal must be applied
  59326. * @param options defines the options used to create the mesh
  59327. * @param scene defines the hosting scene
  59328. * @returns the decal mesh
  59329. * @see https://doc.babylonjs.com/how_to/decals
  59330. */
  59331. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59332. position?: Vector3;
  59333. normal?: Vector3;
  59334. size?: Vector3;
  59335. angle?: number;
  59336. }): Mesh;
  59337. }
  59338. }
  59339. declare module BABYLON {
  59340. /**
  59341. * A simplifier interface for future simplification implementations
  59342. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59343. */
  59344. export interface ISimplifier {
  59345. /**
  59346. * Simplification of a given mesh according to the given settings.
  59347. * Since this requires computation, it is assumed that the function runs async.
  59348. * @param settings The settings of the simplification, including quality and distance
  59349. * @param successCallback A callback that will be called after the mesh was simplified.
  59350. * @param errorCallback in case of an error, this callback will be called. optional.
  59351. */
  59352. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59353. }
  59354. /**
  59355. * Expected simplification settings.
  59356. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59357. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59358. */
  59359. export interface ISimplificationSettings {
  59360. /**
  59361. * Gets or sets the expected quality
  59362. */
  59363. quality: number;
  59364. /**
  59365. * Gets or sets the distance when this optimized version should be used
  59366. */
  59367. distance: number;
  59368. /**
  59369. * Gets an already optimized mesh
  59370. */
  59371. optimizeMesh?: boolean;
  59372. }
  59373. /**
  59374. * Class used to specify simplification options
  59375. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59376. */
  59377. export class SimplificationSettings implements ISimplificationSettings {
  59378. /** expected quality */
  59379. quality: number;
  59380. /** distance when this optimized version should be used */
  59381. distance: number;
  59382. /** already optimized mesh */
  59383. optimizeMesh?: boolean | undefined;
  59384. /**
  59385. * Creates a SimplificationSettings
  59386. * @param quality expected quality
  59387. * @param distance distance when this optimized version should be used
  59388. * @param optimizeMesh already optimized mesh
  59389. */
  59390. constructor(
  59391. /** expected quality */
  59392. quality: number,
  59393. /** distance when this optimized version should be used */
  59394. distance: number,
  59395. /** already optimized mesh */
  59396. optimizeMesh?: boolean | undefined);
  59397. }
  59398. /**
  59399. * Interface used to define a simplification task
  59400. */
  59401. export interface ISimplificationTask {
  59402. /**
  59403. * Array of settings
  59404. */
  59405. settings: Array<ISimplificationSettings>;
  59406. /**
  59407. * Simplification type
  59408. */
  59409. simplificationType: SimplificationType;
  59410. /**
  59411. * Mesh to simplify
  59412. */
  59413. mesh: Mesh;
  59414. /**
  59415. * Callback called on success
  59416. */
  59417. successCallback?: () => void;
  59418. /**
  59419. * Defines if parallel processing can be used
  59420. */
  59421. parallelProcessing: boolean;
  59422. }
  59423. /**
  59424. * Queue used to order the simplification tasks
  59425. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59426. */
  59427. export class SimplificationQueue {
  59428. private _simplificationArray;
  59429. /**
  59430. * Gets a boolean indicating that the process is still running
  59431. */
  59432. running: boolean;
  59433. /**
  59434. * Creates a new queue
  59435. */
  59436. constructor();
  59437. /**
  59438. * Adds a new simplification task
  59439. * @param task defines a task to add
  59440. */
  59441. addTask(task: ISimplificationTask): void;
  59442. /**
  59443. * Execute next task
  59444. */
  59445. executeNext(): void;
  59446. /**
  59447. * Execute a simplification task
  59448. * @param task defines the task to run
  59449. */
  59450. runSimplification(task: ISimplificationTask): void;
  59451. private getSimplifier;
  59452. }
  59453. /**
  59454. * The implemented types of simplification
  59455. * At the moment only Quadratic Error Decimation is implemented
  59456. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59457. */
  59458. export enum SimplificationType {
  59459. /** Quadratic error decimation */
  59460. QUADRATIC = 0
  59461. }
  59462. }
  59463. declare module BABYLON {
  59464. interface Scene {
  59465. /** @hidden (Backing field) */
  59466. _simplificationQueue: SimplificationQueue;
  59467. /**
  59468. * Gets or sets the simplification queue attached to the scene
  59469. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59470. */
  59471. simplificationQueue: SimplificationQueue;
  59472. }
  59473. interface Mesh {
  59474. /**
  59475. * Simplify the mesh according to the given array of settings.
  59476. * Function will return immediately and will simplify async
  59477. * @param settings a collection of simplification settings
  59478. * @param parallelProcessing should all levels calculate parallel or one after the other
  59479. * @param simplificationType the type of simplification to run
  59480. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59481. * @returns the current mesh
  59482. */
  59483. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59484. }
  59485. /**
  59486. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59487. * created in a scene
  59488. */
  59489. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59490. /**
  59491. * The component name helpfull to identify the component in the list of scene components.
  59492. */
  59493. readonly name: string;
  59494. /**
  59495. * The scene the component belongs to.
  59496. */
  59497. scene: Scene;
  59498. /**
  59499. * Creates a new instance of the component for the given scene
  59500. * @param scene Defines the scene to register the component in
  59501. */
  59502. constructor(scene: Scene);
  59503. /**
  59504. * Registers the component in a given scene
  59505. */
  59506. register(): void;
  59507. /**
  59508. * Rebuilds the elements related to this component in case of
  59509. * context lost for instance.
  59510. */
  59511. rebuild(): void;
  59512. /**
  59513. * Disposes the component and the associated ressources
  59514. */
  59515. dispose(): void;
  59516. private _beforeCameraUpdate;
  59517. }
  59518. }
  59519. declare module BABYLON {
  59520. /**
  59521. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59522. */
  59523. export interface INavigationEnginePlugin {
  59524. /**
  59525. * plugin name
  59526. */
  59527. name: string;
  59528. /**
  59529. * Creates a navigation mesh
  59530. * @param meshes array of all the geometry used to compute the navigatio mesh
  59531. * @param parameters bunch of parameters used to filter geometry
  59532. */
  59533. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59534. /**
  59535. * Create a navigation mesh debug mesh
  59536. * @param scene is where the mesh will be added
  59537. * @returns debug display mesh
  59538. */
  59539. createDebugNavMesh(scene: Scene): Mesh;
  59540. /**
  59541. * Get a navigation mesh constrained position, closest to the parameter position
  59542. * @param position world position
  59543. * @returns the closest point to position constrained by the navigation mesh
  59544. */
  59545. getClosestPoint(position: Vector3): Vector3;
  59546. /**
  59547. * Get a navigation mesh constrained position, within a particular radius
  59548. * @param position world position
  59549. * @param maxRadius the maximum distance to the constrained world position
  59550. * @returns the closest point to position constrained by the navigation mesh
  59551. */
  59552. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59553. /**
  59554. * Compute the final position from a segment made of destination-position
  59555. * @param position world position
  59556. * @param destination world position
  59557. * @returns the resulting point along the navmesh
  59558. */
  59559. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59560. /**
  59561. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59562. * @param start world position
  59563. * @param end world position
  59564. * @returns array containing world position composing the path
  59565. */
  59566. computePath(start: Vector3, end: Vector3): Vector3[];
  59567. /**
  59568. * If this plugin is supported
  59569. * @returns true if plugin is supported
  59570. */
  59571. isSupported(): boolean;
  59572. /**
  59573. * Create a new Crowd so you can add agents
  59574. * @param maxAgents the maximum agent count in the crowd
  59575. * @param maxAgentRadius the maximum radius an agent can have
  59576. * @param scene to attach the crowd to
  59577. * @returns the crowd you can add agents to
  59578. */
  59579. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59580. /**
  59581. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59582. * The queries will try to find a solution within those bounds
  59583. * default is (1,1,1)
  59584. * @param extent x,y,z value that define the extent around the queries point of reference
  59585. */
  59586. setDefaultQueryExtent(extent: Vector3): void;
  59587. /**
  59588. * Get the Bounding box extent specified by setDefaultQueryExtent
  59589. * @returns the box extent values
  59590. */
  59591. getDefaultQueryExtent(): Vector3;
  59592. /**
  59593. * Release all resources
  59594. */
  59595. dispose(): void;
  59596. }
  59597. /**
  59598. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59599. */
  59600. export interface ICrowd {
  59601. /**
  59602. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59603. * You can attach anything to that node. The node position is updated in the scene update tick.
  59604. * @param pos world position that will be constrained by the navigation mesh
  59605. * @param parameters agent parameters
  59606. * @param transform hooked to the agent that will be update by the scene
  59607. * @returns agent index
  59608. */
  59609. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59610. /**
  59611. * Returns the agent position in world space
  59612. * @param index agent index returned by addAgent
  59613. * @returns world space position
  59614. */
  59615. getAgentPosition(index: number): Vector3;
  59616. /**
  59617. * Gets the agent velocity in world space
  59618. * @param index agent index returned by addAgent
  59619. * @returns world space velocity
  59620. */
  59621. getAgentVelocity(index: number): Vector3;
  59622. /**
  59623. * remove a particular agent previously created
  59624. * @param index agent index returned by addAgent
  59625. */
  59626. removeAgent(index: number): void;
  59627. /**
  59628. * get the list of all agents attached to this crowd
  59629. * @returns list of agent indices
  59630. */
  59631. getAgents(): number[];
  59632. /**
  59633. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59634. * @param deltaTime in seconds
  59635. */
  59636. update(deltaTime: number): void;
  59637. /**
  59638. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59639. * @param index agent index returned by addAgent
  59640. * @param destination targeted world position
  59641. */
  59642. agentGoto(index: number, destination: Vector3): void;
  59643. /**
  59644. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59645. * The queries will try to find a solution within those bounds
  59646. * default is (1,1,1)
  59647. * @param extent x,y,z value that define the extent around the queries point of reference
  59648. */
  59649. setDefaultQueryExtent(extent: Vector3): void;
  59650. /**
  59651. * Get the Bounding box extent specified by setDefaultQueryExtent
  59652. * @returns the box extent values
  59653. */
  59654. getDefaultQueryExtent(): Vector3;
  59655. /**
  59656. * Release all resources
  59657. */
  59658. dispose(): void;
  59659. }
  59660. /**
  59661. * Configures an agent
  59662. */
  59663. export interface IAgentParameters {
  59664. /**
  59665. * Agent radius. [Limit: >= 0]
  59666. */
  59667. radius: number;
  59668. /**
  59669. * Agent height. [Limit: > 0]
  59670. */
  59671. height: number;
  59672. /**
  59673. * Maximum allowed acceleration. [Limit: >= 0]
  59674. */
  59675. maxAcceleration: number;
  59676. /**
  59677. * Maximum allowed speed. [Limit: >= 0]
  59678. */
  59679. maxSpeed: number;
  59680. /**
  59681. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59682. */
  59683. collisionQueryRange: number;
  59684. /**
  59685. * The path visibility optimization range. [Limit: > 0]
  59686. */
  59687. pathOptimizationRange: number;
  59688. /**
  59689. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59690. */
  59691. separationWeight: number;
  59692. }
  59693. /**
  59694. * Configures the navigation mesh creation
  59695. */
  59696. export interface INavMeshParameters {
  59697. /**
  59698. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59699. */
  59700. cs: number;
  59701. /**
  59702. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59703. */
  59704. ch: number;
  59705. /**
  59706. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59707. */
  59708. walkableSlopeAngle: number;
  59709. /**
  59710. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59711. * be considered walkable. [Limit: >= 3] [Units: vx]
  59712. */
  59713. walkableHeight: number;
  59714. /**
  59715. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59716. */
  59717. walkableClimb: number;
  59718. /**
  59719. * The distance to erode/shrink the walkable area of the heightfield away from
  59720. * obstructions. [Limit: >=0] [Units: vx]
  59721. */
  59722. walkableRadius: number;
  59723. /**
  59724. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59725. */
  59726. maxEdgeLen: number;
  59727. /**
  59728. * The maximum distance a simplfied contour's border edges should deviate
  59729. * the original raw contour. [Limit: >=0] [Units: vx]
  59730. */
  59731. maxSimplificationError: number;
  59732. /**
  59733. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59734. */
  59735. minRegionArea: number;
  59736. /**
  59737. * Any regions with a span count smaller than this value will, if possible,
  59738. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59739. */
  59740. mergeRegionArea: number;
  59741. /**
  59742. * The maximum number of vertices allowed for polygons generated during the
  59743. * contour to polygon conversion process. [Limit: >= 3]
  59744. */
  59745. maxVertsPerPoly: number;
  59746. /**
  59747. * Sets the sampling distance to use when generating the detail mesh.
  59748. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59749. */
  59750. detailSampleDist: number;
  59751. /**
  59752. * The maximum distance the detail mesh surface should deviate from heightfield
  59753. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59754. */
  59755. detailSampleMaxError: number;
  59756. }
  59757. }
  59758. declare module BABYLON {
  59759. /**
  59760. * RecastJS navigation plugin
  59761. */
  59762. export class RecastJSPlugin implements INavigationEnginePlugin {
  59763. /**
  59764. * Reference to the Recast library
  59765. */
  59766. bjsRECAST: any;
  59767. /**
  59768. * plugin name
  59769. */
  59770. name: string;
  59771. /**
  59772. * the first navmesh created. We might extend this to support multiple navmeshes
  59773. */
  59774. navMesh: any;
  59775. /**
  59776. * Initializes the recastJS plugin
  59777. * @param recastInjection can be used to inject your own recast reference
  59778. */
  59779. constructor(recastInjection?: any);
  59780. /**
  59781. * Creates a navigation mesh
  59782. * @param meshes array of all the geometry used to compute the navigatio mesh
  59783. * @param parameters bunch of parameters used to filter geometry
  59784. */
  59785. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59786. /**
  59787. * Create a navigation mesh debug mesh
  59788. * @param scene is where the mesh will be added
  59789. * @returns debug display mesh
  59790. */
  59791. createDebugNavMesh(scene: Scene): Mesh;
  59792. /**
  59793. * Get a navigation mesh constrained position, closest to the parameter position
  59794. * @param position world position
  59795. * @returns the closest point to position constrained by the navigation mesh
  59796. */
  59797. getClosestPoint(position: Vector3): Vector3;
  59798. /**
  59799. * Get a navigation mesh constrained position, within a particular radius
  59800. * @param position world position
  59801. * @param maxRadius the maximum distance to the constrained world position
  59802. * @returns the closest point to position constrained by the navigation mesh
  59803. */
  59804. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59805. /**
  59806. * Compute the final position from a segment made of destination-position
  59807. * @param position world position
  59808. * @param destination world position
  59809. * @returns the resulting point along the navmesh
  59810. */
  59811. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59812. /**
  59813. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59814. * @param start world position
  59815. * @param end world position
  59816. * @returns array containing world position composing the path
  59817. */
  59818. computePath(start: Vector3, end: Vector3): Vector3[];
  59819. /**
  59820. * Create a new Crowd so you can add agents
  59821. * @param maxAgents the maximum agent count in the crowd
  59822. * @param maxAgentRadius the maximum radius an agent can have
  59823. * @param scene to attach the crowd to
  59824. * @returns the crowd you can add agents to
  59825. */
  59826. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59827. /**
  59828. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59829. * The queries will try to find a solution within those bounds
  59830. * default is (1,1,1)
  59831. * @param extent x,y,z value that define the extent around the queries point of reference
  59832. */
  59833. setDefaultQueryExtent(extent: Vector3): void;
  59834. /**
  59835. * Get the Bounding box extent specified by setDefaultQueryExtent
  59836. * @returns the box extent values
  59837. */
  59838. getDefaultQueryExtent(): Vector3;
  59839. /**
  59840. * Disposes
  59841. */
  59842. dispose(): void;
  59843. /**
  59844. * If this plugin is supported
  59845. * @returns true if plugin is supported
  59846. */
  59847. isSupported(): boolean;
  59848. }
  59849. /**
  59850. * Recast detour crowd implementation
  59851. */
  59852. export class RecastJSCrowd implements ICrowd {
  59853. /**
  59854. * Recast/detour plugin
  59855. */
  59856. bjsRECASTPlugin: RecastJSPlugin;
  59857. /**
  59858. * Link to the detour crowd
  59859. */
  59860. recastCrowd: any;
  59861. /**
  59862. * One transform per agent
  59863. */
  59864. transforms: TransformNode[];
  59865. /**
  59866. * All agents created
  59867. */
  59868. agents: number[];
  59869. /**
  59870. * Link to the scene is kept to unregister the crowd from the scene
  59871. */
  59872. private _scene;
  59873. /**
  59874. * Observer for crowd updates
  59875. */
  59876. private _onBeforeAnimationsObserver;
  59877. /**
  59878. * Constructor
  59879. * @param plugin recastJS plugin
  59880. * @param maxAgents the maximum agent count in the crowd
  59881. * @param maxAgentRadius the maximum radius an agent can have
  59882. * @param scene to attach the crowd to
  59883. * @returns the crowd you can add agents to
  59884. */
  59885. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59886. /**
  59887. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59888. * You can attach anything to that node. The node position is updated in the scene update tick.
  59889. * @param pos world position that will be constrained by the navigation mesh
  59890. * @param parameters agent parameters
  59891. * @param transform hooked to the agent that will be update by the scene
  59892. * @returns agent index
  59893. */
  59894. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59895. /**
  59896. * Returns the agent position in world space
  59897. * @param index agent index returned by addAgent
  59898. * @returns world space position
  59899. */
  59900. getAgentPosition(index: number): Vector3;
  59901. /**
  59902. * Returns the agent velocity in world space
  59903. * @param index agent index returned by addAgent
  59904. * @returns world space velocity
  59905. */
  59906. getAgentVelocity(index: number): Vector3;
  59907. /**
  59908. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59909. * @param index agent index returned by addAgent
  59910. * @param destination targeted world position
  59911. */
  59912. agentGoto(index: number, destination: Vector3): void;
  59913. /**
  59914. * remove a particular agent previously created
  59915. * @param index agent index returned by addAgent
  59916. */
  59917. removeAgent(index: number): void;
  59918. /**
  59919. * get the list of all agents attached to this crowd
  59920. * @returns list of agent indices
  59921. */
  59922. getAgents(): number[];
  59923. /**
  59924. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59925. * @param deltaTime in seconds
  59926. */
  59927. update(deltaTime: number): void;
  59928. /**
  59929. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59930. * The queries will try to find a solution within those bounds
  59931. * default is (1,1,1)
  59932. * @param extent x,y,z value that define the extent around the queries point of reference
  59933. */
  59934. setDefaultQueryExtent(extent: Vector3): void;
  59935. /**
  59936. * Get the Bounding box extent specified by setDefaultQueryExtent
  59937. * @returns the box extent values
  59938. */
  59939. getDefaultQueryExtent(): Vector3;
  59940. /**
  59941. * Release all resources
  59942. */
  59943. dispose(): void;
  59944. }
  59945. }
  59946. declare module BABYLON {
  59947. /**
  59948. * Class used to enable access to IndexedDB
  59949. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59950. */
  59951. export class Database implements IOfflineProvider {
  59952. private _callbackManifestChecked;
  59953. private _currentSceneUrl;
  59954. private _db;
  59955. private _enableSceneOffline;
  59956. private _enableTexturesOffline;
  59957. private _manifestVersionFound;
  59958. private _mustUpdateRessources;
  59959. private _hasReachedQuota;
  59960. private _isSupported;
  59961. private _idbFactory;
  59962. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59963. private static IsUASupportingBlobStorage;
  59964. /**
  59965. * Gets a boolean indicating if Database storate is enabled (off by default)
  59966. */
  59967. static IDBStorageEnabled: boolean;
  59968. /**
  59969. * Gets a boolean indicating if scene must be saved in the database
  59970. */
  59971. readonly enableSceneOffline: boolean;
  59972. /**
  59973. * Gets a boolean indicating if textures must be saved in the database
  59974. */
  59975. readonly enableTexturesOffline: boolean;
  59976. /**
  59977. * Creates a new Database
  59978. * @param urlToScene defines the url to load the scene
  59979. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59980. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59981. */
  59982. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59983. private static _ParseURL;
  59984. private static _ReturnFullUrlLocation;
  59985. private _checkManifestFile;
  59986. /**
  59987. * Open the database and make it available
  59988. * @param successCallback defines the callback to call on success
  59989. * @param errorCallback defines the callback to call on error
  59990. */
  59991. open(successCallback: () => void, errorCallback: () => void): void;
  59992. /**
  59993. * Loads an image from the database
  59994. * @param url defines the url to load from
  59995. * @param image defines the target DOM image
  59996. */
  59997. loadImage(url: string, image: HTMLImageElement): void;
  59998. private _loadImageFromDBAsync;
  59999. private _saveImageIntoDBAsync;
  60000. private _checkVersionFromDB;
  60001. private _loadVersionFromDBAsync;
  60002. private _saveVersionIntoDBAsync;
  60003. /**
  60004. * Loads a file from database
  60005. * @param url defines the URL to load from
  60006. * @param sceneLoaded defines a callback to call on success
  60007. * @param progressCallBack defines a callback to call when progress changed
  60008. * @param errorCallback defines a callback to call on error
  60009. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60010. */
  60011. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60012. private _loadFileAsync;
  60013. private _saveFileAsync;
  60014. /**
  60015. * Validates if xhr data is correct
  60016. * @param xhr defines the request to validate
  60017. * @param dataType defines the expected data type
  60018. * @returns true if data is correct
  60019. */
  60020. private static _ValidateXHRData;
  60021. }
  60022. }
  60023. declare module BABYLON {
  60024. /** @hidden */
  60025. export var gpuUpdateParticlesPixelShader: {
  60026. name: string;
  60027. shader: string;
  60028. };
  60029. }
  60030. declare module BABYLON {
  60031. /** @hidden */
  60032. export var gpuUpdateParticlesVertexShader: {
  60033. name: string;
  60034. shader: string;
  60035. };
  60036. }
  60037. declare module BABYLON {
  60038. /** @hidden */
  60039. export var clipPlaneFragmentDeclaration2: {
  60040. name: string;
  60041. shader: string;
  60042. };
  60043. }
  60044. declare module BABYLON {
  60045. /** @hidden */
  60046. export var gpuRenderParticlesPixelShader: {
  60047. name: string;
  60048. shader: string;
  60049. };
  60050. }
  60051. declare module BABYLON {
  60052. /** @hidden */
  60053. export var clipPlaneVertexDeclaration2: {
  60054. name: string;
  60055. shader: string;
  60056. };
  60057. }
  60058. declare module BABYLON {
  60059. /** @hidden */
  60060. export var gpuRenderParticlesVertexShader: {
  60061. name: string;
  60062. shader: string;
  60063. };
  60064. }
  60065. declare module BABYLON {
  60066. /**
  60067. * This represents a GPU particle system in Babylon
  60068. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60069. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60070. */
  60071. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60072. /**
  60073. * The layer mask we are rendering the particles through.
  60074. */
  60075. layerMask: number;
  60076. private _capacity;
  60077. private _activeCount;
  60078. private _currentActiveCount;
  60079. private _accumulatedCount;
  60080. private _renderEffect;
  60081. private _updateEffect;
  60082. private _buffer0;
  60083. private _buffer1;
  60084. private _spriteBuffer;
  60085. private _updateVAO;
  60086. private _renderVAO;
  60087. private _targetIndex;
  60088. private _sourceBuffer;
  60089. private _targetBuffer;
  60090. private _engine;
  60091. private _currentRenderId;
  60092. private _started;
  60093. private _stopped;
  60094. private _timeDelta;
  60095. private _randomTexture;
  60096. private _randomTexture2;
  60097. private _attributesStrideSize;
  60098. private _updateEffectOptions;
  60099. private _randomTextureSize;
  60100. private _actualFrame;
  60101. private readonly _rawTextureWidth;
  60102. /**
  60103. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60104. */
  60105. static readonly IsSupported: boolean;
  60106. /**
  60107. * An event triggered when the system is disposed.
  60108. */
  60109. onDisposeObservable: Observable<GPUParticleSystem>;
  60110. /**
  60111. * Gets the maximum number of particles active at the same time.
  60112. * @returns The max number of active particles.
  60113. */
  60114. getCapacity(): number;
  60115. /**
  60116. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60117. * to override the particles.
  60118. */
  60119. forceDepthWrite: boolean;
  60120. /**
  60121. * Gets or set the number of active particles
  60122. */
  60123. activeParticleCount: number;
  60124. private _preWarmDone;
  60125. /**
  60126. * Is this system ready to be used/rendered
  60127. * @return true if the system is ready
  60128. */
  60129. isReady(): boolean;
  60130. /**
  60131. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60132. * @returns True if it has been started, otherwise false.
  60133. */
  60134. isStarted(): boolean;
  60135. /**
  60136. * Starts the particle system and begins to emit
  60137. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60138. */
  60139. start(delay?: number): void;
  60140. /**
  60141. * Stops the particle system.
  60142. */
  60143. stop(): void;
  60144. /**
  60145. * Remove all active particles
  60146. */
  60147. reset(): void;
  60148. /**
  60149. * Returns the string "GPUParticleSystem"
  60150. * @returns a string containing the class name
  60151. */
  60152. getClassName(): string;
  60153. private _colorGradientsTexture;
  60154. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60155. /**
  60156. * Adds a new color gradient
  60157. * @param gradient defines the gradient to use (between 0 and 1)
  60158. * @param color1 defines the color to affect to the specified gradient
  60159. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60160. * @returns the current particle system
  60161. */
  60162. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60163. /**
  60164. * Remove a specific color gradient
  60165. * @param gradient defines the gradient to remove
  60166. * @returns the current particle system
  60167. */
  60168. removeColorGradient(gradient: number): GPUParticleSystem;
  60169. private _angularSpeedGradientsTexture;
  60170. private _sizeGradientsTexture;
  60171. private _velocityGradientsTexture;
  60172. private _limitVelocityGradientsTexture;
  60173. private _dragGradientsTexture;
  60174. private _addFactorGradient;
  60175. /**
  60176. * Adds a new size gradient
  60177. * @param gradient defines the gradient to use (between 0 and 1)
  60178. * @param factor defines the size factor to affect to the specified gradient
  60179. * @returns the current particle system
  60180. */
  60181. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60182. /**
  60183. * Remove a specific size gradient
  60184. * @param gradient defines the gradient to remove
  60185. * @returns the current particle system
  60186. */
  60187. removeSizeGradient(gradient: number): GPUParticleSystem;
  60188. /**
  60189. * Adds a new angular speed gradient
  60190. * @param gradient defines the gradient to use (between 0 and 1)
  60191. * @param factor defines the angular speed to affect to the specified gradient
  60192. * @returns the current particle system
  60193. */
  60194. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60195. /**
  60196. * Remove a specific angular speed gradient
  60197. * @param gradient defines the gradient to remove
  60198. * @returns the current particle system
  60199. */
  60200. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60201. /**
  60202. * Adds a new velocity gradient
  60203. * @param gradient defines the gradient to use (between 0 and 1)
  60204. * @param factor defines the velocity to affect to the specified gradient
  60205. * @returns the current particle system
  60206. */
  60207. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60208. /**
  60209. * Remove a specific velocity gradient
  60210. * @param gradient defines the gradient to remove
  60211. * @returns the current particle system
  60212. */
  60213. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60214. /**
  60215. * Adds a new limit velocity gradient
  60216. * @param gradient defines the gradient to use (between 0 and 1)
  60217. * @param factor defines the limit velocity value to affect to the specified gradient
  60218. * @returns the current particle system
  60219. */
  60220. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60221. /**
  60222. * Remove a specific limit velocity gradient
  60223. * @param gradient defines the gradient to remove
  60224. * @returns the current particle system
  60225. */
  60226. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60227. /**
  60228. * Adds a new drag gradient
  60229. * @param gradient defines the gradient to use (between 0 and 1)
  60230. * @param factor defines the drag value to affect to the specified gradient
  60231. * @returns the current particle system
  60232. */
  60233. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60234. /**
  60235. * Remove a specific drag gradient
  60236. * @param gradient defines the gradient to remove
  60237. * @returns the current particle system
  60238. */
  60239. removeDragGradient(gradient: number): GPUParticleSystem;
  60240. /**
  60241. * Not supported by GPUParticleSystem
  60242. * @param gradient defines the gradient to use (between 0 and 1)
  60243. * @param factor defines the emit rate value to affect to the specified gradient
  60244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60245. * @returns the current particle system
  60246. */
  60247. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60248. /**
  60249. * Not supported by GPUParticleSystem
  60250. * @param gradient defines the gradient to remove
  60251. * @returns the current particle system
  60252. */
  60253. removeEmitRateGradient(gradient: number): IParticleSystem;
  60254. /**
  60255. * Not supported by GPUParticleSystem
  60256. * @param gradient defines the gradient to use (between 0 and 1)
  60257. * @param factor defines the start size value to affect to the specified gradient
  60258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60259. * @returns the current particle system
  60260. */
  60261. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60262. /**
  60263. * Not supported by GPUParticleSystem
  60264. * @param gradient defines the gradient to remove
  60265. * @returns the current particle system
  60266. */
  60267. removeStartSizeGradient(gradient: number): IParticleSystem;
  60268. /**
  60269. * Not supported by GPUParticleSystem
  60270. * @param gradient defines the gradient to use (between 0 and 1)
  60271. * @param min defines the color remap minimal range
  60272. * @param max defines the color remap maximal range
  60273. * @returns the current particle system
  60274. */
  60275. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60276. /**
  60277. * Not supported by GPUParticleSystem
  60278. * @param gradient defines the gradient to remove
  60279. * @returns the current particle system
  60280. */
  60281. removeColorRemapGradient(): IParticleSystem;
  60282. /**
  60283. * Not supported by GPUParticleSystem
  60284. * @param gradient defines the gradient to use (between 0 and 1)
  60285. * @param min defines the alpha remap minimal range
  60286. * @param max defines the alpha remap maximal range
  60287. * @returns the current particle system
  60288. */
  60289. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60290. /**
  60291. * Not supported by GPUParticleSystem
  60292. * @param gradient defines the gradient to remove
  60293. * @returns the current particle system
  60294. */
  60295. removeAlphaRemapGradient(): IParticleSystem;
  60296. /**
  60297. * Not supported by GPUParticleSystem
  60298. * @param gradient defines the gradient to use (between 0 and 1)
  60299. * @param color defines the color to affect to the specified gradient
  60300. * @returns the current particle system
  60301. */
  60302. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60303. /**
  60304. * Not supported by GPUParticleSystem
  60305. * @param gradient defines the gradient to remove
  60306. * @returns the current particle system
  60307. */
  60308. removeRampGradient(): IParticleSystem;
  60309. /**
  60310. * Not supported by GPUParticleSystem
  60311. * @returns the list of ramp gradients
  60312. */
  60313. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60314. /**
  60315. * Not supported by GPUParticleSystem
  60316. * Gets or sets a boolean indicating that ramp gradients must be used
  60317. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60318. */
  60319. useRampGradients: boolean;
  60320. /**
  60321. * Not supported by GPUParticleSystem
  60322. * @param gradient defines the gradient to use (between 0 and 1)
  60323. * @param factor defines the life time factor to affect to the specified gradient
  60324. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60325. * @returns the current particle system
  60326. */
  60327. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60328. /**
  60329. * Not supported by GPUParticleSystem
  60330. * @param gradient defines the gradient to remove
  60331. * @returns the current particle system
  60332. */
  60333. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60334. /**
  60335. * Instantiates a GPU particle system.
  60336. * 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.
  60337. * @param name The name of the particle system
  60338. * @param options The options used to create the system
  60339. * @param scene The scene the particle system belongs to
  60340. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60341. */
  60342. constructor(name: string, options: Partial<{
  60343. capacity: number;
  60344. randomTextureSize: number;
  60345. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60346. protected _reset(): void;
  60347. private _createUpdateVAO;
  60348. private _createRenderVAO;
  60349. private _initialize;
  60350. /** @hidden */
  60351. _recreateUpdateEffect(): void;
  60352. /** @hidden */
  60353. _recreateRenderEffect(): void;
  60354. /**
  60355. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60356. * @param preWarm defines if we are in the pre-warmimg phase
  60357. */
  60358. animate(preWarm?: boolean): void;
  60359. private _createFactorGradientTexture;
  60360. private _createSizeGradientTexture;
  60361. private _createAngularSpeedGradientTexture;
  60362. private _createVelocityGradientTexture;
  60363. private _createLimitVelocityGradientTexture;
  60364. private _createDragGradientTexture;
  60365. private _createColorGradientTexture;
  60366. /**
  60367. * Renders the particle system in its current state
  60368. * @param preWarm defines if the system should only update the particles but not render them
  60369. * @returns the current number of particles
  60370. */
  60371. render(preWarm?: boolean): number;
  60372. /**
  60373. * Rebuilds the particle system
  60374. */
  60375. rebuild(): void;
  60376. private _releaseBuffers;
  60377. private _releaseVAOs;
  60378. /**
  60379. * Disposes the particle system and free the associated resources
  60380. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60381. */
  60382. dispose(disposeTexture?: boolean): void;
  60383. /**
  60384. * Clones the particle system.
  60385. * @param name The name of the cloned object
  60386. * @param newEmitter The new emitter to use
  60387. * @returns the cloned particle system
  60388. */
  60389. clone(name: string, newEmitter: any): GPUParticleSystem;
  60390. /**
  60391. * Serializes the particle system to a JSON object.
  60392. * @returns the JSON object
  60393. */
  60394. serialize(): any;
  60395. /**
  60396. * Parses a JSON object to create a GPU particle system.
  60397. * @param parsedParticleSystem The JSON object to parse
  60398. * @param scene The scene to create the particle system in
  60399. * @param rootUrl The root url to use to load external dependencies like texture
  60400. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60401. * @returns the parsed GPU particle system
  60402. */
  60403. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60404. }
  60405. }
  60406. declare module BABYLON {
  60407. /**
  60408. * Represents a set of particle systems working together to create a specific effect
  60409. */
  60410. export class ParticleSystemSet implements IDisposable {
  60411. /**
  60412. * Gets or sets base Assets URL
  60413. */
  60414. static BaseAssetsUrl: string;
  60415. private _emitterCreationOptions;
  60416. private _emitterNode;
  60417. /**
  60418. * Gets the particle system list
  60419. */
  60420. systems: IParticleSystem[];
  60421. /**
  60422. * Gets the emitter node used with this set
  60423. */
  60424. readonly emitterNode: Nullable<TransformNode>;
  60425. /**
  60426. * Creates a new emitter mesh as a sphere
  60427. * @param options defines the options used to create the sphere
  60428. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60429. * @param scene defines the hosting scene
  60430. */
  60431. setEmitterAsSphere(options: {
  60432. diameter: number;
  60433. segments: number;
  60434. color: Color3;
  60435. }, renderingGroupId: number, scene: Scene): void;
  60436. /**
  60437. * Starts all particle systems of the set
  60438. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60439. */
  60440. start(emitter?: AbstractMesh): void;
  60441. /**
  60442. * Release all associated resources
  60443. */
  60444. dispose(): void;
  60445. /**
  60446. * Serialize the set into a JSON compatible object
  60447. * @returns a JSON compatible representation of the set
  60448. */
  60449. serialize(): any;
  60450. /**
  60451. * Parse a new ParticleSystemSet from a serialized source
  60452. * @param data defines a JSON compatible representation of the set
  60453. * @param scene defines the hosting scene
  60454. * @param gpu defines if we want GPU particles or CPU particles
  60455. * @returns a new ParticleSystemSet
  60456. */
  60457. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60458. }
  60459. }
  60460. declare module BABYLON {
  60461. /**
  60462. * This class is made for on one-liner static method to help creating particle system set.
  60463. */
  60464. export class ParticleHelper {
  60465. /**
  60466. * Gets or sets base Assets URL
  60467. */
  60468. static BaseAssetsUrl: string;
  60469. /**
  60470. * Create a default particle system that you can tweak
  60471. * @param emitter defines the emitter to use
  60472. * @param capacity defines the system capacity (default is 500 particles)
  60473. * @param scene defines the hosting scene
  60474. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60475. * @returns the new Particle system
  60476. */
  60477. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60478. /**
  60479. * This is the main static method (one-liner) of this helper to create different particle systems
  60480. * @param type This string represents the type to the particle system to create
  60481. * @param scene The scene where the particle system should live
  60482. * @param gpu If the system will use gpu
  60483. * @returns the ParticleSystemSet created
  60484. */
  60485. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60486. /**
  60487. * Static function used to export a particle system to a ParticleSystemSet variable.
  60488. * Please note that the emitter shape is not exported
  60489. * @param systems defines the particle systems to export
  60490. * @returns the created particle system set
  60491. */
  60492. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60493. }
  60494. }
  60495. declare module BABYLON {
  60496. interface Engine {
  60497. /**
  60498. * Create an effect to use with particle systems.
  60499. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60500. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60501. * @param uniformsNames defines a list of attribute names
  60502. * @param samplers defines an array of string used to represent textures
  60503. * @param defines defines the string containing the defines to use to compile the shaders
  60504. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60505. * @param onCompiled defines a function to call when the effect creation is successful
  60506. * @param onError defines a function to call when the effect creation has failed
  60507. * @returns the new Effect
  60508. */
  60509. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60510. }
  60511. interface Mesh {
  60512. /**
  60513. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60514. * @returns an array of IParticleSystem
  60515. */
  60516. getEmittedParticleSystems(): IParticleSystem[];
  60517. /**
  60518. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60519. * @returns an array of IParticleSystem
  60520. */
  60521. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60522. }
  60523. /**
  60524. * @hidden
  60525. */
  60526. export var _IDoNeedToBeInTheBuild: number;
  60527. }
  60528. declare module BABYLON {
  60529. /** Defines the 4 color options */
  60530. export enum PointColor {
  60531. /** color value */
  60532. Color = 2,
  60533. /** uv value */
  60534. UV = 1,
  60535. /** random value */
  60536. Random = 0,
  60537. /** stated value */
  60538. Stated = 3
  60539. }
  60540. /**
  60541. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  60542. * 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.
  60543. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  60544. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  60545. *
  60546. * Full documentation here : TO BE ENTERED
  60547. */
  60548. export class PointsCloudSystem implements IDisposable {
  60549. /**
  60550. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  60551. * Example : var p = SPS.particles[i];
  60552. */
  60553. particles: CloudPoint[];
  60554. /**
  60555. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  60556. */
  60557. nbParticles: number;
  60558. /**
  60559. * This a counter for your own usage. It's not set by any SPS functions.
  60560. */
  60561. counter: number;
  60562. /**
  60563. * The PCS name. This name is also given to the underlying mesh.
  60564. */
  60565. name: string;
  60566. /**
  60567. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  60568. */
  60569. mesh: Mesh;
  60570. /**
  60571. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  60572. * Please read :
  60573. */
  60574. vars: any;
  60575. /**
  60576. * @hidden
  60577. */
  60578. _size: number;
  60579. private _scene;
  60580. private _promises;
  60581. private _positions;
  60582. private _indices;
  60583. private _normals;
  60584. private _colors;
  60585. private _uvs;
  60586. private _indices32;
  60587. private _positions32;
  60588. private _colors32;
  60589. private _uvs32;
  60590. private _updatable;
  60591. private _isVisibilityBoxLocked;
  60592. private _alwaysVisible;
  60593. private _groups;
  60594. private _groupCounter;
  60595. private _computeParticleColor;
  60596. private _computeParticleTexture;
  60597. private _computeParticleRotation;
  60598. private _computeBoundingBox;
  60599. private _isReady;
  60600. /**
  60601. * Creates a PCS (Points Cloud System) object
  60602. * @param name (String) is the PCS name, this will be the underlying mesh name
  60603. * @param pointSize (number) is the size for each point
  60604. * @param scene (Scene) is the scene in which the PCS is added
  60605. * @param options defines the options of the PCS e.g.
  60606. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  60607. */
  60608. constructor(name: string, pointSize: number, scene: Scene, options?: {
  60609. updatable?: boolean;
  60610. });
  60611. /**
  60612. * Builds the PCS underlying mesh. Returns a standard Mesh.
  60613. * If no points were added to the PCS, the returned mesh is just a single point.
  60614. * @returns a promise for the created mesh
  60615. */
  60616. buildMeshAsync(): Promise<Mesh>;
  60617. /**
  60618. * @hidden
  60619. */
  60620. private _buildMesh;
  60621. private _addParticle;
  60622. private _randomUnitVector;
  60623. private _getColorIndicesForCoord;
  60624. private _setPointsColorOrUV;
  60625. private _colorFromTexture;
  60626. private _calculateDensity;
  60627. /**
  60628. * Adds points to the PCS in random positions within a unit sphere
  60629. * @param nb (positive integer) the number of particles to be created from this model
  60630. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  60631. * @returns the number of groups in the system
  60632. */
  60633. addPoints(nb: number, pointFunction?: any): number;
  60634. /**
  60635. * Adds points to the PCS from the surface of the model shape
  60636. * @param mesh is any Mesh object that will be used as a surface model for the points
  60637. * @param nb (positive integer) the number of particles to be created from this model
  60638. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  60639. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  60640. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  60641. * @returns the number of groups in the system
  60642. */
  60643. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  60644. /**
  60645. * Adds points to the PCS inside the model shape
  60646. * @param mesh is any Mesh object that will be used as a surface model for the points
  60647. * @param nb (positive integer) the number of particles to be created from this model
  60648. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  60649. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  60650. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  60651. * @returns the number of groups in the system
  60652. */
  60653. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  60654. /**
  60655. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  60656. * This method calls `updateParticle()` for each particle of the SPS.
  60657. * For an animated SPS, it is usually called within the render loop.
  60658. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  60659. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  60660. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  60661. * @returns the PCS.
  60662. */
  60663. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  60664. /**
  60665. * Disposes the PCS.
  60666. */
  60667. dispose(): void;
  60668. /**
  60669. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  60670. * doc :
  60671. * @returns the PCS.
  60672. */
  60673. refreshVisibleSize(): PointsCloudSystem;
  60674. /**
  60675. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  60676. * @param size the size (float) of the visibility box
  60677. * note : this doesn't lock the PCS mesh bounding box.
  60678. * doc :
  60679. */
  60680. setVisibilityBox(size: number): void;
  60681. /**
  60682. * Gets whether the PCS is always visible or not
  60683. * doc :
  60684. */
  60685. /**
  60686. * Sets the PCS as always visible or not
  60687. * doc :
  60688. */
  60689. isAlwaysVisible: boolean;
  60690. /**
  60691. * Tells to `setParticles()` to compute the particle rotations or not
  60692. * Default value : false. The PCS is faster when it's set to false
  60693. * Note : particle rotations are only applied to parent particles
  60694. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  60695. */
  60696. computeParticleRotation: boolean;
  60697. /**
  60698. * Tells to `setParticles()` to compute the particle colors or not.
  60699. * Default value : true. The PCS is faster when it's set to false.
  60700. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  60701. */
  60702. /**
  60703. * Gets if `setParticles()` computes the particle colors or not.
  60704. * Default value : false. The PCS is faster when it's set to false.
  60705. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  60706. */
  60707. computeParticleColor: boolean;
  60708. /**
  60709. * Gets if `setParticles()` computes the particle textures or not.
  60710. * Default value : false. The PCS is faster when it's set to false.
  60711. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  60712. */
  60713. computeParticleTexture: boolean;
  60714. /**
  60715. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  60716. */
  60717. /**
  60718. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  60719. */
  60720. computeBoundingBox: boolean;
  60721. /**
  60722. * This function does nothing. It may be overwritten to set all the particle first values.
  60723. * The PCS doesn't call this function, you may have to call it by your own.
  60724. * doc :
  60725. */
  60726. initParticles(): void;
  60727. /**
  60728. * This function does nothing. It may be overwritten to recycle a particle
  60729. * The PCS doesn't call this function, you can to call it
  60730. * doc :
  60731. * @param particle The particle to recycle
  60732. * @returns the recycled particle
  60733. */
  60734. recycleParticle(particle: CloudPoint): CloudPoint;
  60735. /**
  60736. * Updates a particle : this function should be overwritten by the user.
  60737. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  60738. * doc :
  60739. * @example : just set a particle position or velocity and recycle conditions
  60740. * @param particle The particle to update
  60741. * @returns the updated particle
  60742. */
  60743. updateParticle(particle: CloudPoint): CloudPoint;
  60744. /**
  60745. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  60746. * This does nothing and may be overwritten by the user.
  60747. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60748. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60749. * @param update the boolean update value actually passed to setParticles()
  60750. */
  60751. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60752. /**
  60753. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  60754. * This will be passed three parameters.
  60755. * This does nothing and may be overwritten by the user.
  60756. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  60757. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  60758. * @param update the boolean update value actually passed to setParticles()
  60759. */
  60760. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  60761. }
  60762. }
  60763. declare module BABYLON {
  60764. /**
  60765. * Represents one particle of a points cloud system.
  60766. */
  60767. export class CloudPoint {
  60768. /**
  60769. * particle global index
  60770. */
  60771. idx: number;
  60772. /**
  60773. * The color of the particle
  60774. */
  60775. color: Nullable<Color4>;
  60776. /**
  60777. * The world space position of the particle.
  60778. */
  60779. position: Vector3;
  60780. /**
  60781. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  60782. */
  60783. rotation: Vector3;
  60784. /**
  60785. * The world space rotation quaternion of the particle.
  60786. */
  60787. rotationQuaternion: Nullable<Quaternion>;
  60788. /**
  60789. * The uv of the particle.
  60790. */
  60791. uv: Nullable<Vector2>;
  60792. /**
  60793. * The current speed of the particle.
  60794. */
  60795. velocity: Vector3;
  60796. /**
  60797. * The pivot point in the particle local space.
  60798. */
  60799. pivot: Vector3;
  60800. /**
  60801. * Must the particle be translated from its pivot point in its local space ?
  60802. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  60803. * Default : false
  60804. */
  60805. translateFromPivot: boolean;
  60806. /**
  60807. * Index of this particle in the global "positions" array (Internal use)
  60808. * @hidden
  60809. */
  60810. _pos: number;
  60811. /**
  60812. * @hidden Index of this particle in the global "indices" array (Internal use)
  60813. */
  60814. _ind: number;
  60815. /**
  60816. * Group this particle belongs to
  60817. */
  60818. _group: PointsGroup;
  60819. /**
  60820. * Group id of this particle
  60821. */
  60822. groupId: number;
  60823. /**
  60824. * Index of the particle in its group id (Internal use)
  60825. */
  60826. idxInGroup: number;
  60827. /**
  60828. * @hidden Particle BoundingInfo object (Internal use)
  60829. */
  60830. _boundingInfo: BoundingInfo;
  60831. /**
  60832. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  60833. */
  60834. _pcs: PointsCloudSystem;
  60835. /**
  60836. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  60837. */
  60838. _stillInvisible: boolean;
  60839. /**
  60840. * @hidden Last computed particle rotation matrix
  60841. */
  60842. _rotationMatrix: number[];
  60843. /**
  60844. * Parent particle Id, if any.
  60845. * Default null.
  60846. */
  60847. parentId: Nullable<number>;
  60848. /**
  60849. * @hidden Internal global position in the PCS.
  60850. */
  60851. _globalPosition: Vector3;
  60852. /**
  60853. * Creates a Point Cloud object.
  60854. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  60855. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  60856. * @param group (PointsGroup) is the group the particle belongs to
  60857. * @param groupId (integer) is the group identifier in the PCS.
  60858. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  60859. * @param pcs defines the PCS it is associated to
  60860. */
  60861. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  60862. /**
  60863. * get point size
  60864. */
  60865. /**
  60866. * Set point size
  60867. */
  60868. size: Vector3;
  60869. /**
  60870. * Legacy support, changed quaternion to rotationQuaternion
  60871. */
  60872. /**
  60873. * Legacy support, changed quaternion to rotationQuaternion
  60874. */
  60875. quaternion: Nullable<Quaternion>;
  60876. /**
  60877. * Returns a boolean. True if the particle intersects a mesh, else false
  60878. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  60879. * @param target is the object (point or mesh) what the intersection is computed against
  60880. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  60881. * @returns true if it intersects
  60882. */
  60883. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  60884. /**
  60885. * get the rotation matrix of the particle
  60886. * @hidden
  60887. */
  60888. getRotationMatrix(m: Matrix): void;
  60889. }
  60890. /**
  60891. * Represents a group of points in a points cloud system
  60892. * * PCS internal tool, don't use it manually.
  60893. */
  60894. export class PointsGroup {
  60895. /**
  60896. * The group id
  60897. * @hidden
  60898. */
  60899. groupID: number;
  60900. /**
  60901. * image data for group (internal use)
  60902. * @hidden
  60903. */
  60904. _groupImageData: Nullable<ArrayBufferView>;
  60905. /**
  60906. * Image Width (internal use)
  60907. * @hidden
  60908. */
  60909. _groupImgWidth: number;
  60910. /**
  60911. * Image Height (internal use)
  60912. * @hidden
  60913. */
  60914. _groupImgHeight: number;
  60915. /**
  60916. * Custom position function (internal use)
  60917. * @hidden
  60918. */
  60919. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  60920. /**
  60921. * density per facet for surface points
  60922. * @hidden
  60923. */
  60924. _groupDensity: number[];
  60925. /**
  60926. * Only when points are colored by texture carries pointer to texture list array
  60927. * @hidden
  60928. */
  60929. _textureNb: number;
  60930. /**
  60931. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  60932. * PCS internal tool, don't use it manually.
  60933. * @hidden
  60934. */
  60935. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  60936. }
  60937. }
  60938. declare module BABYLON {
  60939. interface Scene {
  60940. /** @hidden (Backing field) */
  60941. _physicsEngine: Nullable<IPhysicsEngine>;
  60942. /** @hidden */
  60943. _physicsTimeAccumulator: number;
  60944. /**
  60945. * Gets the current physics engine
  60946. * @returns a IPhysicsEngine or null if none attached
  60947. */
  60948. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60949. /**
  60950. * Enables physics to the current scene
  60951. * @param gravity defines the scene's gravity for the physics engine
  60952. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60953. * @return a boolean indicating if the physics engine was initialized
  60954. */
  60955. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60956. /**
  60957. * Disables and disposes the physics engine associated with the scene
  60958. */
  60959. disablePhysicsEngine(): void;
  60960. /**
  60961. * Gets a boolean indicating if there is an active physics engine
  60962. * @returns a boolean indicating if there is an active physics engine
  60963. */
  60964. isPhysicsEnabled(): boolean;
  60965. /**
  60966. * Deletes a physics compound impostor
  60967. * @param compound defines the compound to delete
  60968. */
  60969. deleteCompoundImpostor(compound: any): void;
  60970. /**
  60971. * An event triggered when physic simulation is about to be run
  60972. */
  60973. onBeforePhysicsObservable: Observable<Scene>;
  60974. /**
  60975. * An event triggered when physic simulation has been done
  60976. */
  60977. onAfterPhysicsObservable: Observable<Scene>;
  60978. }
  60979. interface AbstractMesh {
  60980. /** @hidden */
  60981. _physicsImpostor: Nullable<PhysicsImpostor>;
  60982. /**
  60983. * Gets or sets impostor used for physic simulation
  60984. * @see http://doc.babylonjs.com/features/physics_engine
  60985. */
  60986. physicsImpostor: Nullable<PhysicsImpostor>;
  60987. /**
  60988. * Gets the current physics impostor
  60989. * @see http://doc.babylonjs.com/features/physics_engine
  60990. * @returns a physics impostor or null
  60991. */
  60992. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60993. /** Apply a physic impulse to the mesh
  60994. * @param force defines the force to apply
  60995. * @param contactPoint defines where to apply the force
  60996. * @returns the current mesh
  60997. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60998. */
  60999. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61000. /**
  61001. * Creates a physic joint between two meshes
  61002. * @param otherMesh defines the other mesh to use
  61003. * @param pivot1 defines the pivot to use on this mesh
  61004. * @param pivot2 defines the pivot to use on the other mesh
  61005. * @param options defines additional options (can be plugin dependent)
  61006. * @returns the current mesh
  61007. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61008. */
  61009. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61010. /** @hidden */
  61011. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61012. }
  61013. /**
  61014. * Defines the physics engine scene component responsible to manage a physics engine
  61015. */
  61016. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61017. /**
  61018. * The component name helpful to identify the component in the list of scene components.
  61019. */
  61020. readonly name: string;
  61021. /**
  61022. * The scene the component belongs to.
  61023. */
  61024. scene: Scene;
  61025. /**
  61026. * Creates a new instance of the component for the given scene
  61027. * @param scene Defines the scene to register the component in
  61028. */
  61029. constructor(scene: Scene);
  61030. /**
  61031. * Registers the component in a given scene
  61032. */
  61033. register(): void;
  61034. /**
  61035. * Rebuilds the elements related to this component in case of
  61036. * context lost for instance.
  61037. */
  61038. rebuild(): void;
  61039. /**
  61040. * Disposes the component and the associated ressources
  61041. */
  61042. dispose(): void;
  61043. }
  61044. }
  61045. declare module BABYLON {
  61046. /**
  61047. * A helper for physics simulations
  61048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61049. */
  61050. export class PhysicsHelper {
  61051. private _scene;
  61052. private _physicsEngine;
  61053. /**
  61054. * Initializes the Physics helper
  61055. * @param scene Babylon.js scene
  61056. */
  61057. constructor(scene: Scene);
  61058. /**
  61059. * Applies a radial explosion impulse
  61060. * @param origin the origin of the explosion
  61061. * @param radiusOrEventOptions the radius or the options of radial explosion
  61062. * @param strength the explosion strength
  61063. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61064. * @returns A physics radial explosion event, or null
  61065. */
  61066. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61067. /**
  61068. * Applies a radial explosion force
  61069. * @param origin the origin of the explosion
  61070. * @param radiusOrEventOptions the radius or the options of radial explosion
  61071. * @param strength the explosion strength
  61072. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61073. * @returns A physics radial explosion event, or null
  61074. */
  61075. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61076. /**
  61077. * Creates a gravitational field
  61078. * @param origin the origin of the explosion
  61079. * @param radiusOrEventOptions the radius or the options of radial explosion
  61080. * @param strength the explosion strength
  61081. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61082. * @returns A physics gravitational field event, or null
  61083. */
  61084. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61085. /**
  61086. * Creates a physics updraft event
  61087. * @param origin the origin of the updraft
  61088. * @param radiusOrEventOptions the radius or the options of the updraft
  61089. * @param strength the strength of the updraft
  61090. * @param height the height of the updraft
  61091. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61092. * @returns A physics updraft event, or null
  61093. */
  61094. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61095. /**
  61096. * Creates a physics vortex event
  61097. * @param origin the of the vortex
  61098. * @param radiusOrEventOptions the radius or the options of the vortex
  61099. * @param strength the strength of the vortex
  61100. * @param height the height of the vortex
  61101. * @returns a Physics vortex event, or null
  61102. * A physics vortex event or null
  61103. */
  61104. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61105. }
  61106. /**
  61107. * Represents a physics radial explosion event
  61108. */
  61109. class PhysicsRadialExplosionEvent {
  61110. private _scene;
  61111. private _options;
  61112. private _sphere;
  61113. private _dataFetched;
  61114. /**
  61115. * Initializes a radial explosioin event
  61116. * @param _scene BabylonJS scene
  61117. * @param _options The options for the vortex event
  61118. */
  61119. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61120. /**
  61121. * Returns the data related to the radial explosion event (sphere).
  61122. * @returns The radial explosion event data
  61123. */
  61124. getData(): PhysicsRadialExplosionEventData;
  61125. /**
  61126. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61127. * @param impostor A physics imposter
  61128. * @param origin the origin of the explosion
  61129. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61130. */
  61131. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61132. /**
  61133. * Triggers affecterd impostors callbacks
  61134. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61135. */
  61136. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61137. /**
  61138. * Disposes the sphere.
  61139. * @param force Specifies if the sphere should be disposed by force
  61140. */
  61141. dispose(force?: boolean): void;
  61142. /*** Helpers ***/
  61143. private _prepareSphere;
  61144. private _intersectsWithSphere;
  61145. }
  61146. /**
  61147. * Represents a gravitational field event
  61148. */
  61149. class PhysicsGravitationalFieldEvent {
  61150. private _physicsHelper;
  61151. private _scene;
  61152. private _origin;
  61153. private _options;
  61154. private _tickCallback;
  61155. private _sphere;
  61156. private _dataFetched;
  61157. /**
  61158. * Initializes the physics gravitational field event
  61159. * @param _physicsHelper A physics helper
  61160. * @param _scene BabylonJS scene
  61161. * @param _origin The origin position of the gravitational field event
  61162. * @param _options The options for the vortex event
  61163. */
  61164. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61165. /**
  61166. * Returns the data related to the gravitational field event (sphere).
  61167. * @returns A gravitational field event
  61168. */
  61169. getData(): PhysicsGravitationalFieldEventData;
  61170. /**
  61171. * Enables the gravitational field.
  61172. */
  61173. enable(): void;
  61174. /**
  61175. * Disables the gravitational field.
  61176. */
  61177. disable(): void;
  61178. /**
  61179. * Disposes the sphere.
  61180. * @param force The force to dispose from the gravitational field event
  61181. */
  61182. dispose(force?: boolean): void;
  61183. private _tick;
  61184. }
  61185. /**
  61186. * Represents a physics updraft event
  61187. */
  61188. class PhysicsUpdraftEvent {
  61189. private _scene;
  61190. private _origin;
  61191. private _options;
  61192. private _physicsEngine;
  61193. private _originTop;
  61194. private _originDirection;
  61195. private _tickCallback;
  61196. private _cylinder;
  61197. private _cylinderPosition;
  61198. private _dataFetched;
  61199. /**
  61200. * Initializes the physics updraft event
  61201. * @param _scene BabylonJS scene
  61202. * @param _origin The origin position of the updraft
  61203. * @param _options The options for the updraft event
  61204. */
  61205. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61206. /**
  61207. * Returns the data related to the updraft event (cylinder).
  61208. * @returns A physics updraft event
  61209. */
  61210. getData(): PhysicsUpdraftEventData;
  61211. /**
  61212. * Enables the updraft.
  61213. */
  61214. enable(): void;
  61215. /**
  61216. * Disables the updraft.
  61217. */
  61218. disable(): void;
  61219. /**
  61220. * Disposes the cylinder.
  61221. * @param force Specifies if the updraft should be disposed by force
  61222. */
  61223. dispose(force?: boolean): void;
  61224. private getImpostorHitData;
  61225. private _tick;
  61226. /*** Helpers ***/
  61227. private _prepareCylinder;
  61228. private _intersectsWithCylinder;
  61229. }
  61230. /**
  61231. * Represents a physics vortex event
  61232. */
  61233. class PhysicsVortexEvent {
  61234. private _scene;
  61235. private _origin;
  61236. private _options;
  61237. private _physicsEngine;
  61238. private _originTop;
  61239. private _tickCallback;
  61240. private _cylinder;
  61241. private _cylinderPosition;
  61242. private _dataFetched;
  61243. /**
  61244. * Initializes the physics vortex event
  61245. * @param _scene The BabylonJS scene
  61246. * @param _origin The origin position of the vortex
  61247. * @param _options The options for the vortex event
  61248. */
  61249. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61250. /**
  61251. * Returns the data related to the vortex event (cylinder).
  61252. * @returns The physics vortex event data
  61253. */
  61254. getData(): PhysicsVortexEventData;
  61255. /**
  61256. * Enables the vortex.
  61257. */
  61258. enable(): void;
  61259. /**
  61260. * Disables the cortex.
  61261. */
  61262. disable(): void;
  61263. /**
  61264. * Disposes the sphere.
  61265. * @param force
  61266. */
  61267. dispose(force?: boolean): void;
  61268. private getImpostorHitData;
  61269. private _tick;
  61270. /*** Helpers ***/
  61271. private _prepareCylinder;
  61272. private _intersectsWithCylinder;
  61273. }
  61274. /**
  61275. * Options fot the radial explosion event
  61276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61277. */
  61278. export class PhysicsRadialExplosionEventOptions {
  61279. /**
  61280. * The radius of the sphere for the radial explosion.
  61281. */
  61282. radius: number;
  61283. /**
  61284. * The strenth of the explosion.
  61285. */
  61286. strength: number;
  61287. /**
  61288. * The strenght of the force in correspondence to the distance of the affected object
  61289. */
  61290. falloff: PhysicsRadialImpulseFalloff;
  61291. /**
  61292. * Sphere options for the radial explosion.
  61293. */
  61294. sphere: {
  61295. segments: number;
  61296. diameter: number;
  61297. };
  61298. /**
  61299. * Sphere options for the radial explosion.
  61300. */
  61301. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61302. }
  61303. /**
  61304. * Options fot the updraft event
  61305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61306. */
  61307. export class PhysicsUpdraftEventOptions {
  61308. /**
  61309. * The radius of the cylinder for the vortex
  61310. */
  61311. radius: number;
  61312. /**
  61313. * The strenth of the updraft.
  61314. */
  61315. strength: number;
  61316. /**
  61317. * The height of the cylinder for the updraft.
  61318. */
  61319. height: number;
  61320. /**
  61321. * The mode for the the updraft.
  61322. */
  61323. updraftMode: PhysicsUpdraftMode;
  61324. }
  61325. /**
  61326. * Options fot the vortex event
  61327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61328. */
  61329. export class PhysicsVortexEventOptions {
  61330. /**
  61331. * The radius of the cylinder for the vortex
  61332. */
  61333. radius: number;
  61334. /**
  61335. * The strenth of the vortex.
  61336. */
  61337. strength: number;
  61338. /**
  61339. * The height of the cylinder for the vortex.
  61340. */
  61341. height: number;
  61342. /**
  61343. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61344. */
  61345. centripetalForceThreshold: number;
  61346. /**
  61347. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61348. */
  61349. centripetalForceMultiplier: number;
  61350. /**
  61351. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61352. */
  61353. centrifugalForceMultiplier: number;
  61354. /**
  61355. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61356. */
  61357. updraftForceMultiplier: number;
  61358. }
  61359. /**
  61360. * The strenght of the force in correspondence to the distance of the affected object
  61361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61362. */
  61363. export enum PhysicsRadialImpulseFalloff {
  61364. /** Defines that impulse is constant in strength across it's whole radius */
  61365. Constant = 0,
  61366. /** Defines that impulse gets weaker if it's further from the origin */
  61367. Linear = 1
  61368. }
  61369. /**
  61370. * The strength of the force in correspondence to the distance of the affected object
  61371. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61372. */
  61373. export enum PhysicsUpdraftMode {
  61374. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61375. Center = 0,
  61376. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61377. Perpendicular = 1
  61378. }
  61379. /**
  61380. * Interface for a physics hit data
  61381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61382. */
  61383. export interface PhysicsHitData {
  61384. /**
  61385. * The force applied at the contact point
  61386. */
  61387. force: Vector3;
  61388. /**
  61389. * The contact point
  61390. */
  61391. contactPoint: Vector3;
  61392. /**
  61393. * The distance from the origin to the contact point
  61394. */
  61395. distanceFromOrigin: number;
  61396. }
  61397. /**
  61398. * Interface for radial explosion event data
  61399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61400. */
  61401. export interface PhysicsRadialExplosionEventData {
  61402. /**
  61403. * A sphere used for the radial explosion event
  61404. */
  61405. sphere: Mesh;
  61406. }
  61407. /**
  61408. * Interface for gravitational field event data
  61409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61410. */
  61411. export interface PhysicsGravitationalFieldEventData {
  61412. /**
  61413. * A sphere mesh used for the gravitational field event
  61414. */
  61415. sphere: Mesh;
  61416. }
  61417. /**
  61418. * Interface for updraft event data
  61419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61420. */
  61421. export interface PhysicsUpdraftEventData {
  61422. /**
  61423. * A cylinder used for the updraft event
  61424. */
  61425. cylinder: Mesh;
  61426. }
  61427. /**
  61428. * Interface for vortex event data
  61429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61430. */
  61431. export interface PhysicsVortexEventData {
  61432. /**
  61433. * A cylinder used for the vortex event
  61434. */
  61435. cylinder: Mesh;
  61436. }
  61437. /**
  61438. * Interface for an affected physics impostor
  61439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61440. */
  61441. export interface PhysicsAffectedImpostorWithData {
  61442. /**
  61443. * The impostor affected by the effect
  61444. */
  61445. impostor: PhysicsImpostor;
  61446. /**
  61447. * The data about the hit/horce from the explosion
  61448. */
  61449. hitData: PhysicsHitData;
  61450. }
  61451. }
  61452. declare module BABYLON {
  61453. /** @hidden */
  61454. export var blackAndWhitePixelShader: {
  61455. name: string;
  61456. shader: string;
  61457. };
  61458. }
  61459. declare module BABYLON {
  61460. /**
  61461. * Post process used to render in black and white
  61462. */
  61463. export class BlackAndWhitePostProcess extends PostProcess {
  61464. /**
  61465. * Linear about to convert he result to black and white (default: 1)
  61466. */
  61467. degree: number;
  61468. /**
  61469. * Creates a black and white post process
  61470. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61471. * @param name The name of the effect.
  61472. * @param options The required width/height ratio to downsize to before computing the render pass.
  61473. * @param camera The camera to apply the render pass to.
  61474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61475. * @param engine The engine which the post process will be applied. (default: current engine)
  61476. * @param reusable If the post process can be reused on the same frame. (default: false)
  61477. */
  61478. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61479. }
  61480. }
  61481. declare module BABYLON {
  61482. /**
  61483. * This represents a set of one or more post processes in Babylon.
  61484. * A post process can be used to apply a shader to a texture after it is rendered.
  61485. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61486. */
  61487. export class PostProcessRenderEffect {
  61488. private _postProcesses;
  61489. private _getPostProcesses;
  61490. private _singleInstance;
  61491. private _cameras;
  61492. private _indicesForCamera;
  61493. /**
  61494. * Name of the effect
  61495. * @hidden
  61496. */
  61497. _name: string;
  61498. /**
  61499. * Instantiates a post process render effect.
  61500. * A post process can be used to apply a shader to a texture after it is rendered.
  61501. * @param engine The engine the effect is tied to
  61502. * @param name The name of the effect
  61503. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61504. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61505. */
  61506. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61507. /**
  61508. * Checks if all the post processes in the effect are supported.
  61509. */
  61510. readonly isSupported: boolean;
  61511. /**
  61512. * Updates the current state of the effect
  61513. * @hidden
  61514. */
  61515. _update(): void;
  61516. /**
  61517. * Attaches the effect on cameras
  61518. * @param cameras The camera to attach to.
  61519. * @hidden
  61520. */
  61521. _attachCameras(cameras: Camera): void;
  61522. /**
  61523. * Attaches the effect on cameras
  61524. * @param cameras The camera to attach to.
  61525. * @hidden
  61526. */
  61527. _attachCameras(cameras: Camera[]): void;
  61528. /**
  61529. * Detaches the effect on cameras
  61530. * @param cameras The camera to detatch from.
  61531. * @hidden
  61532. */
  61533. _detachCameras(cameras: Camera): void;
  61534. /**
  61535. * Detatches the effect on cameras
  61536. * @param cameras The camera to detatch from.
  61537. * @hidden
  61538. */
  61539. _detachCameras(cameras: Camera[]): void;
  61540. /**
  61541. * Enables the effect on given cameras
  61542. * @param cameras The camera to enable.
  61543. * @hidden
  61544. */
  61545. _enable(cameras: Camera): void;
  61546. /**
  61547. * Enables the effect on given cameras
  61548. * @param cameras The camera to enable.
  61549. * @hidden
  61550. */
  61551. _enable(cameras: Nullable<Camera[]>): void;
  61552. /**
  61553. * Disables the effect on the given cameras
  61554. * @param cameras The camera to disable.
  61555. * @hidden
  61556. */
  61557. _disable(cameras: Camera): void;
  61558. /**
  61559. * Disables the effect on the given cameras
  61560. * @param cameras The camera to disable.
  61561. * @hidden
  61562. */
  61563. _disable(cameras: Nullable<Camera[]>): void;
  61564. /**
  61565. * Gets a list of the post processes contained in the effect.
  61566. * @param camera The camera to get the post processes on.
  61567. * @returns The list of the post processes in the effect.
  61568. */
  61569. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61570. }
  61571. }
  61572. declare module BABYLON {
  61573. /** @hidden */
  61574. export var extractHighlightsPixelShader: {
  61575. name: string;
  61576. shader: string;
  61577. };
  61578. }
  61579. declare module BABYLON {
  61580. /**
  61581. * 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.
  61582. */
  61583. export class ExtractHighlightsPostProcess extends PostProcess {
  61584. /**
  61585. * The luminance threshold, pixels below this value will be set to black.
  61586. */
  61587. threshold: number;
  61588. /** @hidden */
  61589. _exposure: number;
  61590. /**
  61591. * Post process which has the input texture to be used when performing highlight extraction
  61592. * @hidden
  61593. */
  61594. _inputPostProcess: Nullable<PostProcess>;
  61595. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61596. }
  61597. }
  61598. declare module BABYLON {
  61599. /** @hidden */
  61600. export var bloomMergePixelShader: {
  61601. name: string;
  61602. shader: string;
  61603. };
  61604. }
  61605. declare module BABYLON {
  61606. /**
  61607. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61608. */
  61609. export class BloomMergePostProcess extends PostProcess {
  61610. /** Weight of the bloom to be added to the original input. */
  61611. weight: number;
  61612. /**
  61613. * Creates a new instance of @see BloomMergePostProcess
  61614. * @param name The name of the effect.
  61615. * @param originalFromInput Post process which's input will be used for the merge.
  61616. * @param blurred Blurred highlights post process which's output will be used.
  61617. * @param weight Weight of the bloom to be added to the original input.
  61618. * @param options The required width/height ratio to downsize to before computing the render pass.
  61619. * @param camera The camera to apply the render pass to.
  61620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61621. * @param engine The engine which the post process will be applied. (default: current engine)
  61622. * @param reusable If the post process can be reused on the same frame. (default: false)
  61623. * @param textureType Type of textures used when performing the post process. (default: 0)
  61624. * @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)
  61625. */
  61626. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61627. /** Weight of the bloom to be added to the original input. */
  61628. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61629. }
  61630. }
  61631. declare module BABYLON {
  61632. /**
  61633. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61634. */
  61635. export class BloomEffect extends PostProcessRenderEffect {
  61636. private bloomScale;
  61637. /**
  61638. * @hidden Internal
  61639. */
  61640. _effects: Array<PostProcess>;
  61641. /**
  61642. * @hidden Internal
  61643. */
  61644. _downscale: ExtractHighlightsPostProcess;
  61645. private _blurX;
  61646. private _blurY;
  61647. private _merge;
  61648. /**
  61649. * The luminance threshold to find bright areas of the image to bloom.
  61650. */
  61651. threshold: number;
  61652. /**
  61653. * The strength of the bloom.
  61654. */
  61655. weight: number;
  61656. /**
  61657. * Specifies the size of the bloom blur kernel, relative to the final output size
  61658. */
  61659. kernel: number;
  61660. /**
  61661. * Creates a new instance of @see BloomEffect
  61662. * @param scene The scene the effect belongs to.
  61663. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61664. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61665. * @param bloomWeight The the strength of bloom.
  61666. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61667. * @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)
  61668. */
  61669. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61670. /**
  61671. * Disposes each of the internal effects for a given camera.
  61672. * @param camera The camera to dispose the effect on.
  61673. */
  61674. disposeEffects(camera: Camera): void;
  61675. /**
  61676. * @hidden Internal
  61677. */
  61678. _updateEffects(): void;
  61679. /**
  61680. * Internal
  61681. * @returns if all the contained post processes are ready.
  61682. * @hidden
  61683. */
  61684. _isReady(): boolean;
  61685. }
  61686. }
  61687. declare module BABYLON {
  61688. /** @hidden */
  61689. export var chromaticAberrationPixelShader: {
  61690. name: string;
  61691. shader: string;
  61692. };
  61693. }
  61694. declare module BABYLON {
  61695. /**
  61696. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61697. */
  61698. export class ChromaticAberrationPostProcess extends PostProcess {
  61699. /**
  61700. * The amount of seperation of rgb channels (default: 30)
  61701. */
  61702. aberrationAmount: number;
  61703. /**
  61704. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61705. */
  61706. radialIntensity: number;
  61707. /**
  61708. * 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))
  61709. */
  61710. direction: Vector2;
  61711. /**
  61712. * 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))
  61713. */
  61714. centerPosition: Vector2;
  61715. /**
  61716. * Creates a new instance ChromaticAberrationPostProcess
  61717. * @param name The name of the effect.
  61718. * @param screenWidth The width of the screen to apply the effect on.
  61719. * @param screenHeight The height of the screen to apply the effect on.
  61720. * @param options The required width/height ratio to downsize to before computing the render pass.
  61721. * @param camera The camera to apply the render pass to.
  61722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61723. * @param engine The engine which the post process will be applied. (default: current engine)
  61724. * @param reusable If the post process can be reused on the same frame. (default: false)
  61725. * @param textureType Type of textures used when performing the post process. (default: 0)
  61726. * @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)
  61727. */
  61728. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61729. }
  61730. }
  61731. declare module BABYLON {
  61732. /** @hidden */
  61733. export var circleOfConfusionPixelShader: {
  61734. name: string;
  61735. shader: string;
  61736. };
  61737. }
  61738. declare module BABYLON {
  61739. /**
  61740. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61741. */
  61742. export class CircleOfConfusionPostProcess extends PostProcess {
  61743. /**
  61744. * 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.
  61745. */
  61746. lensSize: number;
  61747. /**
  61748. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61749. */
  61750. fStop: number;
  61751. /**
  61752. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61753. */
  61754. focusDistance: number;
  61755. /**
  61756. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61757. */
  61758. focalLength: number;
  61759. private _depthTexture;
  61760. /**
  61761. * Creates a new instance CircleOfConfusionPostProcess
  61762. * @param name The name of the effect.
  61763. * @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.
  61764. * @param options The required width/height ratio to downsize to before computing the render pass.
  61765. * @param camera The camera to apply the render pass to.
  61766. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61767. * @param engine The engine which the post process will be applied. (default: current engine)
  61768. * @param reusable If the post process can be reused on the same frame. (default: false)
  61769. * @param textureType Type of textures used when performing the post process. (default: 0)
  61770. * @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)
  61771. */
  61772. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61773. /**
  61774. * 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.
  61775. */
  61776. depthTexture: RenderTargetTexture;
  61777. }
  61778. }
  61779. declare module BABYLON {
  61780. /** @hidden */
  61781. export var colorCorrectionPixelShader: {
  61782. name: string;
  61783. shader: string;
  61784. };
  61785. }
  61786. declare module BABYLON {
  61787. /**
  61788. *
  61789. * This post-process allows the modification of rendered colors by using
  61790. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61791. *
  61792. * The object needs to be provided an url to a texture containing the color
  61793. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61794. * Use an image editing software to tweak the LUT to match your needs.
  61795. *
  61796. * For an example of a color LUT, see here:
  61797. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61798. * For explanations on color grading, see here:
  61799. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61800. *
  61801. */
  61802. export class ColorCorrectionPostProcess extends PostProcess {
  61803. private _colorTableTexture;
  61804. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61805. }
  61806. }
  61807. declare module BABYLON {
  61808. /** @hidden */
  61809. export var convolutionPixelShader: {
  61810. name: string;
  61811. shader: string;
  61812. };
  61813. }
  61814. declare module BABYLON {
  61815. /**
  61816. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61817. * input texture to perform effects such as edge detection or sharpening
  61818. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61819. */
  61820. export class ConvolutionPostProcess extends PostProcess {
  61821. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61822. kernel: number[];
  61823. /**
  61824. * Creates a new instance ConvolutionPostProcess
  61825. * @param name The name of the effect.
  61826. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61827. * @param options The required width/height ratio to downsize to before computing the render pass.
  61828. * @param camera The camera to apply the render pass to.
  61829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61830. * @param engine The engine which the post process will be applied. (default: current engine)
  61831. * @param reusable If the post process can be reused on the same frame. (default: false)
  61832. * @param textureType Type of textures used when performing the post process. (default: 0)
  61833. */
  61834. constructor(name: string,
  61835. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61836. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61837. /**
  61838. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61839. */
  61840. static EdgeDetect0Kernel: number[];
  61841. /**
  61842. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61843. */
  61844. static EdgeDetect1Kernel: number[];
  61845. /**
  61846. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61847. */
  61848. static EdgeDetect2Kernel: number[];
  61849. /**
  61850. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61851. */
  61852. static SharpenKernel: number[];
  61853. /**
  61854. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61855. */
  61856. static EmbossKernel: number[];
  61857. /**
  61858. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61859. */
  61860. static GaussianKernel: number[];
  61861. }
  61862. }
  61863. declare module BABYLON {
  61864. /**
  61865. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61866. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61867. * based on samples that have a large difference in distance than the center pixel.
  61868. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61869. */
  61870. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61871. direction: Vector2;
  61872. /**
  61873. * Creates a new instance CircleOfConfusionPostProcess
  61874. * @param name The name of the effect.
  61875. * @param scene The scene the effect belongs to.
  61876. * @param direction The direction the blur should be applied.
  61877. * @param kernel The size of the kernel used to blur.
  61878. * @param options The required width/height ratio to downsize to before computing the render pass.
  61879. * @param camera The camera to apply the render pass to.
  61880. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61881. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61883. * @param engine The engine which the post process will be applied. (default: current engine)
  61884. * @param reusable If the post process can be reused on the same frame. (default: false)
  61885. * @param textureType Type of textures used when performing the post process. (default: 0)
  61886. * @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)
  61887. */
  61888. 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);
  61889. }
  61890. }
  61891. declare module BABYLON {
  61892. /** @hidden */
  61893. export var depthOfFieldMergePixelShader: {
  61894. name: string;
  61895. shader: string;
  61896. };
  61897. }
  61898. declare module BABYLON {
  61899. /**
  61900. * Options to be set when merging outputs from the default pipeline.
  61901. */
  61902. export class DepthOfFieldMergePostProcessOptions {
  61903. /**
  61904. * The original image to merge on top of
  61905. */
  61906. originalFromInput: PostProcess;
  61907. /**
  61908. * Parameters to perform the merge of the depth of field effect
  61909. */
  61910. depthOfField?: {
  61911. circleOfConfusion: PostProcess;
  61912. blurSteps: Array<PostProcess>;
  61913. };
  61914. /**
  61915. * Parameters to perform the merge of bloom effect
  61916. */
  61917. bloom?: {
  61918. blurred: PostProcess;
  61919. weight: number;
  61920. };
  61921. }
  61922. /**
  61923. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61924. */
  61925. export class DepthOfFieldMergePostProcess extends PostProcess {
  61926. private blurSteps;
  61927. /**
  61928. * Creates a new instance of DepthOfFieldMergePostProcess
  61929. * @param name The name of the effect.
  61930. * @param originalFromInput Post process which's input will be used for the merge.
  61931. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61932. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61933. * @param options The required width/height ratio to downsize to before computing the render pass.
  61934. * @param camera The camera to apply the render pass to.
  61935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61936. * @param engine The engine which the post process will be applied. (default: current engine)
  61937. * @param reusable If the post process can be reused on the same frame. (default: false)
  61938. * @param textureType Type of textures used when performing the post process. (default: 0)
  61939. * @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)
  61940. */
  61941. 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);
  61942. /**
  61943. * Updates the effect with the current post process compile time values and recompiles the shader.
  61944. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61945. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61946. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61947. * @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
  61948. * @param onCompiled Called when the shader has been compiled.
  61949. * @param onError Called if there is an error when compiling a shader.
  61950. */
  61951. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61952. }
  61953. }
  61954. declare module BABYLON {
  61955. /**
  61956. * Specifies the level of max blur that should be applied when using the depth of field effect
  61957. */
  61958. export enum DepthOfFieldEffectBlurLevel {
  61959. /**
  61960. * Subtle blur
  61961. */
  61962. Low = 0,
  61963. /**
  61964. * Medium blur
  61965. */
  61966. Medium = 1,
  61967. /**
  61968. * Large blur
  61969. */
  61970. High = 2
  61971. }
  61972. /**
  61973. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61974. */
  61975. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61976. private _circleOfConfusion;
  61977. /**
  61978. * @hidden Internal, blurs from high to low
  61979. */
  61980. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61981. private _depthOfFieldBlurY;
  61982. private _dofMerge;
  61983. /**
  61984. * @hidden Internal post processes in depth of field effect
  61985. */
  61986. _effects: Array<PostProcess>;
  61987. /**
  61988. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61989. */
  61990. focalLength: number;
  61991. /**
  61992. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61993. */
  61994. fStop: number;
  61995. /**
  61996. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61997. */
  61998. focusDistance: number;
  61999. /**
  62000. * 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.
  62001. */
  62002. lensSize: number;
  62003. /**
  62004. * Creates a new instance DepthOfFieldEffect
  62005. * @param scene The scene the effect belongs to.
  62006. * @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.
  62007. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62008. * @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)
  62009. */
  62010. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62011. /**
  62012. * Get the current class name of the current effet
  62013. * @returns "DepthOfFieldEffect"
  62014. */
  62015. getClassName(): string;
  62016. /**
  62017. * 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.
  62018. */
  62019. depthTexture: RenderTargetTexture;
  62020. /**
  62021. * Disposes each of the internal effects for a given camera.
  62022. * @param camera The camera to dispose the effect on.
  62023. */
  62024. disposeEffects(camera: Camera): void;
  62025. /**
  62026. * @hidden Internal
  62027. */
  62028. _updateEffects(): void;
  62029. /**
  62030. * Internal
  62031. * @returns if all the contained post processes are ready.
  62032. * @hidden
  62033. */
  62034. _isReady(): boolean;
  62035. }
  62036. }
  62037. declare module BABYLON {
  62038. /** @hidden */
  62039. export var displayPassPixelShader: {
  62040. name: string;
  62041. shader: string;
  62042. };
  62043. }
  62044. declare module BABYLON {
  62045. /**
  62046. * DisplayPassPostProcess which produces an output the same as it's input
  62047. */
  62048. export class DisplayPassPostProcess extends PostProcess {
  62049. /**
  62050. * Creates the DisplayPassPostProcess
  62051. * @param name The name of the effect.
  62052. * @param options The required width/height ratio to downsize to before computing the render pass.
  62053. * @param camera The camera to apply the render pass to.
  62054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62055. * @param engine The engine which the post process will be applied. (default: current engine)
  62056. * @param reusable If the post process can be reused on the same frame. (default: false)
  62057. */
  62058. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62059. }
  62060. }
  62061. declare module BABYLON {
  62062. /** @hidden */
  62063. export var filterPixelShader: {
  62064. name: string;
  62065. shader: string;
  62066. };
  62067. }
  62068. declare module BABYLON {
  62069. /**
  62070. * Applies a kernel filter to the image
  62071. */
  62072. export class FilterPostProcess extends PostProcess {
  62073. /** The matrix to be applied to the image */
  62074. kernelMatrix: Matrix;
  62075. /**
  62076. *
  62077. * @param name The name of the effect.
  62078. * @param kernelMatrix The matrix to be applied to the image
  62079. * @param options The required width/height ratio to downsize to before computing the render pass.
  62080. * @param camera The camera to apply the render pass to.
  62081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62082. * @param engine The engine which the post process will be applied. (default: current engine)
  62083. * @param reusable If the post process can be reused on the same frame. (default: false)
  62084. */
  62085. constructor(name: string,
  62086. /** The matrix to be applied to the image */
  62087. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62088. }
  62089. }
  62090. declare module BABYLON {
  62091. /** @hidden */
  62092. export var fxaaPixelShader: {
  62093. name: string;
  62094. shader: string;
  62095. };
  62096. }
  62097. declare module BABYLON {
  62098. /** @hidden */
  62099. export var fxaaVertexShader: {
  62100. name: string;
  62101. shader: string;
  62102. };
  62103. }
  62104. declare module BABYLON {
  62105. /**
  62106. * Fxaa post process
  62107. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62108. */
  62109. export class FxaaPostProcess extends PostProcess {
  62110. /** @hidden */
  62111. texelWidth: number;
  62112. /** @hidden */
  62113. texelHeight: number;
  62114. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62115. private _getDefines;
  62116. }
  62117. }
  62118. declare module BABYLON {
  62119. /** @hidden */
  62120. export var grainPixelShader: {
  62121. name: string;
  62122. shader: string;
  62123. };
  62124. }
  62125. declare module BABYLON {
  62126. /**
  62127. * The GrainPostProcess adds noise to the image at mid luminance levels
  62128. */
  62129. export class GrainPostProcess extends PostProcess {
  62130. /**
  62131. * The intensity of the grain added (default: 30)
  62132. */
  62133. intensity: number;
  62134. /**
  62135. * If the grain should be randomized on every frame
  62136. */
  62137. animated: boolean;
  62138. /**
  62139. * Creates a new instance of @see GrainPostProcess
  62140. * @param name The name of the effect.
  62141. * @param options The required width/height ratio to downsize to before computing the render pass.
  62142. * @param camera The camera to apply the render pass to.
  62143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62144. * @param engine The engine which the post process will be applied. (default: current engine)
  62145. * @param reusable If the post process can be reused on the same frame. (default: false)
  62146. * @param textureType Type of textures used when performing the post process. (default: 0)
  62147. * @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)
  62148. */
  62149. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62150. }
  62151. }
  62152. declare module BABYLON {
  62153. /** @hidden */
  62154. export var highlightsPixelShader: {
  62155. name: string;
  62156. shader: string;
  62157. };
  62158. }
  62159. declare module BABYLON {
  62160. /**
  62161. * Extracts highlights from the image
  62162. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62163. */
  62164. export class HighlightsPostProcess extends PostProcess {
  62165. /**
  62166. * Extracts highlights from the image
  62167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62168. * @param name The name of the effect.
  62169. * @param options The required width/height ratio to downsize to before computing the render pass.
  62170. * @param camera The camera to apply the render pass to.
  62171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62172. * @param engine The engine which the post process will be applied. (default: current engine)
  62173. * @param reusable If the post process can be reused on the same frame. (default: false)
  62174. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62175. */
  62176. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62177. }
  62178. }
  62179. declare module BABYLON {
  62180. /** @hidden */
  62181. export var mrtFragmentDeclaration: {
  62182. name: string;
  62183. shader: string;
  62184. };
  62185. }
  62186. declare module BABYLON {
  62187. /** @hidden */
  62188. export var geometryPixelShader: {
  62189. name: string;
  62190. shader: string;
  62191. };
  62192. }
  62193. declare module BABYLON {
  62194. /** @hidden */
  62195. export var geometryVertexShader: {
  62196. name: string;
  62197. shader: string;
  62198. };
  62199. }
  62200. declare module BABYLON {
  62201. /** @hidden */
  62202. interface ISavedTransformationMatrix {
  62203. world: Matrix;
  62204. viewProjection: Matrix;
  62205. }
  62206. /**
  62207. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62208. */
  62209. export class GeometryBufferRenderer {
  62210. /**
  62211. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62212. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62213. */
  62214. static readonly POSITION_TEXTURE_TYPE: number;
  62215. /**
  62216. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62217. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62218. */
  62219. static readonly VELOCITY_TEXTURE_TYPE: number;
  62220. /**
  62221. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62222. * in order to compute objects velocities when enableVelocity is set to "true"
  62223. * @hidden
  62224. */
  62225. _previousTransformationMatrices: {
  62226. [index: number]: ISavedTransformationMatrix;
  62227. };
  62228. /**
  62229. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62230. * in order to compute objects velocities when enableVelocity is set to "true"
  62231. * @hidden
  62232. */
  62233. _previousBonesTransformationMatrices: {
  62234. [index: number]: Float32Array;
  62235. };
  62236. /**
  62237. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62238. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62239. */
  62240. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62241. private _scene;
  62242. private _multiRenderTarget;
  62243. private _ratio;
  62244. private _enablePosition;
  62245. private _enableVelocity;
  62246. private _positionIndex;
  62247. private _velocityIndex;
  62248. protected _effect: Effect;
  62249. protected _cachedDefines: string;
  62250. /**
  62251. * Set the render list (meshes to be rendered) used in the G buffer.
  62252. */
  62253. renderList: Mesh[];
  62254. /**
  62255. * Gets wether or not G buffer are supported by the running hardware.
  62256. * This requires draw buffer supports
  62257. */
  62258. readonly isSupported: boolean;
  62259. /**
  62260. * Returns the index of the given texture type in the G-Buffer textures array
  62261. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62262. * @returns the index of the given texture type in the G-Buffer textures array
  62263. */
  62264. getTextureIndex(textureType: number): number;
  62265. /**
  62266. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62267. */
  62268. /**
  62269. * Sets whether or not objects positions are enabled for the G buffer.
  62270. */
  62271. enablePosition: boolean;
  62272. /**
  62273. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62274. */
  62275. /**
  62276. * Sets wether or not objects velocities are enabled for the G buffer.
  62277. */
  62278. enableVelocity: boolean;
  62279. /**
  62280. * Gets the scene associated with the buffer.
  62281. */
  62282. readonly scene: Scene;
  62283. /**
  62284. * Gets the ratio used by the buffer during its creation.
  62285. * How big is the buffer related to the main canvas.
  62286. */
  62287. readonly ratio: number;
  62288. /** @hidden */
  62289. static _SceneComponentInitialization: (scene: Scene) => void;
  62290. /**
  62291. * Creates a new G Buffer for the scene
  62292. * @param scene The scene the buffer belongs to
  62293. * @param ratio How big is the buffer related to the main canvas.
  62294. */
  62295. constructor(scene: Scene, ratio?: number);
  62296. /**
  62297. * Checks wether everything is ready to render a submesh to the G buffer.
  62298. * @param subMesh the submesh to check readiness for
  62299. * @param useInstances is the mesh drawn using instance or not
  62300. * @returns true if ready otherwise false
  62301. */
  62302. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62303. /**
  62304. * Gets the current underlying G Buffer.
  62305. * @returns the buffer
  62306. */
  62307. getGBuffer(): MultiRenderTarget;
  62308. /**
  62309. * Gets the number of samples used to render the buffer (anti aliasing).
  62310. */
  62311. /**
  62312. * Sets the number of samples used to render the buffer (anti aliasing).
  62313. */
  62314. samples: number;
  62315. /**
  62316. * Disposes the renderer and frees up associated resources.
  62317. */
  62318. dispose(): void;
  62319. protected _createRenderTargets(): void;
  62320. private _copyBonesTransformationMatrices;
  62321. }
  62322. }
  62323. declare module BABYLON {
  62324. interface Scene {
  62325. /** @hidden (Backing field) */
  62326. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62327. /**
  62328. * Gets or Sets the current geometry buffer associated to the scene.
  62329. */
  62330. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62331. /**
  62332. * Enables a GeometryBufferRender and associates it with the scene
  62333. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62334. * @returns the GeometryBufferRenderer
  62335. */
  62336. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62337. /**
  62338. * Disables the GeometryBufferRender associated with the scene
  62339. */
  62340. disableGeometryBufferRenderer(): void;
  62341. }
  62342. /**
  62343. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62344. * in several rendering techniques.
  62345. */
  62346. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62347. /**
  62348. * The component name helpful to identify the component in the list of scene components.
  62349. */
  62350. readonly name: string;
  62351. /**
  62352. * The scene the component belongs to.
  62353. */
  62354. scene: Scene;
  62355. /**
  62356. * Creates a new instance of the component for the given scene
  62357. * @param scene Defines the scene to register the component in
  62358. */
  62359. constructor(scene: Scene);
  62360. /**
  62361. * Registers the component in a given scene
  62362. */
  62363. register(): void;
  62364. /**
  62365. * Rebuilds the elements related to this component in case of
  62366. * context lost for instance.
  62367. */
  62368. rebuild(): void;
  62369. /**
  62370. * Disposes the component and the associated ressources
  62371. */
  62372. dispose(): void;
  62373. private _gatherRenderTargets;
  62374. }
  62375. }
  62376. declare module BABYLON {
  62377. /** @hidden */
  62378. export var motionBlurPixelShader: {
  62379. name: string;
  62380. shader: string;
  62381. };
  62382. }
  62383. declare module BABYLON {
  62384. /**
  62385. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62386. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62387. * As an example, all you have to do is to create the post-process:
  62388. * var mb = new BABYLON.MotionBlurPostProcess(
  62389. * 'mb', // The name of the effect.
  62390. * scene, // The scene containing the objects to blur according to their velocity.
  62391. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62392. * camera // The camera to apply the render pass to.
  62393. * );
  62394. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62395. */
  62396. export class MotionBlurPostProcess extends PostProcess {
  62397. /**
  62398. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62399. */
  62400. motionStrength: number;
  62401. /**
  62402. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62403. */
  62404. /**
  62405. * Sets the number of iterations to be used for motion blur quality
  62406. */
  62407. motionBlurSamples: number;
  62408. private _motionBlurSamples;
  62409. private _geometryBufferRenderer;
  62410. /**
  62411. * Creates a new instance MotionBlurPostProcess
  62412. * @param name The name of the effect.
  62413. * @param scene The scene containing the objects to blur according to their velocity.
  62414. * @param options The required width/height ratio to downsize to before computing the render pass.
  62415. * @param camera The camera to apply the render pass to.
  62416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62417. * @param engine The engine which the post process will be applied. (default: current engine)
  62418. * @param reusable If the post process can be reused on the same frame. (default: false)
  62419. * @param textureType Type of textures used when performing the post process. (default: 0)
  62420. * @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)
  62421. */
  62422. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62423. /**
  62424. * Excludes the given skinned mesh from computing bones velocities.
  62425. * 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.
  62426. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62427. */
  62428. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62429. /**
  62430. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62431. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62432. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62433. */
  62434. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62435. /**
  62436. * Disposes the post process.
  62437. * @param camera The camera to dispose the post process on.
  62438. */
  62439. dispose(camera?: Camera): void;
  62440. }
  62441. }
  62442. declare module BABYLON {
  62443. /** @hidden */
  62444. export var refractionPixelShader: {
  62445. name: string;
  62446. shader: string;
  62447. };
  62448. }
  62449. declare module BABYLON {
  62450. /**
  62451. * Post process which applies a refractin texture
  62452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62453. */
  62454. export class RefractionPostProcess extends PostProcess {
  62455. /** the base color of the refraction (used to taint the rendering) */
  62456. color: Color3;
  62457. /** simulated refraction depth */
  62458. depth: number;
  62459. /** the coefficient of the base color (0 to remove base color tainting) */
  62460. colorLevel: number;
  62461. private _refTexture;
  62462. private _ownRefractionTexture;
  62463. /**
  62464. * Gets or sets the refraction texture
  62465. * Please note that you are responsible for disposing the texture if you set it manually
  62466. */
  62467. refractionTexture: Texture;
  62468. /**
  62469. * Initializes the RefractionPostProcess
  62470. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62471. * @param name The name of the effect.
  62472. * @param refractionTextureUrl Url of the refraction texture to use
  62473. * @param color the base color of the refraction (used to taint the rendering)
  62474. * @param depth simulated refraction depth
  62475. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62476. * @param camera The camera to apply the render pass to.
  62477. * @param options The required width/height ratio to downsize to before computing the render pass.
  62478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62479. * @param engine The engine which the post process will be applied. (default: current engine)
  62480. * @param reusable If the post process can be reused on the same frame. (default: false)
  62481. */
  62482. constructor(name: string, refractionTextureUrl: string,
  62483. /** the base color of the refraction (used to taint the rendering) */
  62484. color: Color3,
  62485. /** simulated refraction depth */
  62486. depth: number,
  62487. /** the coefficient of the base color (0 to remove base color tainting) */
  62488. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62489. /**
  62490. * Disposes of the post process
  62491. * @param camera Camera to dispose post process on
  62492. */
  62493. dispose(camera: Camera): void;
  62494. }
  62495. }
  62496. declare module BABYLON {
  62497. /** @hidden */
  62498. export var sharpenPixelShader: {
  62499. name: string;
  62500. shader: string;
  62501. };
  62502. }
  62503. declare module BABYLON {
  62504. /**
  62505. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62506. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62507. */
  62508. export class SharpenPostProcess extends PostProcess {
  62509. /**
  62510. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62511. */
  62512. colorAmount: number;
  62513. /**
  62514. * How much sharpness should be applied (default: 0.3)
  62515. */
  62516. edgeAmount: number;
  62517. /**
  62518. * Creates a new instance ConvolutionPostProcess
  62519. * @param name The name of the effect.
  62520. * @param options The required width/height ratio to downsize to before computing the render pass.
  62521. * @param camera The camera to apply the render pass to.
  62522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62523. * @param engine The engine which the post process will be applied. (default: current engine)
  62524. * @param reusable If the post process can be reused on the same frame. (default: false)
  62525. * @param textureType Type of textures used when performing the post process. (default: 0)
  62526. * @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)
  62527. */
  62528. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62529. }
  62530. }
  62531. declare module BABYLON {
  62532. /**
  62533. * PostProcessRenderPipeline
  62534. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62535. */
  62536. export class PostProcessRenderPipeline {
  62537. private engine;
  62538. private _renderEffects;
  62539. private _renderEffectsForIsolatedPass;
  62540. /**
  62541. * List of inspectable custom properties (used by the Inspector)
  62542. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62543. */
  62544. inspectableCustomProperties: IInspectable[];
  62545. /**
  62546. * @hidden
  62547. */
  62548. protected _cameras: Camera[];
  62549. /** @hidden */
  62550. _name: string;
  62551. /**
  62552. * Gets pipeline name
  62553. */
  62554. readonly name: string;
  62555. /** Gets the list of attached cameras */
  62556. readonly cameras: Camera[];
  62557. /**
  62558. * Initializes a PostProcessRenderPipeline
  62559. * @param engine engine to add the pipeline to
  62560. * @param name name of the pipeline
  62561. */
  62562. constructor(engine: Engine, name: string);
  62563. /**
  62564. * Gets the class name
  62565. * @returns "PostProcessRenderPipeline"
  62566. */
  62567. getClassName(): string;
  62568. /**
  62569. * If all the render effects in the pipeline are supported
  62570. */
  62571. readonly isSupported: boolean;
  62572. /**
  62573. * Adds an effect to the pipeline
  62574. * @param renderEffect the effect to add
  62575. */
  62576. addEffect(renderEffect: PostProcessRenderEffect): void;
  62577. /** @hidden */
  62578. _rebuild(): void;
  62579. /** @hidden */
  62580. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62581. /** @hidden */
  62582. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62583. /** @hidden */
  62584. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62585. /** @hidden */
  62586. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62587. /** @hidden */
  62588. _attachCameras(cameras: Camera, unique: boolean): void;
  62589. /** @hidden */
  62590. _attachCameras(cameras: Camera[], unique: boolean): void;
  62591. /** @hidden */
  62592. _detachCameras(cameras: Camera): void;
  62593. /** @hidden */
  62594. _detachCameras(cameras: Nullable<Camera[]>): void;
  62595. /** @hidden */
  62596. _update(): void;
  62597. /** @hidden */
  62598. _reset(): void;
  62599. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62600. /**
  62601. * Disposes of the pipeline
  62602. */
  62603. dispose(): void;
  62604. }
  62605. }
  62606. declare module BABYLON {
  62607. /**
  62608. * PostProcessRenderPipelineManager class
  62609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62610. */
  62611. export class PostProcessRenderPipelineManager {
  62612. private _renderPipelines;
  62613. /**
  62614. * Initializes a PostProcessRenderPipelineManager
  62615. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62616. */
  62617. constructor();
  62618. /**
  62619. * Gets the list of supported render pipelines
  62620. */
  62621. readonly supportedPipelines: PostProcessRenderPipeline[];
  62622. /**
  62623. * Adds a pipeline to the manager
  62624. * @param renderPipeline The pipeline to add
  62625. */
  62626. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62627. /**
  62628. * Attaches a camera to the pipeline
  62629. * @param renderPipelineName The name of the pipeline to attach to
  62630. * @param cameras the camera to attach
  62631. * @param unique if the camera can be attached multiple times to the pipeline
  62632. */
  62633. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62634. /**
  62635. * Detaches a camera from the pipeline
  62636. * @param renderPipelineName The name of the pipeline to detach from
  62637. * @param cameras the camera to detach
  62638. */
  62639. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62640. /**
  62641. * Enables an effect by name on a pipeline
  62642. * @param renderPipelineName the name of the pipeline to enable the effect in
  62643. * @param renderEffectName the name of the effect to enable
  62644. * @param cameras the cameras that the effect should be enabled on
  62645. */
  62646. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62647. /**
  62648. * Disables an effect by name on a pipeline
  62649. * @param renderPipelineName the name of the pipeline to disable the effect in
  62650. * @param renderEffectName the name of the effect to disable
  62651. * @param cameras the cameras that the effect should be disabled on
  62652. */
  62653. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62654. /**
  62655. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62656. */
  62657. update(): void;
  62658. /** @hidden */
  62659. _rebuild(): void;
  62660. /**
  62661. * Disposes of the manager and pipelines
  62662. */
  62663. dispose(): void;
  62664. }
  62665. }
  62666. declare module BABYLON {
  62667. interface Scene {
  62668. /** @hidden (Backing field) */
  62669. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62670. /**
  62671. * Gets the postprocess render pipeline manager
  62672. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62673. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62674. */
  62675. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62676. }
  62677. /**
  62678. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62679. */
  62680. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62681. /**
  62682. * The component name helpfull to identify the component in the list of scene components.
  62683. */
  62684. readonly name: string;
  62685. /**
  62686. * The scene the component belongs to.
  62687. */
  62688. scene: Scene;
  62689. /**
  62690. * Creates a new instance of the component for the given scene
  62691. * @param scene Defines the scene to register the component in
  62692. */
  62693. constructor(scene: Scene);
  62694. /**
  62695. * Registers the component in a given scene
  62696. */
  62697. register(): void;
  62698. /**
  62699. * Rebuilds the elements related to this component in case of
  62700. * context lost for instance.
  62701. */
  62702. rebuild(): void;
  62703. /**
  62704. * Disposes the component and the associated ressources
  62705. */
  62706. dispose(): void;
  62707. private _gatherRenderTargets;
  62708. }
  62709. }
  62710. declare module BABYLON {
  62711. /**
  62712. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62713. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62714. */
  62715. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62716. private _scene;
  62717. private _camerasToBeAttached;
  62718. /**
  62719. * ID of the sharpen post process,
  62720. */
  62721. private readonly SharpenPostProcessId;
  62722. /**
  62723. * @ignore
  62724. * ID of the image processing post process;
  62725. */
  62726. readonly ImageProcessingPostProcessId: string;
  62727. /**
  62728. * @ignore
  62729. * ID of the Fast Approximate Anti-Aliasing post process;
  62730. */
  62731. readonly FxaaPostProcessId: string;
  62732. /**
  62733. * ID of the chromatic aberration post process,
  62734. */
  62735. private readonly ChromaticAberrationPostProcessId;
  62736. /**
  62737. * ID of the grain post process
  62738. */
  62739. private readonly GrainPostProcessId;
  62740. /**
  62741. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62742. */
  62743. sharpen: SharpenPostProcess;
  62744. private _sharpenEffect;
  62745. private bloom;
  62746. /**
  62747. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62748. */
  62749. depthOfField: DepthOfFieldEffect;
  62750. /**
  62751. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62752. */
  62753. fxaa: FxaaPostProcess;
  62754. /**
  62755. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62756. */
  62757. imageProcessing: ImageProcessingPostProcess;
  62758. /**
  62759. * Chromatic aberration post process which will shift rgb colors in the image
  62760. */
  62761. chromaticAberration: ChromaticAberrationPostProcess;
  62762. private _chromaticAberrationEffect;
  62763. /**
  62764. * Grain post process which add noise to the image
  62765. */
  62766. grain: GrainPostProcess;
  62767. private _grainEffect;
  62768. /**
  62769. * Glow post process which adds a glow to emissive areas of the image
  62770. */
  62771. private _glowLayer;
  62772. /**
  62773. * Animations which can be used to tweak settings over a period of time
  62774. */
  62775. animations: Animation[];
  62776. private _imageProcessingConfigurationObserver;
  62777. private _sharpenEnabled;
  62778. private _bloomEnabled;
  62779. private _depthOfFieldEnabled;
  62780. private _depthOfFieldBlurLevel;
  62781. private _fxaaEnabled;
  62782. private _imageProcessingEnabled;
  62783. private _defaultPipelineTextureType;
  62784. private _bloomScale;
  62785. private _chromaticAberrationEnabled;
  62786. private _grainEnabled;
  62787. private _buildAllowed;
  62788. /**
  62789. * Gets active scene
  62790. */
  62791. readonly scene: Scene;
  62792. /**
  62793. * Enable or disable the sharpen process from the pipeline
  62794. */
  62795. sharpenEnabled: boolean;
  62796. private _resizeObserver;
  62797. private _hardwareScaleLevel;
  62798. private _bloomKernel;
  62799. /**
  62800. * Specifies the size of the bloom blur kernel, relative to the final output size
  62801. */
  62802. bloomKernel: number;
  62803. /**
  62804. * Specifies the weight of the bloom in the final rendering
  62805. */
  62806. private _bloomWeight;
  62807. /**
  62808. * Specifies the luma threshold for the area that will be blurred by the bloom
  62809. */
  62810. private _bloomThreshold;
  62811. private _hdr;
  62812. /**
  62813. * The strength of the bloom.
  62814. */
  62815. bloomWeight: number;
  62816. /**
  62817. * The strength of the bloom.
  62818. */
  62819. bloomThreshold: number;
  62820. /**
  62821. * The scale of the bloom, lower value will provide better performance.
  62822. */
  62823. bloomScale: number;
  62824. /**
  62825. * Enable or disable the bloom from the pipeline
  62826. */
  62827. bloomEnabled: boolean;
  62828. private _rebuildBloom;
  62829. /**
  62830. * If the depth of field is enabled.
  62831. */
  62832. depthOfFieldEnabled: boolean;
  62833. /**
  62834. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62835. */
  62836. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62837. /**
  62838. * If the anti aliasing is enabled.
  62839. */
  62840. fxaaEnabled: boolean;
  62841. private _samples;
  62842. /**
  62843. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62844. */
  62845. samples: number;
  62846. /**
  62847. * If image processing is enabled.
  62848. */
  62849. imageProcessingEnabled: boolean;
  62850. /**
  62851. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62852. */
  62853. glowLayerEnabled: boolean;
  62854. /**
  62855. * Gets the glow layer (or null if not defined)
  62856. */
  62857. readonly glowLayer: Nullable<GlowLayer>;
  62858. /**
  62859. * Enable or disable the chromaticAberration process from the pipeline
  62860. */
  62861. chromaticAberrationEnabled: boolean;
  62862. /**
  62863. * Enable or disable the grain process from the pipeline
  62864. */
  62865. grainEnabled: boolean;
  62866. /**
  62867. * @constructor
  62868. * @param name - The rendering pipeline name (default: "")
  62869. * @param hdr - If high dynamic range textures should be used (default: true)
  62870. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62871. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62872. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62873. */
  62874. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62875. /**
  62876. * Get the class name
  62877. * @returns "DefaultRenderingPipeline"
  62878. */
  62879. getClassName(): string;
  62880. /**
  62881. * Force the compilation of the entire pipeline.
  62882. */
  62883. prepare(): void;
  62884. private _hasCleared;
  62885. private _prevPostProcess;
  62886. private _prevPrevPostProcess;
  62887. private _setAutoClearAndTextureSharing;
  62888. private _depthOfFieldSceneObserver;
  62889. private _buildPipeline;
  62890. private _disposePostProcesses;
  62891. /**
  62892. * Adds a camera to the pipeline
  62893. * @param camera the camera to be added
  62894. */
  62895. addCamera(camera: Camera): void;
  62896. /**
  62897. * Removes a camera from the pipeline
  62898. * @param camera the camera to remove
  62899. */
  62900. removeCamera(camera: Camera): void;
  62901. /**
  62902. * Dispose of the pipeline and stop all post processes
  62903. */
  62904. dispose(): void;
  62905. /**
  62906. * Serialize the rendering pipeline (Used when exporting)
  62907. * @returns the serialized object
  62908. */
  62909. serialize(): any;
  62910. /**
  62911. * Parse the serialized pipeline
  62912. * @param source Source pipeline.
  62913. * @param scene The scene to load the pipeline to.
  62914. * @param rootUrl The URL of the serialized pipeline.
  62915. * @returns An instantiated pipeline from the serialized object.
  62916. */
  62917. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62918. }
  62919. }
  62920. declare module BABYLON {
  62921. /** @hidden */
  62922. export var lensHighlightsPixelShader: {
  62923. name: string;
  62924. shader: string;
  62925. };
  62926. }
  62927. declare module BABYLON {
  62928. /** @hidden */
  62929. export var depthOfFieldPixelShader: {
  62930. name: string;
  62931. shader: string;
  62932. };
  62933. }
  62934. declare module BABYLON {
  62935. /**
  62936. * BABYLON.JS Chromatic Aberration GLSL Shader
  62937. * Author: Olivier Guyot
  62938. * Separates very slightly R, G and B colors on the edges of the screen
  62939. * Inspired by Francois Tarlier & Martins Upitis
  62940. */
  62941. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62942. /**
  62943. * @ignore
  62944. * The chromatic aberration PostProcess id in the pipeline
  62945. */
  62946. LensChromaticAberrationEffect: string;
  62947. /**
  62948. * @ignore
  62949. * The highlights enhancing PostProcess id in the pipeline
  62950. */
  62951. HighlightsEnhancingEffect: string;
  62952. /**
  62953. * @ignore
  62954. * The depth-of-field PostProcess id in the pipeline
  62955. */
  62956. LensDepthOfFieldEffect: string;
  62957. private _scene;
  62958. private _depthTexture;
  62959. private _grainTexture;
  62960. private _chromaticAberrationPostProcess;
  62961. private _highlightsPostProcess;
  62962. private _depthOfFieldPostProcess;
  62963. private _edgeBlur;
  62964. private _grainAmount;
  62965. private _chromaticAberration;
  62966. private _distortion;
  62967. private _highlightsGain;
  62968. private _highlightsThreshold;
  62969. private _dofDistance;
  62970. private _dofAperture;
  62971. private _dofDarken;
  62972. private _dofPentagon;
  62973. private _blurNoise;
  62974. /**
  62975. * @constructor
  62976. *
  62977. * Effect parameters are as follow:
  62978. * {
  62979. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62980. * edge_blur: number; // from 0 to x (1 for realism)
  62981. * distortion: number; // from 0 to x (1 for realism)
  62982. * grain_amount: number; // from 0 to 1
  62983. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62984. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62985. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62986. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62987. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62988. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62989. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62990. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62991. * }
  62992. * Note: if an effect parameter is unset, effect is disabled
  62993. *
  62994. * @param name The rendering pipeline name
  62995. * @param parameters - An object containing all parameters (see above)
  62996. * @param scene The scene linked to this pipeline
  62997. * @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)
  62998. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62999. */
  63000. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63001. /**
  63002. * Get the class name
  63003. * @returns "LensRenderingPipeline"
  63004. */
  63005. getClassName(): string;
  63006. /**
  63007. * Gets associated scene
  63008. */
  63009. readonly scene: Scene;
  63010. /**
  63011. * Gets or sets the edge blur
  63012. */
  63013. edgeBlur: number;
  63014. /**
  63015. * Gets or sets the grain amount
  63016. */
  63017. grainAmount: number;
  63018. /**
  63019. * Gets or sets the chromatic aberration amount
  63020. */
  63021. chromaticAberration: number;
  63022. /**
  63023. * Gets or sets the depth of field aperture
  63024. */
  63025. dofAperture: number;
  63026. /**
  63027. * Gets or sets the edge distortion
  63028. */
  63029. edgeDistortion: number;
  63030. /**
  63031. * Gets or sets the depth of field distortion
  63032. */
  63033. dofDistortion: number;
  63034. /**
  63035. * Gets or sets the darken out of focus amount
  63036. */
  63037. darkenOutOfFocus: number;
  63038. /**
  63039. * Gets or sets a boolean indicating if blur noise is enabled
  63040. */
  63041. blurNoise: boolean;
  63042. /**
  63043. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63044. */
  63045. pentagonBokeh: boolean;
  63046. /**
  63047. * Gets or sets the highlight grain amount
  63048. */
  63049. highlightsGain: number;
  63050. /**
  63051. * Gets or sets the highlight threshold
  63052. */
  63053. highlightsThreshold: number;
  63054. /**
  63055. * Sets the amount of blur at the edges
  63056. * @param amount blur amount
  63057. */
  63058. setEdgeBlur(amount: number): void;
  63059. /**
  63060. * Sets edge blur to 0
  63061. */
  63062. disableEdgeBlur(): void;
  63063. /**
  63064. * Sets the amout of grain
  63065. * @param amount Amount of grain
  63066. */
  63067. setGrainAmount(amount: number): void;
  63068. /**
  63069. * Set grain amount to 0
  63070. */
  63071. disableGrain(): void;
  63072. /**
  63073. * Sets the chromatic aberration amount
  63074. * @param amount amount of chromatic aberration
  63075. */
  63076. setChromaticAberration(amount: number): void;
  63077. /**
  63078. * Sets chromatic aberration amount to 0
  63079. */
  63080. disableChromaticAberration(): void;
  63081. /**
  63082. * Sets the EdgeDistortion amount
  63083. * @param amount amount of EdgeDistortion
  63084. */
  63085. setEdgeDistortion(amount: number): void;
  63086. /**
  63087. * Sets edge distortion to 0
  63088. */
  63089. disableEdgeDistortion(): void;
  63090. /**
  63091. * Sets the FocusDistance amount
  63092. * @param amount amount of FocusDistance
  63093. */
  63094. setFocusDistance(amount: number): void;
  63095. /**
  63096. * Disables depth of field
  63097. */
  63098. disableDepthOfField(): void;
  63099. /**
  63100. * Sets the Aperture amount
  63101. * @param amount amount of Aperture
  63102. */
  63103. setAperture(amount: number): void;
  63104. /**
  63105. * Sets the DarkenOutOfFocus amount
  63106. * @param amount amount of DarkenOutOfFocus
  63107. */
  63108. setDarkenOutOfFocus(amount: number): void;
  63109. private _pentagonBokehIsEnabled;
  63110. /**
  63111. * Creates a pentagon bokeh effect
  63112. */
  63113. enablePentagonBokeh(): void;
  63114. /**
  63115. * Disables the pentagon bokeh effect
  63116. */
  63117. disablePentagonBokeh(): void;
  63118. /**
  63119. * Enables noise blur
  63120. */
  63121. enableNoiseBlur(): void;
  63122. /**
  63123. * Disables noise blur
  63124. */
  63125. disableNoiseBlur(): void;
  63126. /**
  63127. * Sets the HighlightsGain amount
  63128. * @param amount amount of HighlightsGain
  63129. */
  63130. setHighlightsGain(amount: number): void;
  63131. /**
  63132. * Sets the HighlightsThreshold amount
  63133. * @param amount amount of HighlightsThreshold
  63134. */
  63135. setHighlightsThreshold(amount: number): void;
  63136. /**
  63137. * Disables highlights
  63138. */
  63139. disableHighlights(): void;
  63140. /**
  63141. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63142. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63143. */
  63144. dispose(disableDepthRender?: boolean): void;
  63145. private _createChromaticAberrationPostProcess;
  63146. private _createHighlightsPostProcess;
  63147. private _createDepthOfFieldPostProcess;
  63148. private _createGrainTexture;
  63149. }
  63150. }
  63151. declare module BABYLON {
  63152. /** @hidden */
  63153. export var ssao2PixelShader: {
  63154. name: string;
  63155. shader: string;
  63156. };
  63157. }
  63158. declare module BABYLON {
  63159. /** @hidden */
  63160. export var ssaoCombinePixelShader: {
  63161. name: string;
  63162. shader: string;
  63163. };
  63164. }
  63165. declare module BABYLON {
  63166. /**
  63167. * Render pipeline to produce ssao effect
  63168. */
  63169. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63170. /**
  63171. * @ignore
  63172. * The PassPostProcess id in the pipeline that contains the original scene color
  63173. */
  63174. SSAOOriginalSceneColorEffect: string;
  63175. /**
  63176. * @ignore
  63177. * The SSAO PostProcess id in the pipeline
  63178. */
  63179. SSAORenderEffect: string;
  63180. /**
  63181. * @ignore
  63182. * The horizontal blur PostProcess id in the pipeline
  63183. */
  63184. SSAOBlurHRenderEffect: string;
  63185. /**
  63186. * @ignore
  63187. * The vertical blur PostProcess id in the pipeline
  63188. */
  63189. SSAOBlurVRenderEffect: string;
  63190. /**
  63191. * @ignore
  63192. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63193. */
  63194. SSAOCombineRenderEffect: string;
  63195. /**
  63196. * The output strength of the SSAO post-process. Default value is 1.0.
  63197. */
  63198. totalStrength: number;
  63199. /**
  63200. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63201. */
  63202. maxZ: number;
  63203. /**
  63204. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63205. */
  63206. minZAspect: number;
  63207. private _samples;
  63208. /**
  63209. * Number of samples used for the SSAO calculations. Default value is 8
  63210. */
  63211. samples: number;
  63212. private _textureSamples;
  63213. /**
  63214. * Number of samples to use for antialiasing
  63215. */
  63216. textureSamples: number;
  63217. /**
  63218. * Ratio object used for SSAO ratio and blur ratio
  63219. */
  63220. private _ratio;
  63221. /**
  63222. * Dynamically generated sphere sampler.
  63223. */
  63224. private _sampleSphere;
  63225. /**
  63226. * Blur filter offsets
  63227. */
  63228. private _samplerOffsets;
  63229. private _expensiveBlur;
  63230. /**
  63231. * If bilateral blur should be used
  63232. */
  63233. expensiveBlur: boolean;
  63234. /**
  63235. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63236. */
  63237. radius: number;
  63238. /**
  63239. * The base color of the SSAO post-process
  63240. * The final result is "base + ssao" between [0, 1]
  63241. */
  63242. base: number;
  63243. /**
  63244. * Support test.
  63245. */
  63246. static readonly IsSupported: boolean;
  63247. private _scene;
  63248. private _depthTexture;
  63249. private _normalTexture;
  63250. private _randomTexture;
  63251. private _originalColorPostProcess;
  63252. private _ssaoPostProcess;
  63253. private _blurHPostProcess;
  63254. private _blurVPostProcess;
  63255. private _ssaoCombinePostProcess;
  63256. /**
  63257. * Gets active scene
  63258. */
  63259. readonly scene: Scene;
  63260. /**
  63261. * @constructor
  63262. * @param name The rendering pipeline name
  63263. * @param scene The scene linked to this pipeline
  63264. * @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 }
  63265. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63266. */
  63267. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63268. /**
  63269. * Get the class name
  63270. * @returns "SSAO2RenderingPipeline"
  63271. */
  63272. getClassName(): string;
  63273. /**
  63274. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63275. */
  63276. dispose(disableGeometryBufferRenderer?: boolean): void;
  63277. private _createBlurPostProcess;
  63278. /** @hidden */
  63279. _rebuild(): void;
  63280. private _bits;
  63281. private _radicalInverse_VdC;
  63282. private _hammersley;
  63283. private _hemisphereSample_uniform;
  63284. private _generateHemisphere;
  63285. private _createSSAOPostProcess;
  63286. private _createSSAOCombinePostProcess;
  63287. private _createRandomTexture;
  63288. /**
  63289. * Serialize the rendering pipeline (Used when exporting)
  63290. * @returns the serialized object
  63291. */
  63292. serialize(): any;
  63293. /**
  63294. * Parse the serialized pipeline
  63295. * @param source Source pipeline.
  63296. * @param scene The scene to load the pipeline to.
  63297. * @param rootUrl The URL of the serialized pipeline.
  63298. * @returns An instantiated pipeline from the serialized object.
  63299. */
  63300. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63301. }
  63302. }
  63303. declare module BABYLON {
  63304. /** @hidden */
  63305. export var ssaoPixelShader: {
  63306. name: string;
  63307. shader: string;
  63308. };
  63309. }
  63310. declare module BABYLON {
  63311. /**
  63312. * Render pipeline to produce ssao effect
  63313. */
  63314. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63315. /**
  63316. * @ignore
  63317. * The PassPostProcess id in the pipeline that contains the original scene color
  63318. */
  63319. SSAOOriginalSceneColorEffect: string;
  63320. /**
  63321. * @ignore
  63322. * The SSAO PostProcess id in the pipeline
  63323. */
  63324. SSAORenderEffect: string;
  63325. /**
  63326. * @ignore
  63327. * The horizontal blur PostProcess id in the pipeline
  63328. */
  63329. SSAOBlurHRenderEffect: string;
  63330. /**
  63331. * @ignore
  63332. * The vertical blur PostProcess id in the pipeline
  63333. */
  63334. SSAOBlurVRenderEffect: string;
  63335. /**
  63336. * @ignore
  63337. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63338. */
  63339. SSAOCombineRenderEffect: string;
  63340. /**
  63341. * The output strength of the SSAO post-process. Default value is 1.0.
  63342. */
  63343. totalStrength: number;
  63344. /**
  63345. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63346. */
  63347. radius: number;
  63348. /**
  63349. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63350. * Must not be equal to fallOff and superior to fallOff.
  63351. * Default value is 0.0075
  63352. */
  63353. area: number;
  63354. /**
  63355. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63356. * Must not be equal to area and inferior to area.
  63357. * Default value is 0.000001
  63358. */
  63359. fallOff: number;
  63360. /**
  63361. * The base color of the SSAO post-process
  63362. * The final result is "base + ssao" between [0, 1]
  63363. */
  63364. base: number;
  63365. private _scene;
  63366. private _depthTexture;
  63367. private _randomTexture;
  63368. private _originalColorPostProcess;
  63369. private _ssaoPostProcess;
  63370. private _blurHPostProcess;
  63371. private _blurVPostProcess;
  63372. private _ssaoCombinePostProcess;
  63373. private _firstUpdate;
  63374. /**
  63375. * Gets active scene
  63376. */
  63377. readonly scene: Scene;
  63378. /**
  63379. * @constructor
  63380. * @param name - The rendering pipeline name
  63381. * @param scene - The scene linked to this pipeline
  63382. * @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 }
  63383. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63384. */
  63385. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63386. /**
  63387. * Get the class name
  63388. * @returns "SSAORenderingPipeline"
  63389. */
  63390. getClassName(): string;
  63391. /**
  63392. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63393. */
  63394. dispose(disableDepthRender?: boolean): void;
  63395. private _createBlurPostProcess;
  63396. /** @hidden */
  63397. _rebuild(): void;
  63398. private _createSSAOPostProcess;
  63399. private _createSSAOCombinePostProcess;
  63400. private _createRandomTexture;
  63401. }
  63402. }
  63403. declare module BABYLON {
  63404. /** @hidden */
  63405. export var standardPixelShader: {
  63406. name: string;
  63407. shader: string;
  63408. };
  63409. }
  63410. declare module BABYLON {
  63411. /**
  63412. * Standard rendering pipeline
  63413. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63414. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63415. */
  63416. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63417. /**
  63418. * Public members
  63419. */
  63420. /**
  63421. * Post-process which contains the original scene color before the pipeline applies all the effects
  63422. */
  63423. originalPostProcess: Nullable<PostProcess>;
  63424. /**
  63425. * Post-process used to down scale an image x4
  63426. */
  63427. downSampleX4PostProcess: Nullable<PostProcess>;
  63428. /**
  63429. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63430. */
  63431. brightPassPostProcess: Nullable<PostProcess>;
  63432. /**
  63433. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63434. */
  63435. blurHPostProcesses: PostProcess[];
  63436. /**
  63437. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63438. */
  63439. blurVPostProcesses: PostProcess[];
  63440. /**
  63441. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63442. */
  63443. textureAdderPostProcess: Nullable<PostProcess>;
  63444. /**
  63445. * Post-process used to create volumetric lighting effect
  63446. */
  63447. volumetricLightPostProcess: Nullable<PostProcess>;
  63448. /**
  63449. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63450. */
  63451. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63452. /**
  63453. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63454. */
  63455. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63456. /**
  63457. * Post-process used to merge the volumetric light effect and the real scene color
  63458. */
  63459. volumetricLightMergePostProces: Nullable<PostProcess>;
  63460. /**
  63461. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63462. */
  63463. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63464. /**
  63465. * Base post-process used to calculate the average luminance of the final image for HDR
  63466. */
  63467. luminancePostProcess: Nullable<PostProcess>;
  63468. /**
  63469. * Post-processes used to create down sample post-processes in order to get
  63470. * the average luminance of the final image for HDR
  63471. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63472. */
  63473. luminanceDownSamplePostProcesses: PostProcess[];
  63474. /**
  63475. * Post-process used to create a HDR effect (light adaptation)
  63476. */
  63477. hdrPostProcess: Nullable<PostProcess>;
  63478. /**
  63479. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63480. */
  63481. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63482. /**
  63483. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63484. */
  63485. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63486. /**
  63487. * Post-process used to merge the final HDR post-process and the real scene color
  63488. */
  63489. hdrFinalPostProcess: Nullable<PostProcess>;
  63490. /**
  63491. * Post-process used to create a lens flare effect
  63492. */
  63493. lensFlarePostProcess: Nullable<PostProcess>;
  63494. /**
  63495. * Post-process that merges the result of the lens flare post-process and the real scene color
  63496. */
  63497. lensFlareComposePostProcess: Nullable<PostProcess>;
  63498. /**
  63499. * Post-process used to create a motion blur effect
  63500. */
  63501. motionBlurPostProcess: Nullable<PostProcess>;
  63502. /**
  63503. * Post-process used to create a depth of field effect
  63504. */
  63505. depthOfFieldPostProcess: Nullable<PostProcess>;
  63506. /**
  63507. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63508. */
  63509. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63510. /**
  63511. * Represents the brightness threshold in order to configure the illuminated surfaces
  63512. */
  63513. brightThreshold: number;
  63514. /**
  63515. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63516. */
  63517. blurWidth: number;
  63518. /**
  63519. * Sets if the blur for highlighted surfaces must be only horizontal
  63520. */
  63521. horizontalBlur: boolean;
  63522. /**
  63523. * Gets the overall exposure used by the pipeline
  63524. */
  63525. /**
  63526. * Sets the overall exposure used by the pipeline
  63527. */
  63528. exposure: number;
  63529. /**
  63530. * Texture used typically to simulate "dirty" on camera lens
  63531. */
  63532. lensTexture: Nullable<Texture>;
  63533. /**
  63534. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63535. */
  63536. volumetricLightCoefficient: number;
  63537. /**
  63538. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63539. */
  63540. volumetricLightPower: number;
  63541. /**
  63542. * Used the set the blur intensity to smooth the volumetric lights
  63543. */
  63544. volumetricLightBlurScale: number;
  63545. /**
  63546. * Light (spot or directional) used to generate the volumetric lights rays
  63547. * The source light must have a shadow generate so the pipeline can get its
  63548. * depth map
  63549. */
  63550. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63551. /**
  63552. * For eye adaptation, represents the minimum luminance the eye can see
  63553. */
  63554. hdrMinimumLuminance: number;
  63555. /**
  63556. * For eye adaptation, represents the decrease luminance speed
  63557. */
  63558. hdrDecreaseRate: number;
  63559. /**
  63560. * For eye adaptation, represents the increase luminance speed
  63561. */
  63562. hdrIncreaseRate: number;
  63563. /**
  63564. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63565. */
  63566. /**
  63567. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63568. */
  63569. hdrAutoExposure: boolean;
  63570. /**
  63571. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63572. */
  63573. lensColorTexture: Nullable<Texture>;
  63574. /**
  63575. * The overall strengh for the lens flare effect
  63576. */
  63577. lensFlareStrength: number;
  63578. /**
  63579. * Dispersion coefficient for lens flare ghosts
  63580. */
  63581. lensFlareGhostDispersal: number;
  63582. /**
  63583. * Main lens flare halo width
  63584. */
  63585. lensFlareHaloWidth: number;
  63586. /**
  63587. * Based on the lens distortion effect, defines how much the lens flare result
  63588. * is distorted
  63589. */
  63590. lensFlareDistortionStrength: number;
  63591. /**
  63592. * Configures the blur intensity used for for lens flare (halo)
  63593. */
  63594. lensFlareBlurWidth: number;
  63595. /**
  63596. * Lens star texture must be used to simulate rays on the flares and is available
  63597. * in the documentation
  63598. */
  63599. lensStarTexture: Nullable<Texture>;
  63600. /**
  63601. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63602. * flare effect by taking account of the dirt texture
  63603. */
  63604. lensFlareDirtTexture: Nullable<Texture>;
  63605. /**
  63606. * Represents the focal length for the depth of field effect
  63607. */
  63608. depthOfFieldDistance: number;
  63609. /**
  63610. * Represents the blur intensity for the blurred part of the depth of field effect
  63611. */
  63612. depthOfFieldBlurWidth: number;
  63613. /**
  63614. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63615. */
  63616. /**
  63617. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63618. */
  63619. motionStrength: number;
  63620. /**
  63621. * Gets wether or not the motion blur post-process is object based or screen based.
  63622. */
  63623. /**
  63624. * Sets wether or not the motion blur post-process should be object based or screen based
  63625. */
  63626. objectBasedMotionBlur: boolean;
  63627. /**
  63628. * List of animations for the pipeline (IAnimatable implementation)
  63629. */
  63630. animations: Animation[];
  63631. /**
  63632. * Private members
  63633. */
  63634. private _scene;
  63635. private _currentDepthOfFieldSource;
  63636. private _basePostProcess;
  63637. private _fixedExposure;
  63638. private _currentExposure;
  63639. private _hdrAutoExposure;
  63640. private _hdrCurrentLuminance;
  63641. private _motionStrength;
  63642. private _isObjectBasedMotionBlur;
  63643. private _floatTextureType;
  63644. private _camerasToBeAttached;
  63645. private _ratio;
  63646. private _bloomEnabled;
  63647. private _depthOfFieldEnabled;
  63648. private _vlsEnabled;
  63649. private _lensFlareEnabled;
  63650. private _hdrEnabled;
  63651. private _motionBlurEnabled;
  63652. private _fxaaEnabled;
  63653. private _motionBlurSamples;
  63654. private _volumetricLightStepsCount;
  63655. private _samples;
  63656. /**
  63657. * @ignore
  63658. * Specifies if the bloom pipeline is enabled
  63659. */
  63660. BloomEnabled: boolean;
  63661. /**
  63662. * @ignore
  63663. * Specifies if the depth of field pipeline is enabed
  63664. */
  63665. DepthOfFieldEnabled: boolean;
  63666. /**
  63667. * @ignore
  63668. * Specifies if the lens flare pipeline is enabed
  63669. */
  63670. LensFlareEnabled: boolean;
  63671. /**
  63672. * @ignore
  63673. * Specifies if the HDR pipeline is enabled
  63674. */
  63675. HDREnabled: boolean;
  63676. /**
  63677. * @ignore
  63678. * Specifies if the volumetric lights scattering effect is enabled
  63679. */
  63680. VLSEnabled: boolean;
  63681. /**
  63682. * @ignore
  63683. * Specifies if the motion blur effect is enabled
  63684. */
  63685. MotionBlurEnabled: boolean;
  63686. /**
  63687. * Specifies if anti-aliasing is enabled
  63688. */
  63689. fxaaEnabled: boolean;
  63690. /**
  63691. * Specifies the number of steps used to calculate the volumetric lights
  63692. * Typically in interval [50, 200]
  63693. */
  63694. volumetricLightStepsCount: number;
  63695. /**
  63696. * Specifies the number of samples used for the motion blur effect
  63697. * Typically in interval [16, 64]
  63698. */
  63699. motionBlurSamples: number;
  63700. /**
  63701. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63702. */
  63703. samples: number;
  63704. /**
  63705. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63706. * @constructor
  63707. * @param name The rendering pipeline name
  63708. * @param scene The scene linked to this pipeline
  63709. * @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)
  63710. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63711. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63712. */
  63713. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63714. private _buildPipeline;
  63715. private _createDownSampleX4PostProcess;
  63716. private _createBrightPassPostProcess;
  63717. private _createBlurPostProcesses;
  63718. private _createTextureAdderPostProcess;
  63719. private _createVolumetricLightPostProcess;
  63720. private _createLuminancePostProcesses;
  63721. private _createHdrPostProcess;
  63722. private _createLensFlarePostProcess;
  63723. private _createDepthOfFieldPostProcess;
  63724. private _createMotionBlurPostProcess;
  63725. private _getDepthTexture;
  63726. private _disposePostProcesses;
  63727. /**
  63728. * Dispose of the pipeline and stop all post processes
  63729. */
  63730. dispose(): void;
  63731. /**
  63732. * Serialize the rendering pipeline (Used when exporting)
  63733. * @returns the serialized object
  63734. */
  63735. serialize(): any;
  63736. /**
  63737. * Parse the serialized pipeline
  63738. * @param source Source pipeline.
  63739. * @param scene The scene to load the pipeline to.
  63740. * @param rootUrl The URL of the serialized pipeline.
  63741. * @returns An instantiated pipeline from the serialized object.
  63742. */
  63743. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63744. /**
  63745. * Luminance steps
  63746. */
  63747. static LuminanceSteps: number;
  63748. }
  63749. }
  63750. declare module BABYLON {
  63751. /** @hidden */
  63752. export var tonemapPixelShader: {
  63753. name: string;
  63754. shader: string;
  63755. };
  63756. }
  63757. declare module BABYLON {
  63758. /** Defines operator used for tonemapping */
  63759. export enum TonemappingOperator {
  63760. /** Hable */
  63761. Hable = 0,
  63762. /** Reinhard */
  63763. Reinhard = 1,
  63764. /** HejiDawson */
  63765. HejiDawson = 2,
  63766. /** Photographic */
  63767. Photographic = 3
  63768. }
  63769. /**
  63770. * Defines a post process to apply tone mapping
  63771. */
  63772. export class TonemapPostProcess extends PostProcess {
  63773. private _operator;
  63774. /** Defines the required exposure adjustement */
  63775. exposureAdjustment: number;
  63776. /**
  63777. * Creates a new TonemapPostProcess
  63778. * @param name defines the name of the postprocess
  63779. * @param _operator defines the operator to use
  63780. * @param exposureAdjustment defines the required exposure adjustement
  63781. * @param camera defines the camera to use (can be null)
  63782. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63783. * @param engine defines the hosting engine (can be ignore if camera is set)
  63784. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63785. */
  63786. constructor(name: string, _operator: TonemappingOperator,
  63787. /** Defines the required exposure adjustement */
  63788. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63789. }
  63790. }
  63791. declare module BABYLON {
  63792. /** @hidden */
  63793. export var depthVertexShader: {
  63794. name: string;
  63795. shader: string;
  63796. };
  63797. }
  63798. declare module BABYLON {
  63799. /** @hidden */
  63800. export var volumetricLightScatteringPixelShader: {
  63801. name: string;
  63802. shader: string;
  63803. };
  63804. }
  63805. declare module BABYLON {
  63806. /** @hidden */
  63807. export var volumetricLightScatteringPassVertexShader: {
  63808. name: string;
  63809. shader: string;
  63810. };
  63811. }
  63812. declare module BABYLON {
  63813. /** @hidden */
  63814. export var volumetricLightScatteringPassPixelShader: {
  63815. name: string;
  63816. shader: string;
  63817. };
  63818. }
  63819. declare module BABYLON {
  63820. /**
  63821. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63822. */
  63823. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63824. private _volumetricLightScatteringPass;
  63825. private _volumetricLightScatteringRTT;
  63826. private _viewPort;
  63827. private _screenCoordinates;
  63828. private _cachedDefines;
  63829. /**
  63830. * If not undefined, the mesh position is computed from the attached node position
  63831. */
  63832. attachedNode: {
  63833. position: Vector3;
  63834. };
  63835. /**
  63836. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63837. */
  63838. customMeshPosition: Vector3;
  63839. /**
  63840. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63841. */
  63842. useCustomMeshPosition: boolean;
  63843. /**
  63844. * If the post-process should inverse the light scattering direction
  63845. */
  63846. invert: boolean;
  63847. /**
  63848. * The internal mesh used by the post-process
  63849. */
  63850. mesh: Mesh;
  63851. /**
  63852. * @hidden
  63853. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63854. */
  63855. useDiffuseColor: boolean;
  63856. /**
  63857. * Array containing the excluded meshes not rendered in the internal pass
  63858. */
  63859. excludedMeshes: AbstractMesh[];
  63860. /**
  63861. * Controls the overall intensity of the post-process
  63862. */
  63863. exposure: number;
  63864. /**
  63865. * Dissipates each sample's contribution in range [0, 1]
  63866. */
  63867. decay: number;
  63868. /**
  63869. * Controls the overall intensity of each sample
  63870. */
  63871. weight: number;
  63872. /**
  63873. * Controls the density of each sample
  63874. */
  63875. density: number;
  63876. /**
  63877. * @constructor
  63878. * @param name The post-process name
  63879. * @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)
  63880. * @param camera The camera that the post-process will be attached to
  63881. * @param mesh The mesh used to create the light scattering
  63882. * @param samples The post-process quality, default 100
  63883. * @param samplingModeThe post-process filtering mode
  63884. * @param engine The babylon engine
  63885. * @param reusable If the post-process is reusable
  63886. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63887. */
  63888. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63889. /**
  63890. * Returns the string "VolumetricLightScatteringPostProcess"
  63891. * @returns "VolumetricLightScatteringPostProcess"
  63892. */
  63893. getClassName(): string;
  63894. private _isReady;
  63895. /**
  63896. * Sets the new light position for light scattering effect
  63897. * @param position The new custom light position
  63898. */
  63899. setCustomMeshPosition(position: Vector3): void;
  63900. /**
  63901. * Returns the light position for light scattering effect
  63902. * @return Vector3 The custom light position
  63903. */
  63904. getCustomMeshPosition(): Vector3;
  63905. /**
  63906. * Disposes the internal assets and detaches the post-process from the camera
  63907. */
  63908. dispose(camera: Camera): void;
  63909. /**
  63910. * Returns the render target texture used by the post-process
  63911. * @return the render target texture used by the post-process
  63912. */
  63913. getPass(): RenderTargetTexture;
  63914. private _meshExcluded;
  63915. private _createPass;
  63916. private _updateMeshScreenCoordinates;
  63917. /**
  63918. * Creates a default mesh for the Volumeric Light Scattering post-process
  63919. * @param name The mesh name
  63920. * @param scene The scene where to create the mesh
  63921. * @return the default mesh
  63922. */
  63923. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63924. }
  63925. }
  63926. declare module BABYLON {
  63927. interface Scene {
  63928. /** @hidden (Backing field) */
  63929. _boundingBoxRenderer: BoundingBoxRenderer;
  63930. /** @hidden (Backing field) */
  63931. _forceShowBoundingBoxes: boolean;
  63932. /**
  63933. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63934. */
  63935. forceShowBoundingBoxes: boolean;
  63936. /**
  63937. * Gets the bounding box renderer associated with the scene
  63938. * @returns a BoundingBoxRenderer
  63939. */
  63940. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63941. }
  63942. interface AbstractMesh {
  63943. /** @hidden (Backing field) */
  63944. _showBoundingBox: boolean;
  63945. /**
  63946. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63947. */
  63948. showBoundingBox: boolean;
  63949. }
  63950. /**
  63951. * Component responsible of rendering the bounding box of the meshes in a scene.
  63952. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63953. */
  63954. export class BoundingBoxRenderer implements ISceneComponent {
  63955. /**
  63956. * The component name helpfull to identify the component in the list of scene components.
  63957. */
  63958. readonly name: string;
  63959. /**
  63960. * The scene the component belongs to.
  63961. */
  63962. scene: Scene;
  63963. /**
  63964. * Color of the bounding box lines placed in front of an object
  63965. */
  63966. frontColor: Color3;
  63967. /**
  63968. * Color of the bounding box lines placed behind an object
  63969. */
  63970. backColor: Color3;
  63971. /**
  63972. * Defines if the renderer should show the back lines or not
  63973. */
  63974. showBackLines: boolean;
  63975. /**
  63976. * @hidden
  63977. */
  63978. renderList: SmartArray<BoundingBox>;
  63979. private _colorShader;
  63980. private _vertexBuffers;
  63981. private _indexBuffer;
  63982. private _fillIndexBuffer;
  63983. private _fillIndexData;
  63984. /**
  63985. * Instantiates a new bounding box renderer in a scene.
  63986. * @param scene the scene the renderer renders in
  63987. */
  63988. constructor(scene: Scene);
  63989. /**
  63990. * Registers the component in a given scene
  63991. */
  63992. register(): void;
  63993. private _evaluateSubMesh;
  63994. private _activeMesh;
  63995. private _prepareRessources;
  63996. private _createIndexBuffer;
  63997. /**
  63998. * Rebuilds the elements related to this component in case of
  63999. * context lost for instance.
  64000. */
  64001. rebuild(): void;
  64002. /**
  64003. * @hidden
  64004. */
  64005. reset(): void;
  64006. /**
  64007. * Render the bounding boxes of a specific rendering group
  64008. * @param renderingGroupId defines the rendering group to render
  64009. */
  64010. render(renderingGroupId: number): void;
  64011. /**
  64012. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64013. * @param mesh Define the mesh to render the occlusion bounding box for
  64014. */
  64015. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64016. /**
  64017. * Dispose and release the resources attached to this renderer.
  64018. */
  64019. dispose(): void;
  64020. }
  64021. }
  64022. declare module BABYLON {
  64023. /** @hidden */
  64024. export var depthPixelShader: {
  64025. name: string;
  64026. shader: string;
  64027. };
  64028. }
  64029. declare module BABYLON {
  64030. /**
  64031. * This represents a depth renderer in Babylon.
  64032. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64033. */
  64034. export class DepthRenderer {
  64035. private _scene;
  64036. private _depthMap;
  64037. private _effect;
  64038. private readonly _storeNonLinearDepth;
  64039. private readonly _clearColor;
  64040. /** Get if the depth renderer is using packed depth or not */
  64041. readonly isPacked: boolean;
  64042. private _cachedDefines;
  64043. private _camera;
  64044. /**
  64045. * Specifiess that the depth renderer will only be used within
  64046. * the camera it is created for.
  64047. * This can help forcing its rendering during the camera processing.
  64048. */
  64049. useOnlyInActiveCamera: boolean;
  64050. /** @hidden */
  64051. static _SceneComponentInitialization: (scene: Scene) => void;
  64052. /**
  64053. * Instantiates a depth renderer
  64054. * @param scene The scene the renderer belongs to
  64055. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64056. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64057. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64058. */
  64059. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64060. /**
  64061. * Creates the depth rendering effect and checks if the effect is ready.
  64062. * @param subMesh The submesh to be used to render the depth map of
  64063. * @param useInstances If multiple world instances should be used
  64064. * @returns if the depth renderer is ready to render the depth map
  64065. */
  64066. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64067. /**
  64068. * Gets the texture which the depth map will be written to.
  64069. * @returns The depth map texture
  64070. */
  64071. getDepthMap(): RenderTargetTexture;
  64072. /**
  64073. * Disposes of the depth renderer.
  64074. */
  64075. dispose(): void;
  64076. }
  64077. }
  64078. declare module BABYLON {
  64079. interface Scene {
  64080. /** @hidden (Backing field) */
  64081. _depthRenderer: {
  64082. [id: string]: DepthRenderer;
  64083. };
  64084. /**
  64085. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64086. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64087. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64088. * @returns the created depth renderer
  64089. */
  64090. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64091. /**
  64092. * Disables a depth renderer for a given camera
  64093. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64094. */
  64095. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64096. }
  64097. /**
  64098. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64099. * in several rendering techniques.
  64100. */
  64101. export class DepthRendererSceneComponent implements ISceneComponent {
  64102. /**
  64103. * The component name helpfull to identify the component in the list of scene components.
  64104. */
  64105. readonly name: string;
  64106. /**
  64107. * The scene the component belongs to.
  64108. */
  64109. scene: Scene;
  64110. /**
  64111. * Creates a new instance of the component for the given scene
  64112. * @param scene Defines the scene to register the component in
  64113. */
  64114. constructor(scene: Scene);
  64115. /**
  64116. * Registers the component in a given scene
  64117. */
  64118. register(): void;
  64119. /**
  64120. * Rebuilds the elements related to this component in case of
  64121. * context lost for instance.
  64122. */
  64123. rebuild(): void;
  64124. /**
  64125. * Disposes the component and the associated ressources
  64126. */
  64127. dispose(): void;
  64128. private _gatherRenderTargets;
  64129. private _gatherActiveCameraRenderTargets;
  64130. }
  64131. }
  64132. declare module BABYLON {
  64133. /** @hidden */
  64134. export var outlinePixelShader: {
  64135. name: string;
  64136. shader: string;
  64137. };
  64138. }
  64139. declare module BABYLON {
  64140. /** @hidden */
  64141. export var outlineVertexShader: {
  64142. name: string;
  64143. shader: string;
  64144. };
  64145. }
  64146. declare module BABYLON {
  64147. interface Scene {
  64148. /** @hidden */
  64149. _outlineRenderer: OutlineRenderer;
  64150. /**
  64151. * Gets the outline renderer associated with the scene
  64152. * @returns a OutlineRenderer
  64153. */
  64154. getOutlineRenderer(): OutlineRenderer;
  64155. }
  64156. interface AbstractMesh {
  64157. /** @hidden (Backing field) */
  64158. _renderOutline: boolean;
  64159. /**
  64160. * Gets or sets a boolean indicating if the outline must be rendered as well
  64161. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64162. */
  64163. renderOutline: boolean;
  64164. /** @hidden (Backing field) */
  64165. _renderOverlay: boolean;
  64166. /**
  64167. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64168. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64169. */
  64170. renderOverlay: boolean;
  64171. }
  64172. /**
  64173. * This class is responsible to draw bothe outline/overlay of meshes.
  64174. * It should not be used directly but through the available method on mesh.
  64175. */
  64176. export class OutlineRenderer implements ISceneComponent {
  64177. /**
  64178. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64179. */
  64180. private static _StencilReference;
  64181. /**
  64182. * The name of the component. Each component must have a unique name.
  64183. */
  64184. name: string;
  64185. /**
  64186. * The scene the component belongs to.
  64187. */
  64188. scene: Scene;
  64189. /**
  64190. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64191. */
  64192. zOffset: number;
  64193. private _engine;
  64194. private _effect;
  64195. private _cachedDefines;
  64196. private _savedDepthWrite;
  64197. /**
  64198. * Instantiates a new outline renderer. (There could be only one per scene).
  64199. * @param scene Defines the scene it belongs to
  64200. */
  64201. constructor(scene: Scene);
  64202. /**
  64203. * Register the component to one instance of a scene.
  64204. */
  64205. register(): void;
  64206. /**
  64207. * Rebuilds the elements related to this component in case of
  64208. * context lost for instance.
  64209. */
  64210. rebuild(): void;
  64211. /**
  64212. * Disposes the component and the associated ressources.
  64213. */
  64214. dispose(): void;
  64215. /**
  64216. * Renders the outline in the canvas.
  64217. * @param subMesh Defines the sumesh to render
  64218. * @param batch Defines the batch of meshes in case of instances
  64219. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64220. */
  64221. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64222. /**
  64223. * Returns whether or not the outline renderer is ready for a given submesh.
  64224. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64225. * @param subMesh Defines the submesh to check readyness for
  64226. * @param useInstances Defines wheter wee are trying to render instances or not
  64227. * @returns true if ready otherwise false
  64228. */
  64229. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64230. private _beforeRenderingMesh;
  64231. private _afterRenderingMesh;
  64232. }
  64233. }
  64234. declare module BABYLON {
  64235. /**
  64236. * Defines the basic options interface of a Sprite Frame Source Size.
  64237. */
  64238. export interface ISpriteJSONSpriteSourceSize {
  64239. /**
  64240. * number of the original width of the Frame
  64241. */
  64242. w: number;
  64243. /**
  64244. * number of the original height of the Frame
  64245. */
  64246. h: number;
  64247. }
  64248. /**
  64249. * Defines the basic options interface of a Sprite Frame Data.
  64250. */
  64251. export interface ISpriteJSONSpriteFrameData {
  64252. /**
  64253. * number of the x offset of the Frame
  64254. */
  64255. x: number;
  64256. /**
  64257. * number of the y offset of the Frame
  64258. */
  64259. y: number;
  64260. /**
  64261. * number of the width of the Frame
  64262. */
  64263. w: number;
  64264. /**
  64265. * number of the height of the Frame
  64266. */
  64267. h: number;
  64268. }
  64269. /**
  64270. * Defines the basic options interface of a JSON Sprite.
  64271. */
  64272. export interface ISpriteJSONSprite {
  64273. /**
  64274. * string name of the Frame
  64275. */
  64276. filename: string;
  64277. /**
  64278. * ISpriteJSONSpriteFrame basic object of the frame data
  64279. */
  64280. frame: ISpriteJSONSpriteFrameData;
  64281. /**
  64282. * boolean to flag is the frame was rotated.
  64283. */
  64284. rotated: boolean;
  64285. /**
  64286. * boolean to flag is the frame was trimmed.
  64287. */
  64288. trimmed: boolean;
  64289. /**
  64290. * ISpriteJSONSpriteFrame basic object of the source data
  64291. */
  64292. spriteSourceSize: ISpriteJSONSpriteFrameData;
  64293. /**
  64294. * ISpriteJSONSpriteFrame basic object of the source data
  64295. */
  64296. sourceSize: ISpriteJSONSpriteSourceSize;
  64297. }
  64298. /**
  64299. * Defines the basic options interface of a JSON atlas.
  64300. */
  64301. export interface ISpriteJSONAtlas {
  64302. /**
  64303. * Array of objects that contain the frame data.
  64304. */
  64305. frames: Array<ISpriteJSONSprite>;
  64306. /**
  64307. * object basic object containing the sprite meta data.
  64308. */
  64309. meta?: object;
  64310. }
  64311. }
  64312. declare module BABYLON {
  64313. /** @hidden */
  64314. export var spriteMapPixelShader: {
  64315. name: string;
  64316. shader: string;
  64317. };
  64318. }
  64319. declare module BABYLON {
  64320. /** @hidden */
  64321. export var spriteMapVertexShader: {
  64322. name: string;
  64323. shader: string;
  64324. };
  64325. }
  64326. declare module BABYLON {
  64327. /**
  64328. * Defines the basic options interface of a SpriteMap
  64329. */
  64330. export interface ISpriteMapOptions {
  64331. /**
  64332. * Vector2 of the number of cells in the grid.
  64333. */
  64334. stageSize?: Vector2;
  64335. /**
  64336. * Vector2 of the size of the output plane in World Units.
  64337. */
  64338. outputSize?: Vector2;
  64339. /**
  64340. * Vector3 of the position of the output plane in World Units.
  64341. */
  64342. outputPosition?: Vector3;
  64343. /**
  64344. * Vector3 of the rotation of the output plane.
  64345. */
  64346. outputRotation?: Vector3;
  64347. /**
  64348. * number of layers that the system will reserve in resources.
  64349. */
  64350. layerCount?: number;
  64351. /**
  64352. * number of max animation frames a single cell will reserve in resources.
  64353. */
  64354. maxAnimationFrames?: number;
  64355. /**
  64356. * number cell index of the base tile when the system compiles.
  64357. */
  64358. baseTile?: number;
  64359. /**
  64360. * boolean flip the sprite after its been repositioned by the framing data.
  64361. */
  64362. flipU?: boolean;
  64363. /**
  64364. * Vector3 scalar of the global RGB values of the SpriteMap.
  64365. */
  64366. colorMultiply?: Vector3;
  64367. }
  64368. /**
  64369. * Defines the IDisposable interface in order to be cleanable from resources.
  64370. */
  64371. export interface ISpriteMap extends IDisposable {
  64372. /**
  64373. * String name of the SpriteMap.
  64374. */
  64375. name: string;
  64376. /**
  64377. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  64378. */
  64379. atlasJSON: ISpriteJSONAtlas;
  64380. /**
  64381. * Texture of the SpriteMap.
  64382. */
  64383. spriteSheet: Texture;
  64384. /**
  64385. * The parameters to initialize the SpriteMap with.
  64386. */
  64387. options: ISpriteMapOptions;
  64388. }
  64389. /**
  64390. * Class used to manage a grid restricted sprite deployment on an Output plane.
  64391. */
  64392. export class SpriteMap implements ISpriteMap {
  64393. /** The Name of the spriteMap */
  64394. name: string;
  64395. /** The JSON file with the frame and meta data */
  64396. atlasJSON: ISpriteJSONAtlas;
  64397. /** The systems Sprite Sheet Texture */
  64398. spriteSheet: Texture;
  64399. /** Arguments passed with the Constructor */
  64400. options: ISpriteMapOptions;
  64401. /** Public Sprite Storage array, parsed from atlasJSON */
  64402. sprites: Array<ISpriteJSONSprite>;
  64403. /** Returns the Number of Sprites in the System */
  64404. readonly spriteCount: number;
  64405. /** Returns the Position of Output Plane*/
  64406. /** Returns the Position of Output Plane*/
  64407. position: Vector3;
  64408. /** Returns the Rotation of Output Plane*/
  64409. /** Returns the Rotation of Output Plane*/
  64410. rotation: Vector3;
  64411. /** Sets the AnimationMap*/
  64412. /** Sets the AnimationMap*/
  64413. animationMap: RawTexture;
  64414. /** Scene that the SpriteMap was created in */
  64415. private _scene;
  64416. /** Texture Buffer of Float32 that holds tile frame data*/
  64417. private _frameMap;
  64418. /** Texture Buffers of Float32 that holds tileMap data*/
  64419. private _tileMaps;
  64420. /** Texture Buffer of Float32 that holds Animation Data*/
  64421. private _animationMap;
  64422. /** Custom ShaderMaterial Central to the System*/
  64423. private _material;
  64424. /** Custom ShaderMaterial Central to the System*/
  64425. private _output;
  64426. /** Systems Time Ticker*/
  64427. private _time;
  64428. /**
  64429. * Creates a new SpriteMap
  64430. * @param name defines the SpriteMaps Name
  64431. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  64432. * @param spriteSheet is the Texture that the Sprites are on.
  64433. * @param options a basic deployment configuration
  64434. * @param scene The Scene that the map is deployed on
  64435. */
  64436. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  64437. /**
  64438. * Returns tileID location
  64439. * @returns Vector2 the cell position ID
  64440. */
  64441. getTileID(): Vector2;
  64442. /**
  64443. * Gets the UV location of the mouse over the SpriteMap.
  64444. * @returns Vector2 the UV position of the mouse interaction
  64445. */
  64446. getMousePosition(): Vector2;
  64447. /**
  64448. * Creates the "frame" texture Buffer
  64449. * -------------------------------------
  64450. * Structure of frames
  64451. * "filename": "Falling-Water-2.png",
  64452. * "frame": {"x":69,"y":103,"w":24,"h":32},
  64453. * "rotated": true,
  64454. * "trimmed": true,
  64455. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  64456. * "sourceSize": {"w":32,"h":32}
  64457. * @returns RawTexture of the frameMap
  64458. */
  64459. private _createFrameBuffer;
  64460. /**
  64461. * Creates the tileMap texture Buffer
  64462. * @param buffer normally and array of numbers, or a false to generate from scratch
  64463. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  64464. * @returns RawTexture of the tileMap
  64465. */
  64466. private _createTileBuffer;
  64467. /**
  64468. * Modifies the data of the tileMaps
  64469. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  64470. * @param pos is the iVector2 Coordinates of the Tile
  64471. * @param tile The SpriteIndex of the new Tile
  64472. */
  64473. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  64474. /**
  64475. * Creates the animationMap texture Buffer
  64476. * @param buffer normally and array of numbers, or a false to generate from scratch
  64477. * @returns RawTexture of the animationMap
  64478. */
  64479. private _createTileAnimationBuffer;
  64480. /**
  64481. * Modifies the data of the animationMap
  64482. * @param cellID is the Index of the Sprite
  64483. * @param _frame is the target Animation frame
  64484. * @param toCell is the Target Index of the next frame of the animation
  64485. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  64486. * @param speed is a global scalar of the time variable on the map.
  64487. */
  64488. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  64489. /**
  64490. * Exports the .tilemaps file
  64491. */
  64492. saveTileMaps(): void;
  64493. /**
  64494. * Imports the .tilemaps file
  64495. * @param url of the .tilemaps file
  64496. */
  64497. loadTileMaps(url: string): void;
  64498. /**
  64499. * Release associated resources
  64500. */
  64501. dispose(): void;
  64502. }
  64503. }
  64504. declare module BABYLON {
  64505. /**
  64506. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64507. * @see http://doc.babylonjs.com/babylon101/sprites
  64508. */
  64509. export class SpritePackedManager extends SpriteManager {
  64510. /** defines the packed manager's name */
  64511. name: string;
  64512. /**
  64513. * Creates a new sprite manager from a packed sprite sheet
  64514. * @param name defines the manager's name
  64515. * @param imgUrl defines the sprite sheet url
  64516. * @param capacity defines the maximum allowed number of sprites
  64517. * @param scene defines the hosting scene
  64518. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64519. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64520. * @param samplingMode defines the smapling mode to use with spritesheet
  64521. * @param fromPacked set to true; do not alter
  64522. */
  64523. constructor(
  64524. /** defines the packed manager's name */
  64525. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64526. }
  64527. }
  64528. declare module BABYLON {
  64529. /**
  64530. * Defines the list of states available for a task inside a AssetsManager
  64531. */
  64532. export enum AssetTaskState {
  64533. /**
  64534. * Initialization
  64535. */
  64536. INIT = 0,
  64537. /**
  64538. * Running
  64539. */
  64540. RUNNING = 1,
  64541. /**
  64542. * Done
  64543. */
  64544. DONE = 2,
  64545. /**
  64546. * Error
  64547. */
  64548. ERROR = 3
  64549. }
  64550. /**
  64551. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64552. */
  64553. export abstract class AbstractAssetTask {
  64554. /**
  64555. * Task name
  64556. */ name: string;
  64557. /**
  64558. * Callback called when the task is successful
  64559. */
  64560. onSuccess: (task: any) => void;
  64561. /**
  64562. * Callback called when the task is not successful
  64563. */
  64564. onError: (task: any, message?: string, exception?: any) => void;
  64565. /**
  64566. * Creates a new AssetsManager
  64567. * @param name defines the name of the task
  64568. */
  64569. constructor(
  64570. /**
  64571. * Task name
  64572. */ name: string);
  64573. private _isCompleted;
  64574. private _taskState;
  64575. private _errorObject;
  64576. /**
  64577. * Get if the task is completed
  64578. */
  64579. readonly isCompleted: boolean;
  64580. /**
  64581. * Gets the current state of the task
  64582. */
  64583. readonly taskState: AssetTaskState;
  64584. /**
  64585. * Gets the current error object (if task is in error)
  64586. */
  64587. readonly errorObject: {
  64588. message?: string;
  64589. exception?: any;
  64590. };
  64591. /**
  64592. * Internal only
  64593. * @hidden
  64594. */
  64595. _setErrorObject(message?: string, exception?: any): void;
  64596. /**
  64597. * Execute the current task
  64598. * @param scene defines the scene where you want your assets to be loaded
  64599. * @param onSuccess is a callback called when the task is successfully executed
  64600. * @param onError is a callback called if an error occurs
  64601. */
  64602. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64603. /**
  64604. * Execute the current task
  64605. * @param scene defines the scene where you want your assets to be loaded
  64606. * @param onSuccess is a callback called when the task is successfully executed
  64607. * @param onError is a callback called if an error occurs
  64608. */
  64609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64610. /**
  64611. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64612. * This can be used with failed tasks that have the reason for failure fixed.
  64613. */
  64614. reset(): void;
  64615. private onErrorCallback;
  64616. private onDoneCallback;
  64617. }
  64618. /**
  64619. * Define the interface used by progress events raised during assets loading
  64620. */
  64621. export interface IAssetsProgressEvent {
  64622. /**
  64623. * Defines the number of remaining tasks to process
  64624. */
  64625. remainingCount: number;
  64626. /**
  64627. * Defines the total number of tasks
  64628. */
  64629. totalCount: number;
  64630. /**
  64631. * Defines the task that was just processed
  64632. */
  64633. task: AbstractAssetTask;
  64634. }
  64635. /**
  64636. * Class used to share progress information about assets loading
  64637. */
  64638. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64639. /**
  64640. * Defines the number of remaining tasks to process
  64641. */
  64642. remainingCount: number;
  64643. /**
  64644. * Defines the total number of tasks
  64645. */
  64646. totalCount: number;
  64647. /**
  64648. * Defines the task that was just processed
  64649. */
  64650. task: AbstractAssetTask;
  64651. /**
  64652. * Creates a AssetsProgressEvent
  64653. * @param remainingCount defines the number of remaining tasks to process
  64654. * @param totalCount defines the total number of tasks
  64655. * @param task defines the task that was just processed
  64656. */
  64657. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64658. }
  64659. /**
  64660. * Define a task used by AssetsManager to load meshes
  64661. */
  64662. export class MeshAssetTask extends AbstractAssetTask {
  64663. /**
  64664. * Defines the name of the task
  64665. */
  64666. name: string;
  64667. /**
  64668. * Defines the list of mesh's names you want to load
  64669. */
  64670. meshesNames: any;
  64671. /**
  64672. * Defines the root url to use as a base to load your meshes and associated resources
  64673. */
  64674. rootUrl: string;
  64675. /**
  64676. * Defines the filename of the scene to load from
  64677. */
  64678. sceneFilename: string;
  64679. /**
  64680. * Gets the list of loaded meshes
  64681. */
  64682. loadedMeshes: Array<AbstractMesh>;
  64683. /**
  64684. * Gets the list of loaded particle systems
  64685. */
  64686. loadedParticleSystems: Array<IParticleSystem>;
  64687. /**
  64688. * Gets the list of loaded skeletons
  64689. */
  64690. loadedSkeletons: Array<Skeleton>;
  64691. /**
  64692. * Gets the list of loaded animation groups
  64693. */
  64694. loadedAnimationGroups: Array<AnimationGroup>;
  64695. /**
  64696. * Callback called when the task is successful
  64697. */
  64698. onSuccess: (task: MeshAssetTask) => void;
  64699. /**
  64700. * Callback called when the task is successful
  64701. */
  64702. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64703. /**
  64704. * Creates a new MeshAssetTask
  64705. * @param name defines the name of the task
  64706. * @param meshesNames defines the list of mesh's names you want to load
  64707. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64708. * @param sceneFilename defines the filename of the scene to load from
  64709. */
  64710. constructor(
  64711. /**
  64712. * Defines the name of the task
  64713. */
  64714. name: string,
  64715. /**
  64716. * Defines the list of mesh's names you want to load
  64717. */
  64718. meshesNames: any,
  64719. /**
  64720. * Defines the root url to use as a base to load your meshes and associated resources
  64721. */
  64722. rootUrl: string,
  64723. /**
  64724. * Defines the filename of the scene to load from
  64725. */
  64726. sceneFilename: string);
  64727. /**
  64728. * Execute the current task
  64729. * @param scene defines the scene where you want your assets to be loaded
  64730. * @param onSuccess is a callback called when the task is successfully executed
  64731. * @param onError is a callback called if an error occurs
  64732. */
  64733. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64734. }
  64735. /**
  64736. * Define a task used by AssetsManager to load text content
  64737. */
  64738. export class TextFileAssetTask extends AbstractAssetTask {
  64739. /**
  64740. * Defines the name of the task
  64741. */
  64742. name: string;
  64743. /**
  64744. * Defines the location of the file to load
  64745. */
  64746. url: string;
  64747. /**
  64748. * Gets the loaded text string
  64749. */
  64750. text: string;
  64751. /**
  64752. * Callback called when the task is successful
  64753. */
  64754. onSuccess: (task: TextFileAssetTask) => void;
  64755. /**
  64756. * Callback called when the task is successful
  64757. */
  64758. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64759. /**
  64760. * Creates a new TextFileAssetTask object
  64761. * @param name defines the name of the task
  64762. * @param url defines the location of the file to load
  64763. */
  64764. constructor(
  64765. /**
  64766. * Defines the name of the task
  64767. */
  64768. name: string,
  64769. /**
  64770. * Defines the location of the file to load
  64771. */
  64772. url: string);
  64773. /**
  64774. * Execute the current task
  64775. * @param scene defines the scene where you want your assets to be loaded
  64776. * @param onSuccess is a callback called when the task is successfully executed
  64777. * @param onError is a callback called if an error occurs
  64778. */
  64779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64780. }
  64781. /**
  64782. * Define a task used by AssetsManager to load binary data
  64783. */
  64784. export class BinaryFileAssetTask extends AbstractAssetTask {
  64785. /**
  64786. * Defines the name of the task
  64787. */
  64788. name: string;
  64789. /**
  64790. * Defines the location of the file to load
  64791. */
  64792. url: string;
  64793. /**
  64794. * Gets the lodaded data (as an array buffer)
  64795. */
  64796. data: ArrayBuffer;
  64797. /**
  64798. * Callback called when the task is successful
  64799. */
  64800. onSuccess: (task: BinaryFileAssetTask) => void;
  64801. /**
  64802. * Callback called when the task is successful
  64803. */
  64804. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64805. /**
  64806. * Creates a new BinaryFileAssetTask object
  64807. * @param name defines the name of the new task
  64808. * @param url defines the location of the file to load
  64809. */
  64810. constructor(
  64811. /**
  64812. * Defines the name of the task
  64813. */
  64814. name: string,
  64815. /**
  64816. * Defines the location of the file to load
  64817. */
  64818. url: string);
  64819. /**
  64820. * Execute the current task
  64821. * @param scene defines the scene where you want your assets to be loaded
  64822. * @param onSuccess is a callback called when the task is successfully executed
  64823. * @param onError is a callback called if an error occurs
  64824. */
  64825. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64826. }
  64827. /**
  64828. * Define a task used by AssetsManager to load images
  64829. */
  64830. export class ImageAssetTask extends AbstractAssetTask {
  64831. /**
  64832. * Defines the name of the task
  64833. */
  64834. name: string;
  64835. /**
  64836. * Defines the location of the image to load
  64837. */
  64838. url: string;
  64839. /**
  64840. * Gets the loaded images
  64841. */
  64842. image: HTMLImageElement;
  64843. /**
  64844. * Callback called when the task is successful
  64845. */
  64846. onSuccess: (task: ImageAssetTask) => void;
  64847. /**
  64848. * Callback called when the task is successful
  64849. */
  64850. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64851. /**
  64852. * Creates a new ImageAssetTask
  64853. * @param name defines the name of the task
  64854. * @param url defines the location of the image to load
  64855. */
  64856. constructor(
  64857. /**
  64858. * Defines the name of the task
  64859. */
  64860. name: string,
  64861. /**
  64862. * Defines the location of the image to load
  64863. */
  64864. url: string);
  64865. /**
  64866. * Execute the current task
  64867. * @param scene defines the scene where you want your assets to be loaded
  64868. * @param onSuccess is a callback called when the task is successfully executed
  64869. * @param onError is a callback called if an error occurs
  64870. */
  64871. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64872. }
  64873. /**
  64874. * Defines the interface used by texture loading tasks
  64875. */
  64876. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64877. /**
  64878. * Gets the loaded texture
  64879. */
  64880. texture: TEX;
  64881. }
  64882. /**
  64883. * Define a task used by AssetsManager to load 2D textures
  64884. */
  64885. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64886. /**
  64887. * Defines the name of the task
  64888. */
  64889. name: string;
  64890. /**
  64891. * Defines the location of the file to load
  64892. */
  64893. url: string;
  64894. /**
  64895. * Defines if mipmap should not be generated (default is false)
  64896. */
  64897. noMipmap?: boolean | undefined;
  64898. /**
  64899. * Defines if texture must be inverted on Y axis (default is false)
  64900. */
  64901. invertY?: boolean | undefined;
  64902. /**
  64903. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64904. */
  64905. samplingMode: number;
  64906. /**
  64907. * Gets the loaded texture
  64908. */
  64909. texture: Texture;
  64910. /**
  64911. * Callback called when the task is successful
  64912. */
  64913. onSuccess: (task: TextureAssetTask) => void;
  64914. /**
  64915. * Callback called when the task is successful
  64916. */
  64917. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64918. /**
  64919. * Creates a new TextureAssetTask object
  64920. * @param name defines the name of the task
  64921. * @param url defines the location of the file to load
  64922. * @param noMipmap defines if mipmap should not be generated (default is false)
  64923. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64924. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64925. */
  64926. constructor(
  64927. /**
  64928. * Defines the name of the task
  64929. */
  64930. name: string,
  64931. /**
  64932. * Defines the location of the file to load
  64933. */
  64934. url: string,
  64935. /**
  64936. * Defines if mipmap should not be generated (default is false)
  64937. */
  64938. noMipmap?: boolean | undefined,
  64939. /**
  64940. * Defines if texture must be inverted on Y axis (default is false)
  64941. */
  64942. invertY?: boolean | undefined,
  64943. /**
  64944. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64945. */
  64946. samplingMode?: number);
  64947. /**
  64948. * Execute the current task
  64949. * @param scene defines the scene where you want your assets to be loaded
  64950. * @param onSuccess is a callback called when the task is successfully executed
  64951. * @param onError is a callback called if an error occurs
  64952. */
  64953. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64954. }
  64955. /**
  64956. * Define a task used by AssetsManager to load cube textures
  64957. */
  64958. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64959. /**
  64960. * Defines the name of the task
  64961. */
  64962. name: string;
  64963. /**
  64964. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64965. */
  64966. url: string;
  64967. /**
  64968. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64969. */
  64970. extensions?: string[] | undefined;
  64971. /**
  64972. * Defines if mipmaps should not be generated (default is false)
  64973. */
  64974. noMipmap?: boolean | undefined;
  64975. /**
  64976. * Defines the explicit list of files (undefined by default)
  64977. */
  64978. files?: string[] | undefined;
  64979. /**
  64980. * Gets the loaded texture
  64981. */
  64982. texture: CubeTexture;
  64983. /**
  64984. * Callback called when the task is successful
  64985. */
  64986. onSuccess: (task: CubeTextureAssetTask) => void;
  64987. /**
  64988. * Callback called when the task is successful
  64989. */
  64990. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64991. /**
  64992. * Creates a new CubeTextureAssetTask
  64993. * @param name defines the name of the task
  64994. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64995. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64996. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64997. * @param files defines the explicit list of files (undefined by default)
  64998. */
  64999. constructor(
  65000. /**
  65001. * Defines the name of the task
  65002. */
  65003. name: string,
  65004. /**
  65005. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65006. */
  65007. url: string,
  65008. /**
  65009. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65010. */
  65011. extensions?: string[] | undefined,
  65012. /**
  65013. * Defines if mipmaps should not be generated (default is false)
  65014. */
  65015. noMipmap?: boolean | undefined,
  65016. /**
  65017. * Defines the explicit list of files (undefined by default)
  65018. */
  65019. files?: string[] | undefined);
  65020. /**
  65021. * Execute the current task
  65022. * @param scene defines the scene where you want your assets to be loaded
  65023. * @param onSuccess is a callback called when the task is successfully executed
  65024. * @param onError is a callback called if an error occurs
  65025. */
  65026. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65027. }
  65028. /**
  65029. * Define a task used by AssetsManager to load HDR cube textures
  65030. */
  65031. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65032. /**
  65033. * Defines the name of the task
  65034. */
  65035. name: string;
  65036. /**
  65037. * Defines the location of the file to load
  65038. */
  65039. url: string;
  65040. /**
  65041. * Defines the desired size (the more it increases the longer the generation will be)
  65042. */
  65043. size: number;
  65044. /**
  65045. * Defines if mipmaps should not be generated (default is false)
  65046. */
  65047. noMipmap: boolean;
  65048. /**
  65049. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65050. */
  65051. generateHarmonics: boolean;
  65052. /**
  65053. * 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)
  65054. */
  65055. gammaSpace: boolean;
  65056. /**
  65057. * Internal Use Only
  65058. */
  65059. reserved: boolean;
  65060. /**
  65061. * Gets the loaded texture
  65062. */
  65063. texture: HDRCubeTexture;
  65064. /**
  65065. * Callback called when the task is successful
  65066. */
  65067. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65068. /**
  65069. * Callback called when the task is successful
  65070. */
  65071. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65072. /**
  65073. * Creates a new HDRCubeTextureAssetTask object
  65074. * @param name defines the name of the task
  65075. * @param url defines the location of the file to load
  65076. * @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.
  65077. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65078. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65079. * @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)
  65080. * @param reserved Internal use only
  65081. */
  65082. constructor(
  65083. /**
  65084. * Defines the name of the task
  65085. */
  65086. name: string,
  65087. /**
  65088. * Defines the location of the file to load
  65089. */
  65090. url: string,
  65091. /**
  65092. * Defines the desired size (the more it increases the longer the generation will be)
  65093. */
  65094. size: number,
  65095. /**
  65096. * Defines if mipmaps should not be generated (default is false)
  65097. */
  65098. noMipmap?: boolean,
  65099. /**
  65100. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65101. */
  65102. generateHarmonics?: boolean,
  65103. /**
  65104. * 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)
  65105. */
  65106. gammaSpace?: boolean,
  65107. /**
  65108. * Internal Use Only
  65109. */
  65110. reserved?: boolean);
  65111. /**
  65112. * Execute the current task
  65113. * @param scene defines the scene where you want your assets to be loaded
  65114. * @param onSuccess is a callback called when the task is successfully executed
  65115. * @param onError is a callback called if an error occurs
  65116. */
  65117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65118. }
  65119. /**
  65120. * Define a task used by AssetsManager to load Equirectangular cube textures
  65121. */
  65122. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65123. /**
  65124. * Defines the name of the task
  65125. */
  65126. name: string;
  65127. /**
  65128. * Defines the location of the file to load
  65129. */
  65130. url: string;
  65131. /**
  65132. * Defines the desired size (the more it increases the longer the generation will be)
  65133. */
  65134. size: number;
  65135. /**
  65136. * Defines if mipmaps should not be generated (default is false)
  65137. */
  65138. noMipmap: boolean;
  65139. /**
  65140. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65141. * but the standard material would require them in Gamma space) (default is true)
  65142. */
  65143. gammaSpace: boolean;
  65144. /**
  65145. * Gets the loaded texture
  65146. */
  65147. texture: EquiRectangularCubeTexture;
  65148. /**
  65149. * Callback called when the task is successful
  65150. */
  65151. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65152. /**
  65153. * Callback called when the task is successful
  65154. */
  65155. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65156. /**
  65157. * Creates a new EquiRectangularCubeTextureAssetTask object
  65158. * @param name defines the name of the task
  65159. * @param url defines the location of the file to load
  65160. * @param size defines the desired size (the more it increases the longer the generation will be)
  65161. * If the size is omitted this implies you are using a preprocessed cubemap.
  65162. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65163. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65164. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65165. * (default is true)
  65166. */
  65167. constructor(
  65168. /**
  65169. * Defines the name of the task
  65170. */
  65171. name: string,
  65172. /**
  65173. * Defines the location of the file to load
  65174. */
  65175. url: string,
  65176. /**
  65177. * Defines the desired size (the more it increases the longer the generation will be)
  65178. */
  65179. size: number,
  65180. /**
  65181. * Defines if mipmaps should not be generated (default is false)
  65182. */
  65183. noMipmap?: boolean,
  65184. /**
  65185. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65186. * but the standard material would require them in Gamma space) (default is true)
  65187. */
  65188. gammaSpace?: boolean);
  65189. /**
  65190. * Execute the current task
  65191. * @param scene defines the scene where you want your assets to be loaded
  65192. * @param onSuccess is a callback called when the task is successfully executed
  65193. * @param onError is a callback called if an error occurs
  65194. */
  65195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65196. }
  65197. /**
  65198. * This class can be used to easily import assets into a scene
  65199. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65200. */
  65201. export class AssetsManager {
  65202. private _scene;
  65203. private _isLoading;
  65204. protected _tasks: AbstractAssetTask[];
  65205. protected _waitingTasksCount: number;
  65206. protected _totalTasksCount: number;
  65207. /**
  65208. * Callback called when all tasks are processed
  65209. */
  65210. onFinish: (tasks: AbstractAssetTask[]) => void;
  65211. /**
  65212. * Callback called when a task is successful
  65213. */
  65214. onTaskSuccess: (task: AbstractAssetTask) => void;
  65215. /**
  65216. * Callback called when a task had an error
  65217. */
  65218. onTaskError: (task: AbstractAssetTask) => void;
  65219. /**
  65220. * Callback called when a task is done (whatever the result is)
  65221. */
  65222. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65223. /**
  65224. * Observable called when all tasks are processed
  65225. */
  65226. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65227. /**
  65228. * Observable called when a task had an error
  65229. */
  65230. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65231. /**
  65232. * Observable called when all tasks were executed
  65233. */
  65234. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65235. /**
  65236. * Observable called when a task is done (whatever the result is)
  65237. */
  65238. onProgressObservable: Observable<IAssetsProgressEvent>;
  65239. /**
  65240. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65241. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65242. */
  65243. useDefaultLoadingScreen: boolean;
  65244. /**
  65245. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65246. * when all assets have been downloaded.
  65247. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65248. */
  65249. autoHideLoadingUI: boolean;
  65250. /**
  65251. * Creates a new AssetsManager
  65252. * @param scene defines the scene to work on
  65253. */
  65254. constructor(scene: Scene);
  65255. /**
  65256. * Add a MeshAssetTask to the list of active tasks
  65257. * @param taskName defines the name of the new task
  65258. * @param meshesNames defines the name of meshes to load
  65259. * @param rootUrl defines the root url to use to locate files
  65260. * @param sceneFilename defines the filename of the scene file
  65261. * @returns a new MeshAssetTask object
  65262. */
  65263. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65264. /**
  65265. * Add a TextFileAssetTask to the list of active tasks
  65266. * @param taskName defines the name of the new task
  65267. * @param url defines the url of the file to load
  65268. * @returns a new TextFileAssetTask object
  65269. */
  65270. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65271. /**
  65272. * Add a BinaryFileAssetTask to the list of active tasks
  65273. * @param taskName defines the name of the new task
  65274. * @param url defines the url of the file to load
  65275. * @returns a new BinaryFileAssetTask object
  65276. */
  65277. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65278. /**
  65279. * Add a ImageAssetTask to the list of active tasks
  65280. * @param taskName defines the name of the new task
  65281. * @param url defines the url of the file to load
  65282. * @returns a new ImageAssetTask object
  65283. */
  65284. addImageTask(taskName: string, url: string): ImageAssetTask;
  65285. /**
  65286. * Add a TextureAssetTask to the list of active tasks
  65287. * @param taskName defines the name of the new task
  65288. * @param url defines the url of the file to load
  65289. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65290. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65291. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65292. * @returns a new TextureAssetTask object
  65293. */
  65294. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65295. /**
  65296. * Add a CubeTextureAssetTask to the list of active tasks
  65297. * @param taskName defines the name of the new task
  65298. * @param url defines the url of the file to load
  65299. * @param extensions defines the extension to use to load the cube map (can be null)
  65300. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65301. * @param files defines the list of files to load (can be null)
  65302. * @returns a new CubeTextureAssetTask object
  65303. */
  65304. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65305. /**
  65306. *
  65307. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65308. * @param taskName defines the name of the new task
  65309. * @param url defines the url of the file to load
  65310. * @param size defines the size you want for the cubemap (can be null)
  65311. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65312. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65313. * @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)
  65314. * @param reserved Internal use only
  65315. * @returns a new HDRCubeTextureAssetTask object
  65316. */
  65317. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65318. /**
  65319. *
  65320. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65321. * @param taskName defines the name of the new task
  65322. * @param url defines the url of the file to load
  65323. * @param size defines the size you want for the cubemap (can be null)
  65324. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65325. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65326. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65327. * @returns a new EquiRectangularCubeTextureAssetTask object
  65328. */
  65329. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65330. /**
  65331. * Remove a task from the assets manager.
  65332. * @param task the task to remove
  65333. */
  65334. removeTask(task: AbstractAssetTask): void;
  65335. private _decreaseWaitingTasksCount;
  65336. private _runTask;
  65337. /**
  65338. * Reset the AssetsManager and remove all tasks
  65339. * @return the current instance of the AssetsManager
  65340. */
  65341. reset(): AssetsManager;
  65342. /**
  65343. * Start the loading process
  65344. * @return the current instance of the AssetsManager
  65345. */
  65346. load(): AssetsManager;
  65347. /**
  65348. * Start the loading process as an async operation
  65349. * @return a promise returning the list of failed tasks
  65350. */
  65351. loadAsync(): Promise<void>;
  65352. }
  65353. }
  65354. declare module BABYLON {
  65355. /**
  65356. * Wrapper class for promise with external resolve and reject.
  65357. */
  65358. export class Deferred<T> {
  65359. /**
  65360. * The promise associated with this deferred object.
  65361. */
  65362. readonly promise: Promise<T>;
  65363. private _resolve;
  65364. private _reject;
  65365. /**
  65366. * The resolve method of the promise associated with this deferred object.
  65367. */
  65368. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65369. /**
  65370. * The reject method of the promise associated with this deferred object.
  65371. */
  65372. readonly reject: (reason?: any) => void;
  65373. /**
  65374. * Constructor for this deferred object.
  65375. */
  65376. constructor();
  65377. }
  65378. }
  65379. declare module BABYLON {
  65380. /**
  65381. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65382. */
  65383. export class MeshExploder {
  65384. private _centerMesh;
  65385. private _meshes;
  65386. private _meshesOrigins;
  65387. private _toCenterVectors;
  65388. private _scaledDirection;
  65389. private _newPosition;
  65390. private _centerPosition;
  65391. /**
  65392. * Explodes meshes from a center mesh.
  65393. * @param meshes The meshes to explode.
  65394. * @param centerMesh The mesh to be center of explosion.
  65395. */
  65396. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65397. private _setCenterMesh;
  65398. /**
  65399. * Get class name
  65400. * @returns "MeshExploder"
  65401. */
  65402. getClassName(): string;
  65403. /**
  65404. * "Exploded meshes"
  65405. * @returns Array of meshes with the centerMesh at index 0.
  65406. */
  65407. getMeshes(): Array<Mesh>;
  65408. /**
  65409. * Explodes meshes giving a specific direction
  65410. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65411. */
  65412. explode(direction?: number): void;
  65413. }
  65414. }
  65415. declare module BABYLON {
  65416. /**
  65417. * Class used to help managing file picking and drag'n'drop
  65418. */
  65419. export class FilesInput {
  65420. /**
  65421. * List of files ready to be loaded
  65422. */
  65423. static readonly FilesToLoad: {
  65424. [key: string]: File;
  65425. };
  65426. /**
  65427. * Callback called when a file is processed
  65428. */
  65429. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65430. private _engine;
  65431. private _currentScene;
  65432. private _sceneLoadedCallback;
  65433. private _progressCallback;
  65434. private _additionalRenderLoopLogicCallback;
  65435. private _textureLoadingCallback;
  65436. private _startingProcessingFilesCallback;
  65437. private _onReloadCallback;
  65438. private _errorCallback;
  65439. private _elementToMonitor;
  65440. private _sceneFileToLoad;
  65441. private _filesToLoad;
  65442. /**
  65443. * Creates a new FilesInput
  65444. * @param engine defines the rendering engine
  65445. * @param scene defines the hosting scene
  65446. * @param sceneLoadedCallback callback called when scene is loaded
  65447. * @param progressCallback callback called to track progress
  65448. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65449. * @param textureLoadingCallback callback called when a texture is loading
  65450. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65451. * @param onReloadCallback callback called when a reload is requested
  65452. * @param errorCallback callback call if an error occurs
  65453. */
  65454. 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);
  65455. private _dragEnterHandler;
  65456. private _dragOverHandler;
  65457. private _dropHandler;
  65458. /**
  65459. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65460. * @param elementToMonitor defines the DOM element to track
  65461. */
  65462. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65463. /**
  65464. * Release all associated resources
  65465. */
  65466. dispose(): void;
  65467. private renderFunction;
  65468. private drag;
  65469. private drop;
  65470. private _traverseFolder;
  65471. private _processFiles;
  65472. /**
  65473. * Load files from a drop event
  65474. * @param event defines the drop event to use as source
  65475. */
  65476. loadFiles(event: any): void;
  65477. private _processReload;
  65478. /**
  65479. * Reload the current scene from the loaded files
  65480. */
  65481. reload(): void;
  65482. }
  65483. }
  65484. declare module BABYLON {
  65485. /**
  65486. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65487. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65488. */
  65489. export class SceneOptimization {
  65490. /**
  65491. * Defines the priority of this optimization (0 by default which means first in the list)
  65492. */
  65493. priority: number;
  65494. /**
  65495. * Gets a string describing the action executed by the current optimization
  65496. * @returns description string
  65497. */
  65498. getDescription(): string;
  65499. /**
  65500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65501. * @param scene defines the current scene where to apply this optimization
  65502. * @param optimizer defines the current optimizer
  65503. * @returns true if everything that can be done was applied
  65504. */
  65505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65506. /**
  65507. * Creates the SceneOptimization object
  65508. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65509. * @param desc defines the description associated with the optimization
  65510. */
  65511. constructor(
  65512. /**
  65513. * Defines the priority of this optimization (0 by default which means first in the list)
  65514. */
  65515. priority?: number);
  65516. }
  65517. /**
  65518. * Defines an optimization used to reduce the size of render target textures
  65519. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65520. */
  65521. export class TextureOptimization extends SceneOptimization {
  65522. /**
  65523. * Defines the priority of this optimization (0 by default which means first in the list)
  65524. */
  65525. priority: number;
  65526. /**
  65527. * 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
  65528. */
  65529. maximumSize: number;
  65530. /**
  65531. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65532. */
  65533. step: number;
  65534. /**
  65535. * Gets a string describing the action executed by the current optimization
  65536. * @returns description string
  65537. */
  65538. getDescription(): string;
  65539. /**
  65540. * Creates the TextureOptimization object
  65541. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65542. * @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
  65543. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65544. */
  65545. constructor(
  65546. /**
  65547. * Defines the priority of this optimization (0 by default which means first in the list)
  65548. */
  65549. priority?: number,
  65550. /**
  65551. * 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
  65552. */
  65553. maximumSize?: number,
  65554. /**
  65555. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65556. */
  65557. step?: number);
  65558. /**
  65559. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65560. * @param scene defines the current scene where to apply this optimization
  65561. * @param optimizer defines the current optimizer
  65562. * @returns true if everything that can be done was applied
  65563. */
  65564. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65565. }
  65566. /**
  65567. * Defines an optimization used to increase or decrease the rendering resolution
  65568. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65569. */
  65570. export class HardwareScalingOptimization extends SceneOptimization {
  65571. /**
  65572. * Defines the priority of this optimization (0 by default which means first in the list)
  65573. */
  65574. priority: number;
  65575. /**
  65576. * Defines the maximum scale to use (2 by default)
  65577. */
  65578. maximumScale: number;
  65579. /**
  65580. * Defines the step to use between two passes (0.5 by default)
  65581. */
  65582. step: number;
  65583. private _currentScale;
  65584. private _directionOffset;
  65585. /**
  65586. * Gets a string describing the action executed by the current optimization
  65587. * @return description string
  65588. */
  65589. getDescription(): string;
  65590. /**
  65591. * Creates the HardwareScalingOptimization object
  65592. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65593. * @param maximumScale defines the maximum scale to use (2 by default)
  65594. * @param step defines the step to use between two passes (0.5 by default)
  65595. */
  65596. constructor(
  65597. /**
  65598. * Defines the priority of this optimization (0 by default which means first in the list)
  65599. */
  65600. priority?: number,
  65601. /**
  65602. * Defines the maximum scale to use (2 by default)
  65603. */
  65604. maximumScale?: number,
  65605. /**
  65606. * Defines the step to use between two passes (0.5 by default)
  65607. */
  65608. step?: number);
  65609. /**
  65610. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65611. * @param scene defines the current scene where to apply this optimization
  65612. * @param optimizer defines the current optimizer
  65613. * @returns true if everything that can be done was applied
  65614. */
  65615. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65616. }
  65617. /**
  65618. * Defines an optimization used to remove shadows
  65619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65620. */
  65621. export class ShadowsOptimization extends SceneOptimization {
  65622. /**
  65623. * Gets a string describing the action executed by the current optimization
  65624. * @return description string
  65625. */
  65626. getDescription(): string;
  65627. /**
  65628. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65629. * @param scene defines the current scene where to apply this optimization
  65630. * @param optimizer defines the current optimizer
  65631. * @returns true if everything that can be done was applied
  65632. */
  65633. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65634. }
  65635. /**
  65636. * Defines an optimization used to turn post-processes off
  65637. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65638. */
  65639. export class PostProcessesOptimization extends SceneOptimization {
  65640. /**
  65641. * Gets a string describing the action executed by the current optimization
  65642. * @return description string
  65643. */
  65644. getDescription(): string;
  65645. /**
  65646. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65647. * @param scene defines the current scene where to apply this optimization
  65648. * @param optimizer defines the current optimizer
  65649. * @returns true if everything that can be done was applied
  65650. */
  65651. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65652. }
  65653. /**
  65654. * Defines an optimization used to turn lens flares off
  65655. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65656. */
  65657. export class LensFlaresOptimization extends SceneOptimization {
  65658. /**
  65659. * Gets a string describing the action executed by the current optimization
  65660. * @return description string
  65661. */
  65662. getDescription(): string;
  65663. /**
  65664. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65665. * @param scene defines the current scene where to apply this optimization
  65666. * @param optimizer defines the current optimizer
  65667. * @returns true if everything that can be done was applied
  65668. */
  65669. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65670. }
  65671. /**
  65672. * Defines an optimization based on user defined callback.
  65673. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65674. */
  65675. export class CustomOptimization extends SceneOptimization {
  65676. /**
  65677. * Callback called to apply the custom optimization.
  65678. */
  65679. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65680. /**
  65681. * Callback called to get custom description
  65682. */
  65683. onGetDescription: () => string;
  65684. /**
  65685. * Gets a string describing the action executed by the current optimization
  65686. * @returns description string
  65687. */
  65688. getDescription(): string;
  65689. /**
  65690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65691. * @param scene defines the current scene where to apply this optimization
  65692. * @param optimizer defines the current optimizer
  65693. * @returns true if everything that can be done was applied
  65694. */
  65695. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65696. }
  65697. /**
  65698. * Defines an optimization used to turn particles off
  65699. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65700. */
  65701. export class ParticlesOptimization extends SceneOptimization {
  65702. /**
  65703. * Gets a string describing the action executed by the current optimization
  65704. * @return description string
  65705. */
  65706. getDescription(): string;
  65707. /**
  65708. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65709. * @param scene defines the current scene where to apply this optimization
  65710. * @param optimizer defines the current optimizer
  65711. * @returns true if everything that can be done was applied
  65712. */
  65713. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65714. }
  65715. /**
  65716. * Defines an optimization used to turn render targets off
  65717. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65718. */
  65719. export class RenderTargetsOptimization extends SceneOptimization {
  65720. /**
  65721. * Gets a string describing the action executed by the current optimization
  65722. * @return description string
  65723. */
  65724. getDescription(): string;
  65725. /**
  65726. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65727. * @param scene defines the current scene where to apply this optimization
  65728. * @param optimizer defines the current optimizer
  65729. * @returns true if everything that can be done was applied
  65730. */
  65731. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65732. }
  65733. /**
  65734. * Defines an optimization used to merge meshes with compatible materials
  65735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65736. */
  65737. export class MergeMeshesOptimization extends SceneOptimization {
  65738. private static _UpdateSelectionTree;
  65739. /**
  65740. * Gets or sets a boolean which defines if optimization octree has to be updated
  65741. */
  65742. /**
  65743. * Gets or sets a boolean which defines if optimization octree has to be updated
  65744. */
  65745. static UpdateSelectionTree: boolean;
  65746. /**
  65747. * Gets a string describing the action executed by the current optimization
  65748. * @return description string
  65749. */
  65750. getDescription(): string;
  65751. private _canBeMerged;
  65752. /**
  65753. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65754. * @param scene defines the current scene where to apply this optimization
  65755. * @param optimizer defines the current optimizer
  65756. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65757. * @returns true if everything that can be done was applied
  65758. */
  65759. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65760. }
  65761. /**
  65762. * Defines a list of options used by SceneOptimizer
  65763. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65764. */
  65765. export class SceneOptimizerOptions {
  65766. /**
  65767. * Defines the target frame rate to reach (60 by default)
  65768. */
  65769. targetFrameRate: number;
  65770. /**
  65771. * Defines the interval between two checkes (2000ms by default)
  65772. */
  65773. trackerDuration: number;
  65774. /**
  65775. * Gets the list of optimizations to apply
  65776. */
  65777. optimizations: SceneOptimization[];
  65778. /**
  65779. * Creates a new list of options used by SceneOptimizer
  65780. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65781. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65782. */
  65783. constructor(
  65784. /**
  65785. * Defines the target frame rate to reach (60 by default)
  65786. */
  65787. targetFrameRate?: number,
  65788. /**
  65789. * Defines the interval between two checkes (2000ms by default)
  65790. */
  65791. trackerDuration?: number);
  65792. /**
  65793. * Add a new optimization
  65794. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65795. * @returns the current SceneOptimizerOptions
  65796. */
  65797. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65798. /**
  65799. * Add a new custom optimization
  65800. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65801. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65803. * @returns the current SceneOptimizerOptions
  65804. */
  65805. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65806. /**
  65807. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65808. * @param targetFrameRate defines the target frame rate (60 by default)
  65809. * @returns a SceneOptimizerOptions object
  65810. */
  65811. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65812. /**
  65813. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65814. * @param targetFrameRate defines the target frame rate (60 by default)
  65815. * @returns a SceneOptimizerOptions object
  65816. */
  65817. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65818. /**
  65819. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65820. * @param targetFrameRate defines the target frame rate (60 by default)
  65821. * @returns a SceneOptimizerOptions object
  65822. */
  65823. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65824. }
  65825. /**
  65826. * Class used to run optimizations in order to reach a target frame rate
  65827. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65828. */
  65829. export class SceneOptimizer implements IDisposable {
  65830. private _isRunning;
  65831. private _options;
  65832. private _scene;
  65833. private _currentPriorityLevel;
  65834. private _targetFrameRate;
  65835. private _trackerDuration;
  65836. private _currentFrameRate;
  65837. private _sceneDisposeObserver;
  65838. private _improvementMode;
  65839. /**
  65840. * Defines an observable called when the optimizer reaches the target frame rate
  65841. */
  65842. onSuccessObservable: Observable<SceneOptimizer>;
  65843. /**
  65844. * Defines an observable called when the optimizer enables an optimization
  65845. */
  65846. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65847. /**
  65848. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65849. */
  65850. onFailureObservable: Observable<SceneOptimizer>;
  65851. /**
  65852. * Gets a boolean indicating if the optimizer is in improvement mode
  65853. */
  65854. readonly isInImprovementMode: boolean;
  65855. /**
  65856. * Gets the current priority level (0 at start)
  65857. */
  65858. readonly currentPriorityLevel: number;
  65859. /**
  65860. * Gets the current frame rate checked by the SceneOptimizer
  65861. */
  65862. readonly currentFrameRate: number;
  65863. /**
  65864. * Gets or sets the current target frame rate (60 by default)
  65865. */
  65866. /**
  65867. * Gets or sets the current target frame rate (60 by default)
  65868. */
  65869. targetFrameRate: number;
  65870. /**
  65871. * Gets or sets the current interval between two checks (every 2000ms by default)
  65872. */
  65873. /**
  65874. * Gets or sets the current interval between two checks (every 2000ms by default)
  65875. */
  65876. trackerDuration: number;
  65877. /**
  65878. * Gets the list of active optimizations
  65879. */
  65880. readonly optimizations: SceneOptimization[];
  65881. /**
  65882. * Creates a new SceneOptimizer
  65883. * @param scene defines the scene to work on
  65884. * @param options defines the options to use with the SceneOptimizer
  65885. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65886. * @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)
  65887. */
  65888. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65889. /**
  65890. * Stops the current optimizer
  65891. */
  65892. stop(): void;
  65893. /**
  65894. * Reset the optimizer to initial step (current priority level = 0)
  65895. */
  65896. reset(): void;
  65897. /**
  65898. * Start the optimizer. By default it will try to reach a specific framerate
  65899. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65900. */
  65901. start(): void;
  65902. private _checkCurrentState;
  65903. /**
  65904. * Release all resources
  65905. */
  65906. dispose(): void;
  65907. /**
  65908. * Helper function to create a SceneOptimizer with one single line of code
  65909. * @param scene defines the scene to work on
  65910. * @param options defines the options to use with the SceneOptimizer
  65911. * @param onSuccess defines a callback to call on success
  65912. * @param onFailure defines a callback to call on failure
  65913. * @returns the new SceneOptimizer object
  65914. */
  65915. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65916. }
  65917. }
  65918. declare module BABYLON {
  65919. /**
  65920. * Class used to serialize a scene into a string
  65921. */
  65922. export class SceneSerializer {
  65923. /**
  65924. * Clear cache used by a previous serialization
  65925. */
  65926. static ClearCache(): void;
  65927. /**
  65928. * Serialize a scene into a JSON compatible object
  65929. * @param scene defines the scene to serialize
  65930. * @returns a JSON compatible object
  65931. */
  65932. static Serialize(scene: Scene): any;
  65933. /**
  65934. * Serialize a mesh into a JSON compatible object
  65935. * @param toSerialize defines the mesh to serialize
  65936. * @param withParents defines if parents must be serialized as well
  65937. * @param withChildren defines if children must be serialized as well
  65938. * @returns a JSON compatible object
  65939. */
  65940. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65941. }
  65942. }
  65943. declare module BABYLON {
  65944. /**
  65945. * Class used to host texture specific utilities
  65946. */
  65947. export class TextureTools {
  65948. /**
  65949. * Uses the GPU to create a copy texture rescaled at a given size
  65950. * @param texture Texture to copy from
  65951. * @param width defines the desired width
  65952. * @param height defines the desired height
  65953. * @param useBilinearMode defines if bilinear mode has to be used
  65954. * @return the generated texture
  65955. */
  65956. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65957. }
  65958. }
  65959. declare module BABYLON {
  65960. /**
  65961. * This represents the different options available for the video capture.
  65962. */
  65963. export interface VideoRecorderOptions {
  65964. /** Defines the mime type of the video. */
  65965. mimeType: string;
  65966. /** Defines the FPS the video should be recorded at. */
  65967. fps: number;
  65968. /** Defines the chunk size for the recording data. */
  65969. recordChunckSize: number;
  65970. /** The audio tracks to attach to the recording. */
  65971. audioTracks?: MediaStreamTrack[];
  65972. }
  65973. /**
  65974. * This can help with recording videos from BabylonJS.
  65975. * This is based on the available WebRTC functionalities of the browser.
  65976. *
  65977. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65978. */
  65979. export class VideoRecorder {
  65980. private static readonly _defaultOptions;
  65981. /**
  65982. * Returns whether or not the VideoRecorder is available in your browser.
  65983. * @param engine Defines the Babylon Engine.
  65984. * @returns true if supported otherwise false.
  65985. */
  65986. static IsSupported(engine: Engine): boolean;
  65987. private readonly _options;
  65988. private _canvas;
  65989. private _mediaRecorder;
  65990. private _recordedChunks;
  65991. private _fileName;
  65992. private _resolve;
  65993. private _reject;
  65994. /**
  65995. * True when a recording is already in progress.
  65996. */
  65997. readonly isRecording: boolean;
  65998. /**
  65999. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66000. * @param engine Defines the BabylonJS Engine you wish to record.
  66001. * @param options Defines options that can be used to customize the capture.
  66002. */
  66003. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66004. /**
  66005. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66006. */
  66007. stopRecording(): void;
  66008. /**
  66009. * Starts recording the canvas for a max duration specified in parameters.
  66010. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66011. * If null no automatic download will start and you can rely on the promise to get the data back.
  66012. * @param maxDuration Defines the maximum recording time in seconds.
  66013. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66014. * @return A promise callback at the end of the recording with the video data in Blob.
  66015. */
  66016. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66017. /**
  66018. * Releases internal resources used during the recording.
  66019. */
  66020. dispose(): void;
  66021. private _handleDataAvailable;
  66022. private _handleError;
  66023. private _handleStop;
  66024. }
  66025. }
  66026. declare module BABYLON {
  66027. /**
  66028. * Class containing a set of static utilities functions for screenshots
  66029. */
  66030. export class ScreenshotTools {
  66031. /**
  66032. * Captures a screenshot of the current rendering
  66033. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66034. * @param engine defines the rendering engine
  66035. * @param camera defines the source camera
  66036. * @param size This parameter can be set to a single number or to an object with the
  66037. * following (optional) properties: precision, width, height. If a single number is passed,
  66038. * it will be used for both width and height. If an object is passed, the screenshot size
  66039. * will be derived from the parameters. The precision property is a multiplier allowing
  66040. * rendering at a higher or lower resolution
  66041. * @param successCallback defines the callback receives a single parameter which contains the
  66042. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66043. * src parameter of an <img> to display it
  66044. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66045. * Check your browser for supported MIME types
  66046. */
  66047. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66048. /**
  66049. * Captures a screenshot of the current rendering
  66050. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66051. * @param engine defines the rendering engine
  66052. * @param camera defines the source camera
  66053. * @param size This parameter can be set to a single number or to an object with the
  66054. * following (optional) properties: precision, width, height. If a single number is passed,
  66055. * it will be used for both width and height. If an object is passed, the screenshot size
  66056. * will be derived from the parameters. The precision property is a multiplier allowing
  66057. * rendering at a higher or lower resolution
  66058. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66059. * Check your browser for supported MIME types
  66060. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66061. * to the src parameter of an <img> to display it
  66062. */
  66063. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66064. /**
  66065. * Generates an image screenshot from the specified camera.
  66066. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66067. * @param engine The engine to use for rendering
  66068. * @param camera The camera to use for rendering
  66069. * @param size This parameter can be set to a single number or to an object with the
  66070. * following (optional) properties: precision, width, height. If a single number is passed,
  66071. * it will be used for both width and height. If an object is passed, the screenshot size
  66072. * will be derived from the parameters. The precision property is a multiplier allowing
  66073. * rendering at a higher or lower resolution
  66074. * @param successCallback The callback receives a single parameter which contains the
  66075. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66076. * src parameter of an <img> to display it
  66077. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66078. * Check your browser for supported MIME types
  66079. * @param samples Texture samples (default: 1)
  66080. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66081. * @param fileName A name for for the downloaded file.
  66082. */
  66083. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66084. /**
  66085. * Generates an image screenshot from the specified camera.
  66086. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66087. * @param engine The engine to use for rendering
  66088. * @param camera The camera to use for rendering
  66089. * @param size This parameter can be set to a single number or to an object with the
  66090. * following (optional) properties: precision, width, height. If a single number is passed,
  66091. * it will be used for both width and height. If an object is passed, the screenshot size
  66092. * will be derived from the parameters. The precision property is a multiplier allowing
  66093. * rendering at a higher or lower resolution
  66094. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66095. * Check your browser for supported MIME types
  66096. * @param samples Texture samples (default: 1)
  66097. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66098. * @param fileName A name for for the downloaded file.
  66099. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66100. * to the src parameter of an <img> to display it
  66101. */
  66102. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66103. /**
  66104. * Gets height and width for screenshot size
  66105. * @private
  66106. */
  66107. private static _getScreenshotSize;
  66108. }
  66109. }
  66110. declare module BABYLON {
  66111. /**
  66112. * Interface for a data buffer
  66113. */
  66114. export interface IDataBuffer {
  66115. /**
  66116. * Reads bytes from the data buffer.
  66117. * @param byteOffset The byte offset to read
  66118. * @param byteLength The byte length to read
  66119. * @returns A promise that resolves when the bytes are read
  66120. */
  66121. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  66122. /**
  66123. * The byte length of the buffer.
  66124. */
  66125. readonly byteLength: number;
  66126. }
  66127. /**
  66128. * Utility class for reading from a data buffer
  66129. */
  66130. export class DataReader {
  66131. /**
  66132. * The data buffer associated with this data reader.
  66133. */
  66134. readonly buffer: IDataBuffer;
  66135. /**
  66136. * The current byte offset from the beginning of the data buffer.
  66137. */
  66138. byteOffset: number;
  66139. private _dataView;
  66140. private _dataByteOffset;
  66141. /**
  66142. * Constructor
  66143. * @param buffer The buffer to read
  66144. */
  66145. constructor(buffer: IDataBuffer);
  66146. /**
  66147. * Loads the given byte length.
  66148. * @param byteLength The byte length to load
  66149. * @returns A promise that resolves when the load is complete
  66150. */
  66151. loadAsync(byteLength: number): Promise<void>;
  66152. /**
  66153. * Read a unsigned 32-bit integer from the currently loaded data range.
  66154. * @returns The 32-bit integer read
  66155. */
  66156. readUint32(): number;
  66157. /**
  66158. * Read a byte array from the currently loaded data range.
  66159. * @param byteLength The byte length to read
  66160. * @returns The byte array read
  66161. */
  66162. readUint8Array(byteLength: number): Uint8Array;
  66163. /**
  66164. * Read a string from the currently loaded data range.
  66165. * @param byteLength The byte length to read
  66166. * @returns The string read
  66167. */
  66168. readString(byteLength: number): string;
  66169. /**
  66170. * Skips the given byte length the currently loaded data range.
  66171. * @param byteLength The byte length to skip
  66172. */
  66173. skipBytes(byteLength: number): void;
  66174. }
  66175. }
  66176. declare module BABYLON {
  66177. /**
  66178. * A cursor which tracks a point on a path
  66179. */
  66180. export class PathCursor {
  66181. private path;
  66182. /**
  66183. * Stores path cursor callbacks for when an onchange event is triggered
  66184. */
  66185. private _onchange;
  66186. /**
  66187. * The value of the path cursor
  66188. */
  66189. value: number;
  66190. /**
  66191. * The animation array of the path cursor
  66192. */
  66193. animations: Animation[];
  66194. /**
  66195. * Initializes the path cursor
  66196. * @param path The path to track
  66197. */
  66198. constructor(path: Path2);
  66199. /**
  66200. * Gets the cursor point on the path
  66201. * @returns A point on the path cursor at the cursor location
  66202. */
  66203. getPoint(): Vector3;
  66204. /**
  66205. * Moves the cursor ahead by the step amount
  66206. * @param step The amount to move the cursor forward
  66207. * @returns This path cursor
  66208. */
  66209. moveAhead(step?: number): PathCursor;
  66210. /**
  66211. * Moves the cursor behind by the step amount
  66212. * @param step The amount to move the cursor back
  66213. * @returns This path cursor
  66214. */
  66215. moveBack(step?: number): PathCursor;
  66216. /**
  66217. * Moves the cursor by the step amount
  66218. * If the step amount is greater than one, an exception is thrown
  66219. * @param step The amount to move the cursor
  66220. * @returns This path cursor
  66221. */
  66222. move(step: number): PathCursor;
  66223. /**
  66224. * Ensures that the value is limited between zero and one
  66225. * @returns This path cursor
  66226. */
  66227. private ensureLimits;
  66228. /**
  66229. * Runs onchange callbacks on change (used by the animation engine)
  66230. * @returns This path cursor
  66231. */
  66232. private raiseOnChange;
  66233. /**
  66234. * Executes a function on change
  66235. * @param f A path cursor onchange callback
  66236. * @returns This path cursor
  66237. */
  66238. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66239. }
  66240. }
  66241. declare module BABYLON {
  66242. /** @hidden */
  66243. export var blurPixelShader: {
  66244. name: string;
  66245. shader: string;
  66246. };
  66247. }
  66248. declare module BABYLON {
  66249. /** @hidden */
  66250. export var pointCloudVertexDeclaration: {
  66251. name: string;
  66252. shader: string;
  66253. };
  66254. }
  66255. // Mixins
  66256. interface Window {
  66257. mozIndexedDB: IDBFactory;
  66258. webkitIndexedDB: IDBFactory;
  66259. msIndexedDB: IDBFactory;
  66260. webkitURL: typeof URL;
  66261. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  66262. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  66263. WebGLRenderingContext: WebGLRenderingContext;
  66264. MSGesture: MSGesture;
  66265. CANNON: any;
  66266. AudioContext: AudioContext;
  66267. webkitAudioContext: AudioContext;
  66268. PointerEvent: any;
  66269. Math: Math;
  66270. Uint8Array: Uint8ArrayConstructor;
  66271. Float32Array: Float32ArrayConstructor;
  66272. mozURL: typeof URL;
  66273. msURL: typeof URL;
  66274. VRFrameData: any; // WebVR, from specs 1.1
  66275. DracoDecoderModule: any;
  66276. setImmediate(handler: (...args: any[]) => void): number;
  66277. }
  66278. interface HTMLCanvasElement {
  66279. requestPointerLock(): void;
  66280. msRequestPointerLock?(): void;
  66281. mozRequestPointerLock?(): void;
  66282. webkitRequestPointerLock?(): void;
  66283. /** Track wether a record is in progress */
  66284. isRecording: boolean;
  66285. /** Capture Stream method defined by some browsers */
  66286. captureStream(fps?: number): MediaStream;
  66287. }
  66288. interface CanvasRenderingContext2D {
  66289. msImageSmoothingEnabled: boolean;
  66290. }
  66291. interface MouseEvent {
  66292. mozMovementX: number;
  66293. mozMovementY: number;
  66294. webkitMovementX: number;
  66295. webkitMovementY: number;
  66296. msMovementX: number;
  66297. msMovementY: number;
  66298. }
  66299. interface Navigator {
  66300. mozGetVRDevices: (any: any) => any;
  66301. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66302. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66303. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  66304. webkitGetGamepads(): Gamepad[];
  66305. msGetGamepads(): Gamepad[];
  66306. webkitGamepads(): Gamepad[];
  66307. }
  66308. interface HTMLVideoElement {
  66309. mozSrcObject: any;
  66310. }
  66311. interface Math {
  66312. fround(x: number): number;
  66313. imul(a: number, b: number): number;
  66314. }
  66315. interface WebGLRenderingContext {
  66316. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  66317. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  66318. vertexAttribDivisor(index: number, divisor: number): void;
  66319. createVertexArray(): any;
  66320. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  66321. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  66322. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  66323. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  66324. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  66325. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  66326. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  66327. // Queries
  66328. createQuery(): WebGLQuery;
  66329. deleteQuery(query: WebGLQuery): void;
  66330. beginQuery(target: number, query: WebGLQuery): void;
  66331. endQuery(target: number): void;
  66332. getQueryParameter(query: WebGLQuery, pname: number): any;
  66333. getQuery(target: number, pname: number): any;
  66334. MAX_SAMPLES: number;
  66335. RGBA8: number;
  66336. READ_FRAMEBUFFER: number;
  66337. DRAW_FRAMEBUFFER: number;
  66338. UNIFORM_BUFFER: number;
  66339. HALF_FLOAT_OES: number;
  66340. RGBA16F: number;
  66341. RGBA32F: number;
  66342. R32F: number;
  66343. RG32F: number;
  66344. RGB32F: number;
  66345. R16F: number;
  66346. RG16F: number;
  66347. RGB16F: number;
  66348. RED: number;
  66349. RG: number;
  66350. R8: number;
  66351. RG8: number;
  66352. UNSIGNED_INT_24_8: number;
  66353. DEPTH24_STENCIL8: number;
  66354. MIN: number;
  66355. MAX: number;
  66356. /* Multiple Render Targets */
  66357. drawBuffers(buffers: number[]): void;
  66358. readBuffer(src: number): void;
  66359. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  66360. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  66361. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  66362. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  66363. // Occlusion Query
  66364. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  66365. ANY_SAMPLES_PASSED: number;
  66366. QUERY_RESULT_AVAILABLE: number;
  66367. QUERY_RESULT: number;
  66368. }
  66369. interface WebGLProgram {
  66370. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  66371. }
  66372. interface EXT_disjoint_timer_query {
  66373. QUERY_COUNTER_BITS_EXT: number;
  66374. TIME_ELAPSED_EXT: number;
  66375. TIMESTAMP_EXT: number;
  66376. GPU_DISJOINT_EXT: number;
  66377. QUERY_RESULT_EXT: number;
  66378. QUERY_RESULT_AVAILABLE_EXT: number;
  66379. queryCounterEXT(query: WebGLQuery, target: number): void;
  66380. createQueryEXT(): WebGLQuery;
  66381. beginQueryEXT(target: number, query: WebGLQuery): void;
  66382. endQueryEXT(target: number): void;
  66383. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  66384. deleteQueryEXT(query: WebGLQuery): void;
  66385. }
  66386. interface WebGLUniformLocation {
  66387. _currentState: any;
  66388. }
  66389. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  66390. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  66391. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  66392. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  66393. interface WebGLRenderingContext {
  66394. readonly RASTERIZER_DISCARD: number;
  66395. readonly DEPTH_COMPONENT24: number;
  66396. readonly TEXTURE_3D: number;
  66397. readonly TEXTURE_2D_ARRAY: number;
  66398. readonly TEXTURE_COMPARE_FUNC: number;
  66399. readonly TEXTURE_COMPARE_MODE: number;
  66400. readonly COMPARE_REF_TO_TEXTURE: number;
  66401. readonly TEXTURE_WRAP_R: number;
  66402. readonly HALF_FLOAT: number;
  66403. readonly RGB8: number;
  66404. readonly RED_INTEGER: number;
  66405. readonly RG_INTEGER: number;
  66406. readonly RGB_INTEGER: number;
  66407. readonly RGBA_INTEGER: number;
  66408. readonly R8_SNORM: number;
  66409. readonly RG8_SNORM: number;
  66410. readonly RGB8_SNORM: number;
  66411. readonly RGBA8_SNORM: number;
  66412. readonly R8I: number;
  66413. readonly RG8I: number;
  66414. readonly RGB8I: number;
  66415. readonly RGBA8I: number;
  66416. readonly R8UI: number;
  66417. readonly RG8UI: number;
  66418. readonly RGB8UI: number;
  66419. readonly RGBA8UI: number;
  66420. readonly R16I: number;
  66421. readonly RG16I: number;
  66422. readonly RGB16I: number;
  66423. readonly RGBA16I: number;
  66424. readonly R16UI: number;
  66425. readonly RG16UI: number;
  66426. readonly RGB16UI: number;
  66427. readonly RGBA16UI: number;
  66428. readonly R32I: number;
  66429. readonly RG32I: number;
  66430. readonly RGB32I: number;
  66431. readonly RGBA32I: number;
  66432. readonly R32UI: number;
  66433. readonly RG32UI: number;
  66434. readonly RGB32UI: number;
  66435. readonly RGBA32UI: number;
  66436. readonly RGB10_A2UI: number;
  66437. readonly R11F_G11F_B10F: number;
  66438. readonly RGB9_E5: number;
  66439. readonly RGB10_A2: number;
  66440. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  66441. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  66442. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  66443. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  66444. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  66445. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  66446. 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;
  66447. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  66448. readonly TRANSFORM_FEEDBACK: number;
  66449. readonly INTERLEAVED_ATTRIBS: number;
  66450. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  66451. createTransformFeedback(): WebGLTransformFeedback;
  66452. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  66453. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  66454. beginTransformFeedback(primitiveMode: number): void;
  66455. endTransformFeedback(): void;
  66456. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  66457. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  66458. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  66459. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  66460. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  66461. }
  66462. interface ImageBitmap {
  66463. readonly width: number;
  66464. readonly height: number;
  66465. close(): void;
  66466. }
  66467. interface WebGLQuery extends WebGLObject {
  66468. }
  66469. declare var WebGLQuery: {
  66470. prototype: WebGLQuery;
  66471. new(): WebGLQuery;
  66472. };
  66473. interface WebGLSampler extends WebGLObject {
  66474. }
  66475. declare var WebGLSampler: {
  66476. prototype: WebGLSampler;
  66477. new(): WebGLSampler;
  66478. };
  66479. interface WebGLSync extends WebGLObject {
  66480. }
  66481. declare var WebGLSync: {
  66482. prototype: WebGLSync;
  66483. new(): WebGLSync;
  66484. };
  66485. interface WebGLTransformFeedback extends WebGLObject {
  66486. }
  66487. declare var WebGLTransformFeedback: {
  66488. prototype: WebGLTransformFeedback;
  66489. new(): WebGLTransformFeedback;
  66490. };
  66491. interface WebGLVertexArrayObject extends WebGLObject {
  66492. }
  66493. declare var WebGLVertexArrayObject: {
  66494. prototype: WebGLVertexArrayObject;
  66495. new(): WebGLVertexArrayObject;
  66496. };
  66497. // Type definitions for WebVR API
  66498. // Project: https://w3c.github.io/webvr/
  66499. // Definitions by: six a <https://github.com/lostfictions>
  66500. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  66501. interface VRDisplay extends EventTarget {
  66502. /**
  66503. * Dictionary of capabilities describing the VRDisplay.
  66504. */
  66505. readonly capabilities: VRDisplayCapabilities;
  66506. /**
  66507. * z-depth defining the far plane of the eye view frustum
  66508. * enables mapping of values in the render target depth
  66509. * attachment to scene coordinates. Initially set to 10000.0.
  66510. */
  66511. depthFar: number;
  66512. /**
  66513. * z-depth defining the near plane of the eye view frustum
  66514. * enables mapping of values in the render target depth
  66515. * attachment to scene coordinates. Initially set to 0.01.
  66516. */
  66517. depthNear: number;
  66518. /**
  66519. * An identifier for this distinct VRDisplay. Used as an
  66520. * association point in the Gamepad API.
  66521. */
  66522. readonly displayId: number;
  66523. /**
  66524. * A display name, a user-readable name identifying it.
  66525. */
  66526. readonly displayName: string;
  66527. readonly isConnected: boolean;
  66528. readonly isPresenting: boolean;
  66529. /**
  66530. * If this VRDisplay supports room-scale experiences, the optional
  66531. * stage attribute contains details on the room-scale parameters.
  66532. */
  66533. readonly stageParameters: VRStageParameters | null;
  66534. /**
  66535. * Passing the value returned by `requestAnimationFrame` to
  66536. * `cancelAnimationFrame` will unregister the callback.
  66537. * @param handle Define the hanle of the request to cancel
  66538. */
  66539. cancelAnimationFrame(handle: number): void;
  66540. /**
  66541. * Stops presenting to the VRDisplay.
  66542. * @returns a promise to know when it stopped
  66543. */
  66544. exitPresent(): Promise<void>;
  66545. /**
  66546. * Return the current VREyeParameters for the given eye.
  66547. * @param whichEye Define the eye we want the parameter for
  66548. * @returns the eye parameters
  66549. */
  66550. getEyeParameters(whichEye: string): VREyeParameters;
  66551. /**
  66552. * Populates the passed VRFrameData with the information required to render
  66553. * the current frame.
  66554. * @param frameData Define the data structure to populate
  66555. * @returns true if ok otherwise false
  66556. */
  66557. getFrameData(frameData: VRFrameData): boolean;
  66558. /**
  66559. * Get the layers currently being presented.
  66560. * @returns the list of VR layers
  66561. */
  66562. getLayers(): VRLayer[];
  66563. /**
  66564. * Return a VRPose containing the future predicted pose of the VRDisplay
  66565. * when the current frame will be presented. The value returned will not
  66566. * change until JavaScript has returned control to the browser.
  66567. *
  66568. * The VRPose will contain the position, orientation, velocity,
  66569. * and acceleration of each of these properties.
  66570. * @returns the pose object
  66571. */
  66572. getPose(): VRPose;
  66573. /**
  66574. * Return the current instantaneous pose of the VRDisplay, with no
  66575. * prediction applied.
  66576. * @returns the current instantaneous pose
  66577. */
  66578. getImmediatePose(): VRPose;
  66579. /**
  66580. * The callback passed to `requestAnimationFrame` will be called
  66581. * any time a new frame should be rendered. When the VRDisplay is
  66582. * presenting the callback will be called at the native refresh
  66583. * rate of the HMD. When not presenting this function acts
  66584. * identically to how window.requestAnimationFrame acts. Content should
  66585. * make no assumptions of frame rate or vsync behavior as the HMD runs
  66586. * asynchronously from other displays and at differing refresh rates.
  66587. * @param callback Define the eaction to run next frame
  66588. * @returns the request handle it
  66589. */
  66590. requestAnimationFrame(callback: FrameRequestCallback): number;
  66591. /**
  66592. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  66593. * Repeat calls while already presenting will update the VRLayers being displayed.
  66594. * @param layers Define the list of layer to present
  66595. * @returns a promise to know when the request has been fulfilled
  66596. */
  66597. requestPresent(layers: VRLayer[]): Promise<void>;
  66598. /**
  66599. * Reset the pose for this display, treating its current position and
  66600. * orientation as the "origin/zero" values. VRPose.position,
  66601. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  66602. * updated when calling resetPose(). This should be called in only
  66603. * sitting-space experiences.
  66604. */
  66605. resetPose(): void;
  66606. /**
  66607. * The VRLayer provided to the VRDisplay will be captured and presented
  66608. * in the HMD. Calling this function has the same effect on the source
  66609. * canvas as any other operation that uses its source image, and canvases
  66610. * created without preserveDrawingBuffer set to true will be cleared.
  66611. * @param pose Define the pose to submit
  66612. */
  66613. submitFrame(pose?: VRPose): void;
  66614. }
  66615. declare var VRDisplay: {
  66616. prototype: VRDisplay;
  66617. new(): VRDisplay;
  66618. };
  66619. interface VRLayer {
  66620. leftBounds?: number[] | Float32Array | null;
  66621. rightBounds?: number[] | Float32Array | null;
  66622. source?: HTMLCanvasElement | null;
  66623. }
  66624. interface VRDisplayCapabilities {
  66625. readonly canPresent: boolean;
  66626. readonly hasExternalDisplay: boolean;
  66627. readonly hasOrientation: boolean;
  66628. readonly hasPosition: boolean;
  66629. readonly maxLayers: number;
  66630. }
  66631. interface VREyeParameters {
  66632. /** @deprecated */
  66633. readonly fieldOfView: VRFieldOfView;
  66634. readonly offset: Float32Array;
  66635. readonly renderHeight: number;
  66636. readonly renderWidth: number;
  66637. }
  66638. interface VRFieldOfView {
  66639. readonly downDegrees: number;
  66640. readonly leftDegrees: number;
  66641. readonly rightDegrees: number;
  66642. readonly upDegrees: number;
  66643. }
  66644. interface VRFrameData {
  66645. readonly leftProjectionMatrix: Float32Array;
  66646. readonly leftViewMatrix: Float32Array;
  66647. readonly pose: VRPose;
  66648. readonly rightProjectionMatrix: Float32Array;
  66649. readonly rightViewMatrix: Float32Array;
  66650. readonly timestamp: number;
  66651. }
  66652. interface VRPose {
  66653. readonly angularAcceleration: Float32Array | null;
  66654. readonly angularVelocity: Float32Array | null;
  66655. readonly linearAcceleration: Float32Array | null;
  66656. readonly linearVelocity: Float32Array | null;
  66657. readonly orientation: Float32Array | null;
  66658. readonly position: Float32Array | null;
  66659. readonly timestamp: number;
  66660. }
  66661. interface VRStageParameters {
  66662. sittingToStandingTransform?: Float32Array;
  66663. sizeX?: number;
  66664. sizeY?: number;
  66665. }
  66666. interface Navigator {
  66667. getVRDisplays(): Promise<VRDisplay[]>;
  66668. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  66669. }
  66670. interface Window {
  66671. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  66672. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  66673. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  66674. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  66675. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  66676. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  66677. }
  66678. interface Gamepad {
  66679. readonly displayId: number;
  66680. }
  66681. type XRSessionMode =
  66682. | "inline"
  66683. | "immersive-vr"
  66684. | "immersive-ar";
  66685. type XRReferenceSpaceType =
  66686. | "viewer"
  66687. | "local"
  66688. | "local-floor"
  66689. | "bounded-floor"
  66690. | "unbounded";
  66691. type XREnvironmentBlendMode =
  66692. | "opaque"
  66693. | "additive"
  66694. | "alpha-blend";
  66695. type XRVisibilityState =
  66696. | "visible"
  66697. | "visible-blurred"
  66698. | "hidden";
  66699. type XRHandedness =
  66700. | "none"
  66701. | "left"
  66702. | "right";
  66703. type XRTargetRayMode =
  66704. | "gaze"
  66705. | "tracked-pointer"
  66706. | "screen";
  66707. type XREye =
  66708. | "none"
  66709. | "left"
  66710. | "right";
  66711. interface XRSpace extends EventTarget {
  66712. }
  66713. interface XRRenderState {
  66714. depthNear?: number;
  66715. depthFar?: number;
  66716. inlineVerticalFieldOfView?: number;
  66717. baseLayer?: XRWebGLLayer;
  66718. }
  66719. interface XRInputSource {
  66720. handedness: XRHandedness;
  66721. targetRayMode: XRTargetRayMode;
  66722. targetRaySpace: XRSpace;
  66723. gripSpace: XRSpace | undefined;
  66724. gamepad: Gamepad | undefined;
  66725. profiles: Array<string>;
  66726. }
  66727. interface XRSession extends XRAnchorCreator {
  66728. addEventListener: Function;
  66729. removeEventListener: Function;
  66730. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  66731. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  66732. requestAnimationFrame: Function;
  66733. end(): Promise<void>;
  66734. renderState: XRRenderState;
  66735. inputSources: Array<XRInputSource>;
  66736. // AR hit test
  66737. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  66738. updateWorldTrackingState(options: {
  66739. planeDetectionState?: { enabled: boolean; }
  66740. }): void;
  66741. }
  66742. interface XRReferenceSpace extends XRSpace {
  66743. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  66744. onreset: any;
  66745. }
  66746. type XRPlaneSet = Set<XRPlane>;
  66747. type XRAnchorSet = Set<XRAnchor>;
  66748. interface XRFrame {
  66749. session: XRSession;
  66750. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  66751. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  66752. // Anchors
  66753. trackedAnchors?: XRAnchorSet;
  66754. // Planes
  66755. worldInformation: {
  66756. detectedPlanes?: XRPlaneSet;
  66757. };
  66758. }
  66759. interface XRViewerPose extends XRPose {
  66760. views: Array<XRView>;
  66761. }
  66762. interface XRPose {
  66763. transform: XRRigidTransform;
  66764. emulatedPosition: boolean;
  66765. }
  66766. interface XRWebGLLayerOptions {
  66767. antialias?: boolean;
  66768. depth?: boolean;
  66769. stencil?: boolean;
  66770. alpha?: boolean;
  66771. multiview?: boolean;
  66772. framebufferScaleFactor?: number;
  66773. }
  66774. declare var XRWebGLLayer: {
  66775. prototype: XRWebGLLayer;
  66776. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  66777. };
  66778. interface XRWebGLLayer {
  66779. framebuffer: WebGLFramebuffer;
  66780. framebufferWidth: number;
  66781. framebufferHeight: number;
  66782. getViewport: Function;
  66783. }
  66784. declare class XRRigidTransform {
  66785. constructor(matrix: Float32Array);
  66786. position: DOMPointReadOnly;
  66787. orientation: DOMPointReadOnly;
  66788. matrix: Float32Array;
  66789. inverse: XRRigidTransform;
  66790. }
  66791. interface XRView {
  66792. eye: XREye;
  66793. projectionMatrix: Float32Array;
  66794. transform: XRRigidTransform;
  66795. }
  66796. interface XRInputSourceChangeEvent {
  66797. session: XRSession;
  66798. removed: Array<XRInputSource>;
  66799. added: Array<XRInputSource>;
  66800. }
  66801. interface XRInputSourceEvent extends Event {
  66802. readonly frame: XRFrame;
  66803. readonly inputSource: XRInputSource;
  66804. }
  66805. // Experimental(er) features
  66806. declare class XRRay {
  66807. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  66808. origin: DOMPointReadOnly;
  66809. direction: DOMPointReadOnly;
  66810. matrix: Float32Array;
  66811. }
  66812. interface XRHitResult {
  66813. hitMatrix: Float32Array;
  66814. }
  66815. interface XRAnchor {
  66816. // remove?
  66817. id?: string;
  66818. anchorSpace: XRSpace;
  66819. lastChangedTime: number;
  66820. detach(): void;
  66821. }
  66822. interface XRPlane extends XRAnchorCreator {
  66823. orientation: "Horizontal" | "Vertical";
  66824. planeSpace: XRSpace;
  66825. polygon: Array<DOMPointReadOnly>;
  66826. lastChangedTime: number;
  66827. }
  66828. interface XRAnchorCreator {
  66829. // AR Anchors
  66830. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  66831. }
  66832. /**
  66833. * @ignore
  66834. */
  66835. declare module BABYLON.GLTF2.Exporter {
  66836. }
  66837. /**
  66838. * @ignore
  66839. */
  66840. declare module BABYLON.GLTF1 {
  66841. }
  66842. declare module BABYLON.GUI {
  66843. /**
  66844. * Class used to specific a value and its associated unit
  66845. */
  66846. export class ValueAndUnit {
  66847. /** defines the unit to store */
  66848. unit: number;
  66849. /** defines a boolean indicating if the value can be negative */
  66850. negativeValueAllowed: boolean;
  66851. private _value;
  66852. private _originalUnit;
  66853. /**
  66854. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  66855. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  66856. */
  66857. ignoreAdaptiveScaling: boolean;
  66858. /**
  66859. * Creates a new ValueAndUnit
  66860. * @param value defines the value to store
  66861. * @param unit defines the unit to store
  66862. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  66863. */
  66864. constructor(value: number,
  66865. /** defines the unit to store */
  66866. unit?: number,
  66867. /** defines a boolean indicating if the value can be negative */
  66868. negativeValueAllowed?: boolean);
  66869. /** Gets a boolean indicating if the value is a percentage */
  66870. readonly isPercentage: boolean;
  66871. /** Gets a boolean indicating if the value is store as pixel */
  66872. readonly isPixel: boolean;
  66873. /** Gets direct internal value */
  66874. readonly internalValue: number;
  66875. /**
  66876. * Gets value as pixel
  66877. * @param host defines the root host
  66878. * @param refValue defines the reference value for percentages
  66879. * @returns the value as pixel
  66880. */
  66881. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  66882. /**
  66883. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  66884. * @param value defines the value to store
  66885. * @param unit defines the unit to store
  66886. * @returns the current ValueAndUnit
  66887. */
  66888. updateInPlace(value: number, unit?: number): ValueAndUnit;
  66889. /**
  66890. * Gets the value accordingly to its unit
  66891. * @param host defines the root host
  66892. * @returns the value
  66893. */
  66894. getValue(host: AdvancedDynamicTexture): number;
  66895. /**
  66896. * Gets a string representation of the value
  66897. * @param host defines the root host
  66898. * @param decimals defines an optional number of decimals to display
  66899. * @returns a string
  66900. */
  66901. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  66902. /**
  66903. * Store a value parsed from a string
  66904. * @param source defines the source string
  66905. * @returns true if the value was successfully parsed
  66906. */
  66907. fromString(source: string | number): boolean;
  66908. private static _Regex;
  66909. private static _UNITMODE_PERCENTAGE;
  66910. private static _UNITMODE_PIXEL;
  66911. /** UNITMODE_PERCENTAGE */
  66912. static readonly UNITMODE_PERCENTAGE: number;
  66913. /** UNITMODE_PIXEL */
  66914. static readonly UNITMODE_PIXEL: number;
  66915. }
  66916. }
  66917. declare module BABYLON.GUI {
  66918. /**
  66919. * Define a style used by control to automatically setup properties based on a template.
  66920. * Only support font related properties so far
  66921. */
  66922. export class Style implements BABYLON.IDisposable {
  66923. private _fontFamily;
  66924. private _fontStyle;
  66925. private _fontWeight;
  66926. /** @hidden */
  66927. _host: AdvancedDynamicTexture;
  66928. /** @hidden */
  66929. _fontSize: ValueAndUnit;
  66930. /**
  66931. * BABYLON.Observable raised when the style values are changed
  66932. */
  66933. onChangedObservable: BABYLON.Observable<Style>;
  66934. /**
  66935. * Creates a new style object
  66936. * @param host defines the AdvancedDynamicTexture which hosts this style
  66937. */
  66938. constructor(host: AdvancedDynamicTexture);
  66939. /**
  66940. * Gets or sets the font size
  66941. */
  66942. fontSize: string | number;
  66943. /**
  66944. * Gets or sets the font family
  66945. */
  66946. fontFamily: string;
  66947. /**
  66948. * Gets or sets the font style
  66949. */
  66950. fontStyle: string;
  66951. /** Gets or sets font weight */
  66952. fontWeight: string;
  66953. /** Dispose all associated resources */
  66954. dispose(): void;
  66955. }
  66956. }
  66957. declare module BABYLON.GUI {
  66958. /**
  66959. * Class used to transport BABYLON.Vector2 information for pointer events
  66960. */
  66961. export class Vector2WithInfo extends BABYLON.Vector2 {
  66962. /** defines the current mouse button index */
  66963. buttonIndex: number;
  66964. /**
  66965. * Creates a new Vector2WithInfo
  66966. * @param source defines the vector2 data to transport
  66967. * @param buttonIndex defines the current mouse button index
  66968. */
  66969. constructor(source: BABYLON.Vector2,
  66970. /** defines the current mouse button index */
  66971. buttonIndex?: number);
  66972. }
  66973. /** Class used to provide 2D matrix features */
  66974. export class Matrix2D {
  66975. /** Gets the internal array of 6 floats used to store matrix data */
  66976. m: Float32Array;
  66977. /**
  66978. * Creates a new matrix
  66979. * @param m00 defines value for (0, 0)
  66980. * @param m01 defines value for (0, 1)
  66981. * @param m10 defines value for (1, 0)
  66982. * @param m11 defines value for (1, 1)
  66983. * @param m20 defines value for (2, 0)
  66984. * @param m21 defines value for (2, 1)
  66985. */
  66986. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  66987. /**
  66988. * Fills the matrix from direct values
  66989. * @param m00 defines value for (0, 0)
  66990. * @param m01 defines value for (0, 1)
  66991. * @param m10 defines value for (1, 0)
  66992. * @param m11 defines value for (1, 1)
  66993. * @param m20 defines value for (2, 0)
  66994. * @param m21 defines value for (2, 1)
  66995. * @returns the current modified matrix
  66996. */
  66997. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  66998. /**
  66999. * Gets matrix determinant
  67000. * @returns the determinant
  67001. */
  67002. determinant(): number;
  67003. /**
  67004. * Inverses the matrix and stores it in a target matrix
  67005. * @param result defines the target matrix
  67006. * @returns the current matrix
  67007. */
  67008. invertToRef(result: Matrix2D): Matrix2D;
  67009. /**
  67010. * Multiplies the current matrix with another one
  67011. * @param other defines the second operand
  67012. * @param result defines the target matrix
  67013. * @returns the current matrix
  67014. */
  67015. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  67016. /**
  67017. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  67018. * @param x defines the x coordinate to transform
  67019. * @param y defines the x coordinate to transform
  67020. * @param result defines the target vector2
  67021. * @returns the current matrix
  67022. */
  67023. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  67024. /**
  67025. * Creates an identity matrix
  67026. * @returns a new matrix
  67027. */
  67028. static Identity(): Matrix2D;
  67029. /**
  67030. * Creates a translation matrix and stores it in a target matrix
  67031. * @param x defines the x coordinate of the translation
  67032. * @param y defines the y coordinate of the translation
  67033. * @param result defines the target matrix
  67034. */
  67035. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  67036. /**
  67037. * Creates a scaling matrix and stores it in a target matrix
  67038. * @param x defines the x coordinate of the scaling
  67039. * @param y defines the y coordinate of the scaling
  67040. * @param result defines the target matrix
  67041. */
  67042. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  67043. /**
  67044. * Creates a rotation matrix and stores it in a target matrix
  67045. * @param angle defines the rotation angle
  67046. * @param result defines the target matrix
  67047. */
  67048. static RotationToRef(angle: number, result: Matrix2D): void;
  67049. private static _TempPreTranslationMatrix;
  67050. private static _TempPostTranslationMatrix;
  67051. private static _TempRotationMatrix;
  67052. private static _TempScalingMatrix;
  67053. private static _TempCompose0;
  67054. private static _TempCompose1;
  67055. private static _TempCompose2;
  67056. /**
  67057. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  67058. * @param tx defines the x coordinate of the translation
  67059. * @param ty defines the y coordinate of the translation
  67060. * @param angle defines the rotation angle
  67061. * @param scaleX defines the x coordinate of the scaling
  67062. * @param scaleY defines the y coordinate of the scaling
  67063. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  67064. * @param result defines the target matrix
  67065. */
  67066. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  67067. }
  67068. }
  67069. declare module BABYLON.GUI {
  67070. /**
  67071. * Class used to store 2D control sizes
  67072. */
  67073. export class Measure {
  67074. /** defines left coordinate */
  67075. left: number;
  67076. /** defines top coordinate */
  67077. top: number;
  67078. /** defines width dimension */
  67079. width: number;
  67080. /** defines height dimension */
  67081. height: number;
  67082. /**
  67083. * Creates a new measure
  67084. * @param left defines left coordinate
  67085. * @param top defines top coordinate
  67086. * @param width defines width dimension
  67087. * @param height defines height dimension
  67088. */
  67089. constructor(
  67090. /** defines left coordinate */
  67091. left: number,
  67092. /** defines top coordinate */
  67093. top: number,
  67094. /** defines width dimension */
  67095. width: number,
  67096. /** defines height dimension */
  67097. height: number);
  67098. /**
  67099. * Copy from another measure
  67100. * @param other defines the other measure to copy from
  67101. */
  67102. copyFrom(other: Measure): void;
  67103. /**
  67104. * Copy from a group of 4 floats
  67105. * @param left defines left coordinate
  67106. * @param top defines top coordinate
  67107. * @param width defines width dimension
  67108. * @param height defines height dimension
  67109. */
  67110. copyFromFloats(left: number, top: number, width: number, height: number): void;
  67111. /**
  67112. * Computes the axis aligned bounding box measure for two given measures
  67113. * @param a Input measure
  67114. * @param b Input measure
  67115. * @param result the resulting bounding measure
  67116. */
  67117. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  67118. /**
  67119. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  67120. * @param transform the matrix to transform the measure before computing the AABB
  67121. * @param result the resulting AABB
  67122. */
  67123. transformToRef(transform: Matrix2D, result: Measure): void;
  67124. /**
  67125. * Check equality between this measure and another one
  67126. * @param other defines the other measures
  67127. * @returns true if both measures are equals
  67128. */
  67129. isEqualsTo(other: Measure): boolean;
  67130. /**
  67131. * Creates an empty measure
  67132. * @returns a new measure
  67133. */
  67134. static Empty(): Measure;
  67135. }
  67136. }
  67137. declare module BABYLON.GUI {
  67138. /**
  67139. * Interface used to define a control that can receive focus
  67140. */
  67141. export interface IFocusableControl {
  67142. /**
  67143. * Function called when the control receives the focus
  67144. */
  67145. onFocus(): void;
  67146. /**
  67147. * Function called when the control loses the focus
  67148. */
  67149. onBlur(): void;
  67150. /**
  67151. * Function called to let the control handle keyboard events
  67152. * @param evt defines the current keyboard event
  67153. */
  67154. processKeyboard(evt: KeyboardEvent): void;
  67155. /**
  67156. * Function called to get the list of controls that should not steal the focus from this control
  67157. * @returns an array of controls
  67158. */
  67159. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  67160. }
  67161. /**
  67162. * Class used to create texture to support 2D GUI elements
  67163. * @see http://doc.babylonjs.com/how_to/gui
  67164. */
  67165. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  67166. private _isDirty;
  67167. private _renderObserver;
  67168. private _resizeObserver;
  67169. private _preKeyboardObserver;
  67170. private _pointerMoveObserver;
  67171. private _pointerObserver;
  67172. private _canvasPointerOutObserver;
  67173. private _background;
  67174. /** @hidden */
  67175. _rootContainer: Container;
  67176. /** @hidden */
  67177. _lastPickedControl: Control;
  67178. /** @hidden */
  67179. _lastControlOver: {
  67180. [pointerId: number]: Control;
  67181. };
  67182. /** @hidden */
  67183. _lastControlDown: {
  67184. [pointerId: number]: Control;
  67185. };
  67186. /** @hidden */
  67187. _capturingControl: {
  67188. [pointerId: number]: Control;
  67189. };
  67190. /** @hidden */
  67191. _shouldBlockPointer: boolean;
  67192. /** @hidden */
  67193. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  67194. /** @hidden */
  67195. _linkedControls: Control[];
  67196. private _isFullscreen;
  67197. private _fullscreenViewport;
  67198. private _idealWidth;
  67199. private _idealHeight;
  67200. private _useSmallestIdeal;
  67201. private _renderAtIdealSize;
  67202. private _focusedControl;
  67203. private _blockNextFocusCheck;
  67204. private _renderScale;
  67205. private _rootElement;
  67206. private _cursorChanged;
  67207. /**
  67208. * Define type to string to ensure compatibility across browsers
  67209. * Safari doesn't support DataTransfer constructor
  67210. */
  67211. private _clipboardData;
  67212. /**
  67213. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  67214. */
  67215. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  67216. /**
  67217. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  67218. */
  67219. onControlPickedObservable: BABYLON.Observable<Control>;
  67220. /**
  67221. * BABYLON.Observable event triggered before layout is evaluated
  67222. */
  67223. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67224. /**
  67225. * BABYLON.Observable event triggered after the layout was evaluated
  67226. */
  67227. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67228. /**
  67229. * BABYLON.Observable event triggered before the texture is rendered
  67230. */
  67231. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67232. /**
  67233. * BABYLON.Observable event triggered after the texture was rendered
  67234. */
  67235. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  67236. /**
  67237. * Gets or sets a boolean defining if alpha is stored as premultiplied
  67238. */
  67239. premulAlpha: boolean;
  67240. /**
  67241. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  67242. * Useful when you want more antialiasing
  67243. */
  67244. renderScale: number;
  67245. /** Gets or sets the background color */
  67246. background: string;
  67247. /**
  67248. * Gets or sets the ideal width used to design controls.
  67249. * The GUI will then rescale everything accordingly
  67250. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67251. */
  67252. idealWidth: number;
  67253. /**
  67254. * Gets or sets the ideal height used to design controls.
  67255. * The GUI will then rescale everything accordingly
  67256. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67257. */
  67258. idealHeight: number;
  67259. /**
  67260. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  67261. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67262. */
  67263. useSmallestIdeal: boolean;
  67264. /**
  67265. * Gets or sets a boolean indicating if adaptive scaling must be used
  67266. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  67267. */
  67268. renderAtIdealSize: boolean;
  67269. /**
  67270. * Gets the underlying layer used to render the texture when in fullscreen mode
  67271. */
  67272. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  67273. /**
  67274. * Gets the root container control
  67275. */
  67276. readonly rootContainer: Container;
  67277. /**
  67278. * Returns an array containing the root container.
  67279. * This is mostly used to let the Inspector introspects the ADT
  67280. * @returns an array containing the rootContainer
  67281. */
  67282. getChildren(): Array<Container>;
  67283. /**
  67284. * Will return all controls that are inside this texture
  67285. * @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
  67286. * @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
  67287. * @return all child controls
  67288. */
  67289. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67290. /**
  67291. * Gets or sets the current focused control
  67292. */
  67293. focusedControl: BABYLON.Nullable<IFocusableControl>;
  67294. /**
  67295. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  67296. */
  67297. isForeground: boolean;
  67298. /**
  67299. * Gets or set information about clipboardData
  67300. */
  67301. clipboardData: string;
  67302. /**
  67303. * Creates a new AdvancedDynamicTexture
  67304. * @param name defines the name of the texture
  67305. * @param width defines the width of the texture
  67306. * @param height defines the height of the texture
  67307. * @param scene defines the hosting scene
  67308. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  67309. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  67310. */
  67311. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  67312. /**
  67313. * Get the current class name of the texture useful for serialization or dynamic coding.
  67314. * @returns "AdvancedDynamicTexture"
  67315. */
  67316. getClassName(): string;
  67317. /**
  67318. * Function used to execute a function on all controls
  67319. * @param func defines the function to execute
  67320. * @param container defines the container where controls belong. If null the root container will be used
  67321. */
  67322. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  67323. private _useInvalidateRectOptimization;
  67324. /**
  67325. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  67326. */
  67327. useInvalidateRectOptimization: boolean;
  67328. private _invalidatedRectangle;
  67329. /**
  67330. * Invalidates a rectangle area on the gui texture
  67331. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  67332. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  67333. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  67334. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  67335. */
  67336. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  67337. /**
  67338. * Marks the texture as dirty forcing a complete update
  67339. */
  67340. markAsDirty(): void;
  67341. /**
  67342. * Helper function used to create a new style
  67343. * @returns a new style
  67344. * @see http://doc.babylonjs.com/how_to/gui#styles
  67345. */
  67346. createStyle(): Style;
  67347. /**
  67348. * Adds a new control to the root container
  67349. * @param control defines the control to add
  67350. * @returns the current texture
  67351. */
  67352. addControl(control: Control): AdvancedDynamicTexture;
  67353. /**
  67354. * Removes a control from the root container
  67355. * @param control defines the control to remove
  67356. * @returns the current texture
  67357. */
  67358. removeControl(control: Control): AdvancedDynamicTexture;
  67359. /**
  67360. * Release all resources
  67361. */
  67362. dispose(): void;
  67363. private _onResize;
  67364. /** @hidden */
  67365. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  67366. /**
  67367. * Get screen coordinates for a vector3
  67368. * @param position defines the position to project
  67369. * @param worldMatrix defines the world matrix to use
  67370. * @returns the projected position
  67371. */
  67372. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  67373. private _checkUpdate;
  67374. private _clearMeasure;
  67375. private _render;
  67376. /** @hidden */
  67377. _changeCursor(cursor: string): void;
  67378. /** @hidden */
  67379. _registerLastControlDown(control: Control, pointerId: number): void;
  67380. private _doPicking;
  67381. /** @hidden */
  67382. _cleanControlAfterRemovalFromList(list: {
  67383. [pointerId: number]: Control;
  67384. }, control: Control): void;
  67385. /** @hidden */
  67386. _cleanControlAfterRemoval(control: Control): void;
  67387. /** Attach to all scene events required to support pointer events */
  67388. attach(): void;
  67389. /** @hidden */
  67390. private onClipboardCopy;
  67391. /** @hidden */
  67392. private onClipboardCut;
  67393. /** @hidden */
  67394. private onClipboardPaste;
  67395. /**
  67396. * Register the clipboard Events onto the canvas
  67397. */
  67398. registerClipboardEvents(): void;
  67399. /**
  67400. * Unregister the clipboard Events from the canvas
  67401. */
  67402. unRegisterClipboardEvents(): void;
  67403. /**
  67404. * Connect the texture to a hosting mesh to enable interactions
  67405. * @param mesh defines the mesh to attach to
  67406. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  67407. */
  67408. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  67409. /**
  67410. * Move the focus to a specific control
  67411. * @param control defines the control which will receive the focus
  67412. */
  67413. moveFocusToControl(control: IFocusableControl): void;
  67414. private _manageFocus;
  67415. private _attachToOnPointerOut;
  67416. /**
  67417. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  67418. * @param mesh defines the mesh which will receive the texture
  67419. * @param width defines the texture width (1024 by default)
  67420. * @param height defines the texture height (1024 by default)
  67421. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  67422. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  67423. * @returns a new AdvancedDynamicTexture
  67424. */
  67425. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  67426. /**
  67427. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  67428. * In this mode the texture will rely on a layer for its rendering.
  67429. * This allows it to be treated like any other layer.
  67430. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  67431. * LayerMask is set through advancedTexture.layer.layerMask
  67432. * @param name defines name for the texture
  67433. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  67434. * @param scene defines the hsoting scene
  67435. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  67436. * @returns a new AdvancedDynamicTexture
  67437. */
  67438. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  67439. }
  67440. }
  67441. declare module BABYLON.GUI {
  67442. /**
  67443. * Root class used for all 2D controls
  67444. * @see http://doc.babylonjs.com/how_to/gui#controls
  67445. */
  67446. export class Control {
  67447. /** defines the name of the control */
  67448. name?: string | undefined;
  67449. /**
  67450. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  67451. */
  67452. static AllowAlphaInheritance: boolean;
  67453. private _alpha;
  67454. private _alphaSet;
  67455. private _zIndex;
  67456. /** @hidden */
  67457. _host: AdvancedDynamicTexture;
  67458. /** Gets or sets the control parent */
  67459. parent: BABYLON.Nullable<Container>;
  67460. /** @hidden */
  67461. _currentMeasure: Measure;
  67462. private _fontFamily;
  67463. private _fontStyle;
  67464. private _fontWeight;
  67465. private _fontSize;
  67466. private _font;
  67467. /** @hidden */
  67468. _width: ValueAndUnit;
  67469. /** @hidden */
  67470. _height: ValueAndUnit;
  67471. /** @hidden */
  67472. protected _fontOffset: {
  67473. ascent: number;
  67474. height: number;
  67475. descent: number;
  67476. };
  67477. private _color;
  67478. private _style;
  67479. private _styleObserver;
  67480. /** @hidden */
  67481. protected _horizontalAlignment: number;
  67482. /** @hidden */
  67483. protected _verticalAlignment: number;
  67484. /** @hidden */
  67485. protected _isDirty: boolean;
  67486. /** @hidden */
  67487. protected _wasDirty: boolean;
  67488. /** @hidden */
  67489. _tempParentMeasure: Measure;
  67490. /** @hidden */
  67491. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  67492. /** @hidden */
  67493. protected _cachedParentMeasure: Measure;
  67494. private _paddingLeft;
  67495. private _paddingRight;
  67496. private _paddingTop;
  67497. private _paddingBottom;
  67498. /** @hidden */
  67499. _left: ValueAndUnit;
  67500. /** @hidden */
  67501. _top: ValueAndUnit;
  67502. private _scaleX;
  67503. private _scaleY;
  67504. private _rotation;
  67505. private _transformCenterX;
  67506. private _transformCenterY;
  67507. /** @hidden */
  67508. _transformMatrix: Matrix2D;
  67509. /** @hidden */
  67510. protected _invertTransformMatrix: Matrix2D;
  67511. /** @hidden */
  67512. protected _transformedPosition: BABYLON.Vector2;
  67513. private _isMatrixDirty;
  67514. private _cachedOffsetX;
  67515. private _cachedOffsetY;
  67516. private _isVisible;
  67517. private _isHighlighted;
  67518. /** @hidden */
  67519. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67520. private _fontSet;
  67521. private _dummyVector2;
  67522. private _downCount;
  67523. private _enterCount;
  67524. private _doNotRender;
  67525. private _downPointerIds;
  67526. protected _isEnabled: boolean;
  67527. protected _disabledColor: string;
  67528. /** @hidden */
  67529. protected _rebuildLayout: boolean;
  67530. /** @hidden */
  67531. _isClipped: boolean;
  67532. /** @hidden */
  67533. _automaticSize: boolean;
  67534. /** @hidden */
  67535. _tag: any;
  67536. /**
  67537. * 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
  67538. */
  67539. uniqueId: number;
  67540. /**
  67541. * Gets or sets an object used to store user defined information for the node
  67542. */
  67543. metadata: any;
  67544. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  67545. isHitTestVisible: boolean;
  67546. /** Gets or sets a boolean indicating if the control can block pointer events */
  67547. isPointerBlocker: boolean;
  67548. /** Gets or sets a boolean indicating if the control can be focusable */
  67549. isFocusInvisible: boolean;
  67550. /**
  67551. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  67552. * 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
  67553. */
  67554. clipChildren: boolean;
  67555. /**
  67556. * Gets or sets a boolean indicating that control content must be clipped
  67557. * 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
  67558. */
  67559. clipContent: boolean;
  67560. /**
  67561. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  67562. */
  67563. useBitmapCache: boolean;
  67564. private _cacheData;
  67565. private _shadowOffsetX;
  67566. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  67567. shadowOffsetX: number;
  67568. private _shadowOffsetY;
  67569. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  67570. shadowOffsetY: number;
  67571. private _shadowBlur;
  67572. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  67573. shadowBlur: number;
  67574. private _shadowColor;
  67575. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  67576. shadowColor: string;
  67577. /** Gets or sets the cursor to use when the control is hovered */
  67578. hoverCursor: string;
  67579. /** @hidden */
  67580. protected _linkOffsetX: ValueAndUnit;
  67581. /** @hidden */
  67582. protected _linkOffsetY: ValueAndUnit;
  67583. /** Gets the control type name */
  67584. readonly typeName: string;
  67585. /**
  67586. * Get the current class name of the control.
  67587. * @returns current class name
  67588. */
  67589. getClassName(): string;
  67590. /**
  67591. * An event triggered when the pointer move over the control.
  67592. */
  67593. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  67594. /**
  67595. * An event triggered when the pointer move out of the control.
  67596. */
  67597. onPointerOutObservable: BABYLON.Observable<Control>;
  67598. /**
  67599. * An event triggered when the pointer taps the control
  67600. */
  67601. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  67602. /**
  67603. * An event triggered when pointer up
  67604. */
  67605. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  67606. /**
  67607. * An event triggered when a control is clicked on
  67608. */
  67609. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  67610. /**
  67611. * An event triggered when pointer enters the control
  67612. */
  67613. onPointerEnterObservable: BABYLON.Observable<Control>;
  67614. /**
  67615. * An event triggered when the control is marked as dirty
  67616. */
  67617. onDirtyObservable: BABYLON.Observable<Control>;
  67618. /**
  67619. * An event triggered before drawing the control
  67620. */
  67621. onBeforeDrawObservable: BABYLON.Observable<Control>;
  67622. /**
  67623. * An event triggered after the control was drawn
  67624. */
  67625. onAfterDrawObservable: BABYLON.Observable<Control>;
  67626. /**
  67627. * Get the hosting AdvancedDynamicTexture
  67628. */
  67629. readonly host: AdvancedDynamicTexture;
  67630. /** Gets or set information about font offsets (used to render and align text) */
  67631. fontOffset: {
  67632. ascent: number;
  67633. height: number;
  67634. descent: number;
  67635. };
  67636. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  67637. alpha: number;
  67638. /**
  67639. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  67640. */
  67641. isHighlighted: boolean;
  67642. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  67643. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67644. */
  67645. scaleX: number;
  67646. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  67647. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67648. */
  67649. scaleY: number;
  67650. /** Gets or sets the rotation angle (0 by default)
  67651. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67652. */
  67653. rotation: number;
  67654. /** Gets or sets the transformation center on Y axis (0 by default)
  67655. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67656. */
  67657. transformCenterY: number;
  67658. /** Gets or sets the transformation center on X axis (0 by default)
  67659. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  67660. */
  67661. transformCenterX: number;
  67662. /**
  67663. * Gets or sets the horizontal alignment
  67664. * @see http://doc.babylonjs.com/how_to/gui#alignments
  67665. */
  67666. horizontalAlignment: number;
  67667. /**
  67668. * Gets or sets the vertical alignment
  67669. * @see http://doc.babylonjs.com/how_to/gui#alignments
  67670. */
  67671. verticalAlignment: number;
  67672. /**
  67673. * Gets or sets control width
  67674. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67675. */
  67676. width: string | number;
  67677. /**
  67678. * Gets or sets the control width in pixel
  67679. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67680. */
  67681. widthInPixels: number;
  67682. /**
  67683. * Gets or sets control height
  67684. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67685. */
  67686. height: string | number;
  67687. /**
  67688. * Gets or sets control height in pixel
  67689. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67690. */
  67691. heightInPixels: number;
  67692. /** Gets or set font family */
  67693. fontFamily: string;
  67694. /** Gets or sets font style */
  67695. fontStyle: string;
  67696. /** Gets or sets font weight */
  67697. fontWeight: string;
  67698. /**
  67699. * Gets or sets style
  67700. * @see http://doc.babylonjs.com/how_to/gui#styles
  67701. */
  67702. style: BABYLON.Nullable<Style>;
  67703. /** @hidden */
  67704. readonly _isFontSizeInPercentage: boolean;
  67705. /** Gets or sets font size in pixels */
  67706. fontSizeInPixels: number;
  67707. /** Gets or sets font size */
  67708. fontSize: string | number;
  67709. /** Gets or sets foreground color */
  67710. color: string;
  67711. /** Gets or sets z index which is used to reorder controls on the z axis */
  67712. zIndex: number;
  67713. /** Gets or sets a boolean indicating if the control can be rendered */
  67714. notRenderable: boolean;
  67715. /** Gets or sets a boolean indicating if the control is visible */
  67716. isVisible: boolean;
  67717. /** Gets a boolean indicating that the control needs to update its rendering */
  67718. readonly isDirty: boolean;
  67719. /**
  67720. * Gets the current linked mesh (or null if none)
  67721. */
  67722. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67723. /**
  67724. * Gets or sets a value indicating the padding to use on the left of the control
  67725. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67726. */
  67727. paddingLeft: string | number;
  67728. /**
  67729. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  67730. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67731. */
  67732. paddingLeftInPixels: number;
  67733. /**
  67734. * Gets or sets a value indicating the padding to use on the right of the control
  67735. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67736. */
  67737. paddingRight: string | number;
  67738. /**
  67739. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  67740. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67741. */
  67742. paddingRightInPixels: number;
  67743. /**
  67744. * Gets or sets a value indicating the padding to use on the top of the control
  67745. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67746. */
  67747. paddingTop: string | number;
  67748. /**
  67749. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  67750. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67751. */
  67752. paddingTopInPixels: number;
  67753. /**
  67754. * Gets or sets a value indicating the padding to use on the bottom of the control
  67755. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67756. */
  67757. paddingBottom: string | number;
  67758. /**
  67759. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  67760. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67761. */
  67762. paddingBottomInPixels: number;
  67763. /**
  67764. * Gets or sets a value indicating the left coordinate of the control
  67765. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67766. */
  67767. left: string | number;
  67768. /**
  67769. * Gets or sets a value indicating the left coordinate in pixels of the control
  67770. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67771. */
  67772. leftInPixels: number;
  67773. /**
  67774. * Gets or sets a value indicating the top coordinate of the control
  67775. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67776. */
  67777. top: string | number;
  67778. /**
  67779. * Gets or sets a value indicating the top coordinate in pixels of the control
  67780. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67781. */
  67782. topInPixels: number;
  67783. /**
  67784. * Gets or sets a value indicating the offset on X axis to the linked mesh
  67785. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67786. */
  67787. linkOffsetX: string | number;
  67788. /**
  67789. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  67790. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67791. */
  67792. linkOffsetXInPixels: number;
  67793. /**
  67794. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  67795. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67796. */
  67797. linkOffsetY: string | number;
  67798. /**
  67799. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  67800. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67801. */
  67802. linkOffsetYInPixels: number;
  67803. /** Gets the center coordinate on X axis */
  67804. readonly centerX: number;
  67805. /** Gets the center coordinate on Y axis */
  67806. readonly centerY: number;
  67807. /** Gets or sets if control is Enabled*/
  67808. isEnabled: boolean;
  67809. /** Gets or sets background color of control if it's disabled*/
  67810. disabledColor: string;
  67811. /**
  67812. * Creates a new control
  67813. * @param name defines the name of the control
  67814. */
  67815. constructor(
  67816. /** defines the name of the control */
  67817. name?: string | undefined);
  67818. /** @hidden */
  67819. protected _getTypeName(): string;
  67820. /**
  67821. * Gets the first ascendant in the hierarchy of the given type
  67822. * @param className defines the required type
  67823. * @returns the ascendant or null if not found
  67824. */
  67825. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  67826. /** @hidden */
  67827. _resetFontCache(): void;
  67828. /**
  67829. * Determines if a container is an ascendant of the current control
  67830. * @param container defines the container to look for
  67831. * @returns true if the container is one of the ascendant of the control
  67832. */
  67833. isAscendant(container: Control): boolean;
  67834. /**
  67835. * Gets coordinates in local control space
  67836. * @param globalCoordinates defines the coordinates to transform
  67837. * @returns the new coordinates in local space
  67838. */
  67839. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  67840. /**
  67841. * Gets coordinates in local control space
  67842. * @param globalCoordinates defines the coordinates to transform
  67843. * @param result defines the target vector2 where to store the result
  67844. * @returns the current control
  67845. */
  67846. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  67847. /**
  67848. * Gets coordinates in parent local control space
  67849. * @param globalCoordinates defines the coordinates to transform
  67850. * @returns the new coordinates in parent local space
  67851. */
  67852. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  67853. /**
  67854. * Move the current control to a vector3 position projected onto the screen.
  67855. * @param position defines the target position
  67856. * @param scene defines the hosting scene
  67857. */
  67858. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  67859. /**
  67860. * Will store all controls that have this control as ascendant in a given array
  67861. * @param results defines the array where to store the descendants
  67862. * @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
  67863. * @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
  67864. */
  67865. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  67866. /**
  67867. * Will return all controls that have this control as ascendant
  67868. * @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
  67869. * @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
  67870. * @return all child controls
  67871. */
  67872. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  67873. /**
  67874. * Link current control with a target mesh
  67875. * @param mesh defines the mesh to link with
  67876. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  67877. */
  67878. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  67879. /** @hidden */
  67880. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  67881. /** @hidden */
  67882. _offsetLeft(offset: number): void;
  67883. /** @hidden */
  67884. _offsetTop(offset: number): void;
  67885. /** @hidden */
  67886. _markMatrixAsDirty(): void;
  67887. /** @hidden */
  67888. _flagDescendantsAsMatrixDirty(): void;
  67889. /** @hidden */
  67890. _intersectsRect(rect: Measure): boolean;
  67891. /** @hidden */
  67892. protected invalidateRect(): void;
  67893. /** @hidden */
  67894. _markAsDirty(force?: boolean): void;
  67895. /** @hidden */
  67896. _markAllAsDirty(): void;
  67897. /** @hidden */
  67898. _link(host: AdvancedDynamicTexture): void;
  67899. /** @hidden */
  67900. protected _transform(context?: CanvasRenderingContext2D): void;
  67901. /** @hidden */
  67902. _renderHighlight(context: CanvasRenderingContext2D): void;
  67903. /** @hidden */
  67904. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67905. /** @hidden */
  67906. protected _applyStates(context: CanvasRenderingContext2D): void;
  67907. /** @hidden */
  67908. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  67909. /** @hidden */
  67910. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67911. protected _evaluateClippingState(parentMeasure: Measure): void;
  67912. /** @hidden */
  67913. _measure(): void;
  67914. /** @hidden */
  67915. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67916. /** @hidden */
  67917. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67918. /** @hidden */
  67919. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67920. /** @hidden */
  67921. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67922. private static _ClipMeasure;
  67923. private _tmpMeasureA;
  67924. private _clip;
  67925. /** @hidden */
  67926. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  67927. /** @hidden */
  67928. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  67929. /**
  67930. * Tests if a given coordinates belong to the current control
  67931. * @param x defines x coordinate to test
  67932. * @param y defines y coordinate to test
  67933. * @returns true if the coordinates are inside the control
  67934. */
  67935. contains(x: number, y: number): boolean;
  67936. /** @hidden */
  67937. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  67938. /** @hidden */
  67939. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67940. /** @hidden */
  67941. _onPointerEnter(target: Control): boolean;
  67942. /** @hidden */
  67943. _onPointerOut(target: Control, force?: boolean): void;
  67944. /** @hidden */
  67945. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67946. /** @hidden */
  67947. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67948. /** @hidden */
  67949. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67950. /** @hidden */
  67951. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  67952. private _prepareFont;
  67953. /** Releases associated resources */
  67954. dispose(): void;
  67955. private static _HORIZONTAL_ALIGNMENT_LEFT;
  67956. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  67957. private static _HORIZONTAL_ALIGNMENT_CENTER;
  67958. private static _VERTICAL_ALIGNMENT_TOP;
  67959. private static _VERTICAL_ALIGNMENT_BOTTOM;
  67960. private static _VERTICAL_ALIGNMENT_CENTER;
  67961. /** HORIZONTAL_ALIGNMENT_LEFT */
  67962. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  67963. /** HORIZONTAL_ALIGNMENT_RIGHT */
  67964. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  67965. /** HORIZONTAL_ALIGNMENT_CENTER */
  67966. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  67967. /** VERTICAL_ALIGNMENT_TOP */
  67968. static readonly VERTICAL_ALIGNMENT_TOP: number;
  67969. /** VERTICAL_ALIGNMENT_BOTTOM */
  67970. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  67971. /** VERTICAL_ALIGNMENT_CENTER */
  67972. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  67973. private static _FontHeightSizes;
  67974. /** @hidden */
  67975. static _GetFontOffset(font: string): {
  67976. ascent: number;
  67977. height: number;
  67978. descent: number;
  67979. };
  67980. /**
  67981. * Creates a stack panel that can be used to render headers
  67982. * @param control defines the control to associate with the header
  67983. * @param text defines the text of the header
  67984. * @param size defines the size of the header
  67985. * @param options defines options used to configure the header
  67986. * @returns a new StackPanel
  67987. * @ignore
  67988. * @hidden
  67989. */
  67990. static AddHeader: (control: Control, text: string, size: string | number, options: {
  67991. isHorizontal: boolean;
  67992. controlFirst: boolean;
  67993. }) => any;
  67994. /** @hidden */
  67995. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  67996. }
  67997. }
  67998. declare module BABYLON.GUI {
  67999. /**
  68000. * Root class for 2D containers
  68001. * @see http://doc.babylonjs.com/how_to/gui#containers
  68002. */
  68003. export class Container extends Control {
  68004. name?: string | undefined;
  68005. /** @hidden */
  68006. protected _children: Control[];
  68007. /** @hidden */
  68008. protected _measureForChildren: Measure;
  68009. /** @hidden */
  68010. protected _background: string;
  68011. /** @hidden */
  68012. protected _adaptWidthToChildren: boolean;
  68013. /** @hidden */
  68014. protected _adaptHeightToChildren: boolean;
  68015. /**
  68016. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  68017. */
  68018. logLayoutCycleErrors: boolean;
  68019. /**
  68020. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  68021. */
  68022. maxLayoutCycle: number;
  68023. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  68024. adaptHeightToChildren: boolean;
  68025. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  68026. adaptWidthToChildren: boolean;
  68027. /** Gets or sets background color */
  68028. background: string;
  68029. /** Gets the list of children */
  68030. readonly children: Control[];
  68031. /**
  68032. * Creates a new Container
  68033. * @param name defines the name of the container
  68034. */
  68035. constructor(name?: string | undefined);
  68036. protected _getTypeName(): string;
  68037. _flagDescendantsAsMatrixDirty(): void;
  68038. /**
  68039. * Gets a child using its name
  68040. * @param name defines the child name to look for
  68041. * @returns the child control if found
  68042. */
  68043. getChildByName(name: string): BABYLON.Nullable<Control>;
  68044. /**
  68045. * Gets a child using its type and its name
  68046. * @param name defines the child name to look for
  68047. * @param type defines the child type to look for
  68048. * @returns the child control if found
  68049. */
  68050. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  68051. /**
  68052. * Search for a specific control in children
  68053. * @param control defines the control to look for
  68054. * @returns true if the control is in child list
  68055. */
  68056. containsControl(control: Control): boolean;
  68057. /**
  68058. * Adds a new control to the current container
  68059. * @param control defines the control to add
  68060. * @returns the current container
  68061. */
  68062. addControl(control: BABYLON.Nullable<Control>): Container;
  68063. /**
  68064. * Removes all controls from the current container
  68065. * @returns the current container
  68066. */
  68067. clearControls(): Container;
  68068. /**
  68069. * Removes a control from the current container
  68070. * @param control defines the control to remove
  68071. * @returns the current container
  68072. */
  68073. removeControl(control: Control): Container;
  68074. /** @hidden */
  68075. _reOrderControl(control: Control): void;
  68076. /** @hidden */
  68077. _offsetLeft(offset: number): void;
  68078. /** @hidden */
  68079. _offsetTop(offset: number): void;
  68080. /** @hidden */
  68081. _markAllAsDirty(): void;
  68082. /** @hidden */
  68083. protected _localDraw(context: CanvasRenderingContext2D): void;
  68084. /** @hidden */
  68085. _link(host: AdvancedDynamicTexture): void;
  68086. /** @hidden */
  68087. protected _beforeLayout(): void;
  68088. /** @hidden */
  68089. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68090. /** @hidden */
  68091. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  68092. protected _postMeasure(): void;
  68093. /** @hidden */
  68094. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  68095. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  68096. /** @hidden */
  68097. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68098. /** @hidden */
  68099. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68100. /** Releases associated resources */
  68101. dispose(): void;
  68102. }
  68103. }
  68104. declare module BABYLON.GUI {
  68105. /** Class used to create rectangle container */
  68106. export class Rectangle extends Container {
  68107. name?: string | undefined;
  68108. private _thickness;
  68109. private _cornerRadius;
  68110. /** Gets or sets border thickness */
  68111. thickness: number;
  68112. /** Gets or sets the corner radius angle */
  68113. cornerRadius: number;
  68114. /**
  68115. * Creates a new Rectangle
  68116. * @param name defines the control name
  68117. */
  68118. constructor(name?: string | undefined);
  68119. protected _getTypeName(): string;
  68120. protected _localDraw(context: CanvasRenderingContext2D): void;
  68121. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68122. private _drawRoundedRect;
  68123. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  68124. }
  68125. }
  68126. declare module BABYLON.GUI {
  68127. /**
  68128. * Enum that determines the text-wrapping mode to use.
  68129. */
  68130. export enum TextWrapping {
  68131. /**
  68132. * Clip the text when it's larger than Control.width; this is the default mode.
  68133. */
  68134. Clip = 0,
  68135. /**
  68136. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  68137. */
  68138. WordWrap = 1,
  68139. /**
  68140. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  68141. */
  68142. Ellipsis = 2
  68143. }
  68144. /**
  68145. * Class used to create text block control
  68146. */
  68147. export class TextBlock extends Control {
  68148. /**
  68149. * Defines the name of the control
  68150. */
  68151. name?: string | undefined;
  68152. private _text;
  68153. private _textWrapping;
  68154. private _textHorizontalAlignment;
  68155. private _textVerticalAlignment;
  68156. private _lines;
  68157. private _resizeToFit;
  68158. private _lineSpacing;
  68159. private _outlineWidth;
  68160. private _outlineColor;
  68161. /**
  68162. * An event triggered after the text is changed
  68163. */
  68164. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  68165. /**
  68166. * An event triggered after the text was broken up into lines
  68167. */
  68168. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  68169. /**
  68170. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  68171. */
  68172. readonly lines: any[];
  68173. /**
  68174. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68175. */
  68176. /**
  68177. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  68178. */
  68179. resizeToFit: boolean;
  68180. /**
  68181. * Gets or sets a boolean indicating if text must be wrapped
  68182. */
  68183. /**
  68184. * Gets or sets a boolean indicating if text must be wrapped
  68185. */
  68186. textWrapping: TextWrapping | boolean;
  68187. /**
  68188. * Gets or sets text to display
  68189. */
  68190. /**
  68191. * Gets or sets text to display
  68192. */
  68193. text: string;
  68194. /**
  68195. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68196. */
  68197. /**
  68198. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  68199. */
  68200. textHorizontalAlignment: number;
  68201. /**
  68202. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68203. */
  68204. /**
  68205. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  68206. */
  68207. textVerticalAlignment: number;
  68208. /**
  68209. * Gets or sets line spacing value
  68210. */
  68211. /**
  68212. * Gets or sets line spacing value
  68213. */
  68214. lineSpacing: string | number;
  68215. /**
  68216. * Gets or sets outlineWidth of the text to display
  68217. */
  68218. /**
  68219. * Gets or sets outlineWidth of the text to display
  68220. */
  68221. outlineWidth: number;
  68222. /**
  68223. * Gets or sets outlineColor of the text to display
  68224. */
  68225. /**
  68226. * Gets or sets outlineColor of the text to display
  68227. */
  68228. outlineColor: string;
  68229. /**
  68230. * Creates a new TextBlock object
  68231. * @param name defines the name of the control
  68232. * @param text defines the text to display (emptry string by default)
  68233. */
  68234. constructor(
  68235. /**
  68236. * Defines the name of the control
  68237. */
  68238. name?: string | undefined, text?: string);
  68239. protected _getTypeName(): string;
  68240. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68241. private _drawText;
  68242. /** @hidden */
  68243. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68244. protected _applyStates(context: CanvasRenderingContext2D): void;
  68245. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  68246. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  68247. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  68248. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  68249. protected _renderLines(context: CanvasRenderingContext2D): void;
  68250. /**
  68251. * Given a width constraint applied on the text block, find the expected height
  68252. * @returns expected height
  68253. */
  68254. computeExpectedHeight(): number;
  68255. dispose(): void;
  68256. }
  68257. }
  68258. declare module BABYLON.GUI {
  68259. /**
  68260. * Class used to create 2D images
  68261. */
  68262. export class Image extends Control {
  68263. name?: string | undefined;
  68264. private _workingCanvas;
  68265. private _domImage;
  68266. private _imageWidth;
  68267. private _imageHeight;
  68268. private _loaded;
  68269. private _stretch;
  68270. private _source;
  68271. private _autoScale;
  68272. private _sourceLeft;
  68273. private _sourceTop;
  68274. private _sourceWidth;
  68275. private _sourceHeight;
  68276. private _cellWidth;
  68277. private _cellHeight;
  68278. private _cellId;
  68279. private _populateNinePatchSlicesFromImage;
  68280. private _sliceLeft;
  68281. private _sliceRight;
  68282. private _sliceTop;
  68283. private _sliceBottom;
  68284. private _detectPointerOnOpaqueOnly;
  68285. /**
  68286. * BABYLON.Observable notified when the content is loaded
  68287. */
  68288. onImageLoadedObservable: BABYLON.Observable<Image>;
  68289. /**
  68290. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  68291. */
  68292. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  68293. /**
  68294. * Gets a boolean indicating that the content is loaded
  68295. */
  68296. readonly isLoaded: boolean;
  68297. /**
  68298. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  68299. */
  68300. populateNinePatchSlicesFromImage: boolean;
  68301. /**
  68302. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  68303. * Beware using this as this will comsume more memory as the image has to be stored twice
  68304. */
  68305. detectPointerOnOpaqueOnly: boolean;
  68306. /**
  68307. * Gets or sets the left value for slicing (9-patch)
  68308. */
  68309. sliceLeft: number;
  68310. /**
  68311. * Gets or sets the right value for slicing (9-patch)
  68312. */
  68313. sliceRight: number;
  68314. /**
  68315. * Gets or sets the top value for slicing (9-patch)
  68316. */
  68317. sliceTop: number;
  68318. /**
  68319. * Gets or sets the bottom value for slicing (9-patch)
  68320. */
  68321. sliceBottom: number;
  68322. /**
  68323. * Gets or sets the left coordinate in the source image
  68324. */
  68325. sourceLeft: number;
  68326. /**
  68327. * Gets or sets the top coordinate in the source image
  68328. */
  68329. sourceTop: number;
  68330. /**
  68331. * Gets or sets the width to capture in the source image
  68332. */
  68333. sourceWidth: number;
  68334. /**
  68335. * Gets or sets the height to capture in the source image
  68336. */
  68337. sourceHeight: number;
  68338. /**
  68339. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  68340. * @see http://doc.babylonjs.com/how_to/gui#image
  68341. */
  68342. autoScale: boolean;
  68343. /** Gets or sets the streching mode used by the image */
  68344. stretch: number;
  68345. /** @hidden */
  68346. _rotate90(n: number): Image;
  68347. /**
  68348. * Gets or sets the internal DOM image used to render the control
  68349. */
  68350. domImage: HTMLImageElement;
  68351. private _onImageLoaded;
  68352. private _extractNinePatchSliceDataFromImage;
  68353. /**
  68354. * Gets or sets image source url
  68355. */
  68356. source: BABYLON.Nullable<string>;
  68357. /**
  68358. * Checks for svg document with icon id present
  68359. */
  68360. private _svgCheck;
  68361. /**
  68362. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  68363. * given external svg file and icon id
  68364. */
  68365. private _getSVGAttribs;
  68366. /**
  68367. * Gets or sets the cell width to use when animation sheet is enabled
  68368. * @see http://doc.babylonjs.com/how_to/gui#image
  68369. */
  68370. cellWidth: number;
  68371. /**
  68372. * Gets or sets the cell height to use when animation sheet is enabled
  68373. * @see http://doc.babylonjs.com/how_to/gui#image
  68374. */
  68375. cellHeight: number;
  68376. /**
  68377. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  68378. * @see http://doc.babylonjs.com/how_to/gui#image
  68379. */
  68380. cellId: number;
  68381. /**
  68382. * Creates a new Image
  68383. * @param name defines the control name
  68384. * @param url defines the image url
  68385. */
  68386. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  68387. /**
  68388. * Tests if a given coordinates belong to the current control
  68389. * @param x defines x coordinate to test
  68390. * @param y defines y coordinate to test
  68391. * @returns true if the coordinates are inside the control
  68392. */
  68393. contains(x: number, y: number): boolean;
  68394. protected _getTypeName(): string;
  68395. /** Force the control to synchronize with its content */
  68396. synchronizeSizeWithContent(): void;
  68397. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68398. private _prepareWorkingCanvasForOpaqueDetection;
  68399. private _drawImage;
  68400. _draw(context: CanvasRenderingContext2D): void;
  68401. private _renderCornerPatch;
  68402. private _renderNinePatch;
  68403. dispose(): void;
  68404. /** STRETCH_NONE */
  68405. static readonly STRETCH_NONE: number;
  68406. /** STRETCH_FILL */
  68407. static readonly STRETCH_FILL: number;
  68408. /** STRETCH_UNIFORM */
  68409. static readonly STRETCH_UNIFORM: number;
  68410. /** STRETCH_EXTEND */
  68411. static readonly STRETCH_EXTEND: number;
  68412. /** NINE_PATCH */
  68413. static readonly STRETCH_NINE_PATCH: number;
  68414. }
  68415. }
  68416. declare module BABYLON.GUI {
  68417. /**
  68418. * Class used to create 2D buttons
  68419. */
  68420. export class Button extends Rectangle {
  68421. name?: string | undefined;
  68422. /**
  68423. * Function called to generate a pointer enter animation
  68424. */
  68425. pointerEnterAnimation: () => void;
  68426. /**
  68427. * Function called to generate a pointer out animation
  68428. */
  68429. pointerOutAnimation: () => void;
  68430. /**
  68431. * Function called to generate a pointer down animation
  68432. */
  68433. pointerDownAnimation: () => void;
  68434. /**
  68435. * Function called to generate a pointer up animation
  68436. */
  68437. pointerUpAnimation: () => void;
  68438. /**
  68439. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  68440. */
  68441. delegatePickingToChildren: boolean;
  68442. private _image;
  68443. /**
  68444. * Returns the image part of the button (if any)
  68445. */
  68446. readonly image: BABYLON.Nullable<Image>;
  68447. private _textBlock;
  68448. /**
  68449. * Returns the image part of the button (if any)
  68450. */
  68451. readonly textBlock: BABYLON.Nullable<TextBlock>;
  68452. /**
  68453. * Creates a new Button
  68454. * @param name defines the name of the button
  68455. */
  68456. constructor(name?: string | undefined);
  68457. protected _getTypeName(): string;
  68458. /** @hidden */
  68459. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  68460. /** @hidden */
  68461. _onPointerEnter(target: Control): boolean;
  68462. /** @hidden */
  68463. _onPointerOut(target: Control, force?: boolean): void;
  68464. /** @hidden */
  68465. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68466. /** @hidden */
  68467. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68468. /**
  68469. * Creates a new button made with an image and a text
  68470. * @param name defines the name of the button
  68471. * @param text defines the text of the button
  68472. * @param imageUrl defines the url of the image
  68473. * @returns a new Button
  68474. */
  68475. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  68476. /**
  68477. * Creates a new button made with an image
  68478. * @param name defines the name of the button
  68479. * @param imageUrl defines the url of the image
  68480. * @returns a new Button
  68481. */
  68482. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  68483. /**
  68484. * Creates a new button made with a text
  68485. * @param name defines the name of the button
  68486. * @param text defines the text of the button
  68487. * @returns a new Button
  68488. */
  68489. static CreateSimpleButton(name: string, text: string): Button;
  68490. /**
  68491. * Creates a new button made with an image and a centered text
  68492. * @param name defines the name of the button
  68493. * @param text defines the text of the button
  68494. * @param imageUrl defines the url of the image
  68495. * @returns a new Button
  68496. */
  68497. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  68498. }
  68499. }
  68500. declare module BABYLON.GUI {
  68501. /**
  68502. * Class used to create a 2D stack panel container
  68503. */
  68504. export class StackPanel extends Container {
  68505. name?: string | undefined;
  68506. private _isVertical;
  68507. private _manualWidth;
  68508. private _manualHeight;
  68509. private _doNotTrackManualChanges;
  68510. /**
  68511. * Gets or sets a boolean indicating that layou warnings should be ignored
  68512. */
  68513. ignoreLayoutWarnings: boolean;
  68514. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  68515. isVertical: boolean;
  68516. /**
  68517. * Gets or sets panel width.
  68518. * This value should not be set when in horizontal mode as it will be computed automatically
  68519. */
  68520. width: string | number;
  68521. /**
  68522. * Gets or sets panel height.
  68523. * This value should not be set when in vertical mode as it will be computed automatically
  68524. */
  68525. height: string | number;
  68526. /**
  68527. * Creates a new StackPanel
  68528. * @param name defines control name
  68529. */
  68530. constructor(name?: string | undefined);
  68531. protected _getTypeName(): string;
  68532. /** @hidden */
  68533. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68534. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68535. protected _postMeasure(): void;
  68536. }
  68537. }
  68538. declare module BABYLON.GUI {
  68539. /**
  68540. * Class used to represent a 2D checkbox
  68541. */
  68542. export class Checkbox extends Control {
  68543. name?: string | undefined;
  68544. private _isChecked;
  68545. private _background;
  68546. private _checkSizeRatio;
  68547. private _thickness;
  68548. /** Gets or sets border thickness */
  68549. thickness: number;
  68550. /**
  68551. * BABYLON.Observable raised when isChecked property changes
  68552. */
  68553. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  68554. /** Gets or sets a value indicating the ratio between overall size and check size */
  68555. checkSizeRatio: number;
  68556. /** Gets or sets background color */
  68557. background: string;
  68558. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  68559. isChecked: boolean;
  68560. /**
  68561. * Creates a new CheckBox
  68562. * @param name defines the control name
  68563. */
  68564. constructor(name?: string | undefined);
  68565. protected _getTypeName(): string;
  68566. /** @hidden */
  68567. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68568. /** @hidden */
  68569. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68570. /**
  68571. * Utility function to easily create a checkbox with a header
  68572. * @param title defines the label to use for the header
  68573. * @param onValueChanged defines the callback to call when value changes
  68574. * @returns a StackPanel containing the checkbox and a textBlock
  68575. */
  68576. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  68577. }
  68578. }
  68579. declare module BABYLON.GUI {
  68580. /**
  68581. * Class used to store key control properties
  68582. */
  68583. export class KeyPropertySet {
  68584. /** Width */
  68585. width?: string;
  68586. /** Height */
  68587. height?: string;
  68588. /** Left padding */
  68589. paddingLeft?: string;
  68590. /** Right padding */
  68591. paddingRight?: string;
  68592. /** Top padding */
  68593. paddingTop?: string;
  68594. /** Bottom padding */
  68595. paddingBottom?: string;
  68596. /** Foreground color */
  68597. color?: string;
  68598. /** Background color */
  68599. background?: string;
  68600. }
  68601. /**
  68602. * Class used to create virtual keyboard
  68603. */
  68604. export class VirtualKeyboard extends StackPanel {
  68605. /** BABYLON.Observable raised when a key is pressed */
  68606. onKeyPressObservable: BABYLON.Observable<string>;
  68607. /** Gets or sets default key button width */
  68608. defaultButtonWidth: string;
  68609. /** Gets or sets default key button height */
  68610. defaultButtonHeight: string;
  68611. /** Gets or sets default key button left padding */
  68612. defaultButtonPaddingLeft: string;
  68613. /** Gets or sets default key button right padding */
  68614. defaultButtonPaddingRight: string;
  68615. /** Gets or sets default key button top padding */
  68616. defaultButtonPaddingTop: string;
  68617. /** Gets or sets default key button bottom padding */
  68618. defaultButtonPaddingBottom: string;
  68619. /** Gets or sets default key button foreground color */
  68620. defaultButtonColor: string;
  68621. /** Gets or sets default key button background color */
  68622. defaultButtonBackground: string;
  68623. /** Gets or sets shift button foreground color */
  68624. shiftButtonColor: string;
  68625. /** Gets or sets shift button thickness*/
  68626. selectedShiftThickness: number;
  68627. /** Gets shift key state */
  68628. shiftState: number;
  68629. protected _getTypeName(): string;
  68630. private _createKey;
  68631. /**
  68632. * Adds a new row of keys
  68633. * @param keys defines the list of keys to add
  68634. * @param propertySets defines the associated property sets
  68635. */
  68636. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  68637. /**
  68638. * Set the shift key to a specific state
  68639. * @param shiftState defines the new shift state
  68640. */
  68641. applyShiftState(shiftState: number): void;
  68642. private _currentlyConnectedInputText;
  68643. private _connectedInputTexts;
  68644. private _onKeyPressObserver;
  68645. /** Gets the input text control currently attached to the keyboard */
  68646. readonly connectedInputText: BABYLON.Nullable<InputText>;
  68647. /**
  68648. * Connects the keyboard with an input text control
  68649. *
  68650. * @param input defines the target control
  68651. */
  68652. connect(input: InputText): void;
  68653. /**
  68654. * Disconnects the keyboard from connected InputText controls
  68655. *
  68656. * @param input optionally defines a target control, otherwise all are disconnected
  68657. */
  68658. disconnect(input?: InputText): void;
  68659. private _removeConnectedInputObservables;
  68660. /**
  68661. * Release all resources
  68662. */
  68663. dispose(): void;
  68664. /**
  68665. * Creates a new keyboard using a default layout
  68666. *
  68667. * @param name defines control name
  68668. * @returns a new VirtualKeyboard
  68669. */
  68670. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  68671. }
  68672. }
  68673. declare module BABYLON.GUI {
  68674. /**
  68675. * Class used to create input text control
  68676. */
  68677. export class InputText extends Control implements IFocusableControl {
  68678. name?: string | undefined;
  68679. private _text;
  68680. private _placeholderText;
  68681. private _background;
  68682. private _focusedBackground;
  68683. private _focusedColor;
  68684. private _placeholderColor;
  68685. private _thickness;
  68686. private _margin;
  68687. private _autoStretchWidth;
  68688. private _maxWidth;
  68689. private _isFocused;
  68690. private _blinkTimeout;
  68691. private _blinkIsEven;
  68692. private _cursorOffset;
  68693. private _scrollLeft;
  68694. private _textWidth;
  68695. private _clickedCoordinate;
  68696. private _deadKey;
  68697. private _addKey;
  68698. private _currentKey;
  68699. private _isTextHighlightOn;
  68700. private _textHighlightColor;
  68701. private _highligherOpacity;
  68702. private _highlightedText;
  68703. private _startHighlightIndex;
  68704. private _endHighlightIndex;
  68705. private _cursorIndex;
  68706. private _onFocusSelectAll;
  68707. private _isPointerDown;
  68708. private _onClipboardObserver;
  68709. private _onPointerDblTapObserver;
  68710. /** @hidden */
  68711. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  68712. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  68713. promptMessage: string;
  68714. /** Force disable prompt on mobile device */
  68715. disableMobilePrompt: boolean;
  68716. /** BABYLON.Observable raised when the text changes */
  68717. onTextChangedObservable: BABYLON.Observable<InputText>;
  68718. /** BABYLON.Observable raised just before an entered character is to be added */
  68719. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  68720. /** BABYLON.Observable raised when the control gets the focus */
  68721. onFocusObservable: BABYLON.Observable<InputText>;
  68722. /** BABYLON.Observable raised when the control loses the focus */
  68723. onBlurObservable: BABYLON.Observable<InputText>;
  68724. /**Observable raised when the text is highlighted */
  68725. onTextHighlightObservable: BABYLON.Observable<InputText>;
  68726. /**Observable raised when copy event is triggered */
  68727. onTextCopyObservable: BABYLON.Observable<InputText>;
  68728. /** BABYLON.Observable raised when cut event is triggered */
  68729. onTextCutObservable: BABYLON.Observable<InputText>;
  68730. /** BABYLON.Observable raised when paste event is triggered */
  68731. onTextPasteObservable: BABYLON.Observable<InputText>;
  68732. /** BABYLON.Observable raised when a key event was processed */
  68733. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  68734. /** Gets or sets the maximum width allowed by the control */
  68735. maxWidth: string | number;
  68736. /** Gets the maximum width allowed by the control in pixels */
  68737. readonly maxWidthInPixels: number;
  68738. /** Gets or sets the text highlighter transparency; default: 0.4 */
  68739. highligherOpacity: number;
  68740. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  68741. onFocusSelectAll: boolean;
  68742. /** Gets or sets the text hightlight color */
  68743. textHighlightColor: string;
  68744. /** Gets or sets control margin */
  68745. margin: string;
  68746. /** Gets control margin in pixels */
  68747. readonly marginInPixels: number;
  68748. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  68749. autoStretchWidth: boolean;
  68750. /** Gets or sets border thickness */
  68751. thickness: number;
  68752. /** Gets or sets the background color when focused */
  68753. focusedBackground: string;
  68754. /** Gets or sets the background color when focused */
  68755. focusedColor: string;
  68756. /** Gets or sets the background color */
  68757. background: string;
  68758. /** Gets or sets the placeholder color */
  68759. placeholderColor: string;
  68760. /** Gets or sets the text displayed when the control is empty */
  68761. placeholderText: string;
  68762. /** Gets or sets the dead key flag */
  68763. deadKey: boolean;
  68764. /** Gets or sets the highlight text */
  68765. highlightedText: string;
  68766. /** Gets or sets if the current key should be added */
  68767. addKey: boolean;
  68768. /** Gets or sets the value of the current key being entered */
  68769. currentKey: string;
  68770. /** Gets or sets the text displayed in the control */
  68771. text: string;
  68772. /** Gets or sets control width */
  68773. width: string | number;
  68774. /**
  68775. * Creates a new InputText
  68776. * @param name defines the control name
  68777. * @param text defines the text of the control
  68778. */
  68779. constructor(name?: string | undefined, text?: string);
  68780. /** @hidden */
  68781. onBlur(): void;
  68782. /** @hidden */
  68783. onFocus(): void;
  68784. protected _getTypeName(): string;
  68785. /**
  68786. * Function called to get the list of controls that should not steal the focus from this control
  68787. * @returns an array of controls
  68788. */
  68789. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  68790. /** @hidden */
  68791. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  68792. /** @hidden */
  68793. private _updateValueFromCursorIndex;
  68794. /** @hidden */
  68795. private _processDblClick;
  68796. /** @hidden */
  68797. private _selectAllText;
  68798. /**
  68799. * Handles the keyboard event
  68800. * @param evt Defines the KeyboardEvent
  68801. */
  68802. processKeyboard(evt: KeyboardEvent): void;
  68803. /** @hidden */
  68804. private _onCopyText;
  68805. /** @hidden */
  68806. private _onCutText;
  68807. /** @hidden */
  68808. private _onPasteText;
  68809. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  68810. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68811. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68812. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68813. protected _beforeRenderText(text: string): string;
  68814. dispose(): void;
  68815. }
  68816. }
  68817. declare module BABYLON.GUI {
  68818. /**
  68819. * Class used to create a 2D grid container
  68820. */
  68821. export class Grid extends Container {
  68822. name?: string | undefined;
  68823. private _rowDefinitions;
  68824. private _columnDefinitions;
  68825. private _cells;
  68826. private _childControls;
  68827. /**
  68828. * Gets the number of columns
  68829. */
  68830. readonly columnCount: number;
  68831. /**
  68832. * Gets the number of rows
  68833. */
  68834. readonly rowCount: number;
  68835. /** Gets the list of children */
  68836. readonly children: Control[];
  68837. /** Gets the list of cells (e.g. the containers) */
  68838. readonly cells: {
  68839. [key: string]: Container;
  68840. };
  68841. /**
  68842. * Gets the definition of a specific row
  68843. * @param index defines the index of the row
  68844. * @returns the row definition
  68845. */
  68846. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  68847. /**
  68848. * Gets the definition of a specific column
  68849. * @param index defines the index of the column
  68850. * @returns the column definition
  68851. */
  68852. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  68853. /**
  68854. * Adds a new row to the grid
  68855. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  68856. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  68857. * @returns the current grid
  68858. */
  68859. addRowDefinition(height: number, isPixel?: boolean): Grid;
  68860. /**
  68861. * Adds a new column to the grid
  68862. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  68863. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  68864. * @returns the current grid
  68865. */
  68866. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  68867. /**
  68868. * Update a row definition
  68869. * @param index defines the index of the row to update
  68870. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  68871. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  68872. * @returns the current grid
  68873. */
  68874. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  68875. /**
  68876. * Update a column definition
  68877. * @param index defines the index of the column to update
  68878. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  68879. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  68880. * @returns the current grid
  68881. */
  68882. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  68883. /**
  68884. * Gets the list of children stored in a specific cell
  68885. * @param row defines the row to check
  68886. * @param column defines the column to check
  68887. * @returns the list of controls
  68888. */
  68889. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  68890. /**
  68891. * Gets a string representing the child cell info (row x column)
  68892. * @param child defines the control to get info from
  68893. * @returns a string containing the child cell info (row x column)
  68894. */
  68895. getChildCellInfo(child: Control): string;
  68896. private _removeCell;
  68897. private _offsetCell;
  68898. /**
  68899. * Remove a column definition at specified index
  68900. * @param index defines the index of the column to remove
  68901. * @returns the current grid
  68902. */
  68903. removeColumnDefinition(index: number): Grid;
  68904. /**
  68905. * Remove a row definition at specified index
  68906. * @param index defines the index of the row to remove
  68907. * @returns the current grid
  68908. */
  68909. removeRowDefinition(index: number): Grid;
  68910. /**
  68911. * Adds a new control to the current grid
  68912. * @param control defines the control to add
  68913. * @param row defines the row where to add the control (0 by default)
  68914. * @param column defines the column where to add the control (0 by default)
  68915. * @returns the current grid
  68916. */
  68917. addControl(control: Control, row?: number, column?: number): Grid;
  68918. /**
  68919. * Removes a control from the current container
  68920. * @param control defines the control to remove
  68921. * @returns the current container
  68922. */
  68923. removeControl(control: Control): Container;
  68924. /**
  68925. * Creates a new Grid
  68926. * @param name defines control name
  68927. */
  68928. constructor(name?: string | undefined);
  68929. protected _getTypeName(): string;
  68930. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  68931. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68932. _flagDescendantsAsMatrixDirty(): void;
  68933. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  68934. /** Releases associated resources */
  68935. dispose(): void;
  68936. }
  68937. }
  68938. declare module BABYLON.GUI {
  68939. /** Class used to create color pickers */
  68940. export class ColorPicker extends Control {
  68941. name?: string | undefined;
  68942. private static _Epsilon;
  68943. private _colorWheelCanvas;
  68944. private _value;
  68945. private _tmpColor;
  68946. private _pointerStartedOnSquare;
  68947. private _pointerStartedOnWheel;
  68948. private _squareLeft;
  68949. private _squareTop;
  68950. private _squareSize;
  68951. private _h;
  68952. private _s;
  68953. private _v;
  68954. private _lastPointerDownID;
  68955. /**
  68956. * BABYLON.Observable raised when the value changes
  68957. */
  68958. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  68959. /** Gets or sets the color of the color picker */
  68960. value: BABYLON.Color3;
  68961. /**
  68962. * Gets or sets control width
  68963. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68964. */
  68965. width: string | number;
  68966. /**
  68967. * Gets or sets control height
  68968. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  68969. */
  68970. /** Gets or sets control height */
  68971. height: string | number;
  68972. /** Gets or sets control size */
  68973. size: string | number;
  68974. /**
  68975. * Creates a new ColorPicker
  68976. * @param name defines the control name
  68977. */
  68978. constructor(name?: string | undefined);
  68979. protected _getTypeName(): string;
  68980. /** @hidden */
  68981. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  68982. private _updateSquareProps;
  68983. private _drawGradientSquare;
  68984. private _drawCircle;
  68985. private _createColorWheelCanvas;
  68986. /** @hidden */
  68987. _draw(context: CanvasRenderingContext2D): void;
  68988. private _pointerIsDown;
  68989. private _updateValueFromPointer;
  68990. private _isPointOnSquare;
  68991. private _isPointOnWheel;
  68992. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  68993. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  68994. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68995. /**
  68996. * This function expands the color picker by creating a color picker dialog with manual
  68997. * color value input and the ability to save colors into an array to be used later in
  68998. * subsequent launches of the dialogue.
  68999. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  69000. * @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.
  69001. * @returns picked color as a hex string and the saved colors array as hex strings.
  69002. */
  69003. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  69004. pickerWidth?: string;
  69005. pickerHeight?: string;
  69006. headerHeight?: string;
  69007. lastColor?: string;
  69008. swatchLimit?: number;
  69009. numSwatchesPerLine?: number;
  69010. savedColors?: Array<string>;
  69011. }): Promise<{
  69012. savedColors?: string[];
  69013. pickedColor: string;
  69014. }>;
  69015. }
  69016. }
  69017. declare module BABYLON.GUI {
  69018. /** Class used to create 2D ellipse containers */
  69019. export class Ellipse extends Container {
  69020. name?: string | undefined;
  69021. private _thickness;
  69022. /** Gets or sets border thickness */
  69023. thickness: number;
  69024. /**
  69025. * Creates a new Ellipse
  69026. * @param name defines the control name
  69027. */
  69028. constructor(name?: string | undefined);
  69029. protected _getTypeName(): string;
  69030. protected _localDraw(context: CanvasRenderingContext2D): void;
  69031. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69032. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  69033. }
  69034. }
  69035. declare module BABYLON.GUI {
  69036. /**
  69037. * Class used to create a password control
  69038. */
  69039. export class InputPassword extends InputText {
  69040. protected _beforeRenderText(text: string): string;
  69041. }
  69042. }
  69043. declare module BABYLON.GUI {
  69044. /** Class used to render 2D lines */
  69045. export class Line extends Control {
  69046. name?: string | undefined;
  69047. private _lineWidth;
  69048. private _x1;
  69049. private _y1;
  69050. private _x2;
  69051. private _y2;
  69052. private _dash;
  69053. private _connectedControl;
  69054. private _connectedControlDirtyObserver;
  69055. /** Gets or sets the dash pattern */
  69056. dash: Array<number>;
  69057. /** Gets or sets the control connected with the line end */
  69058. connectedControl: Control;
  69059. /** Gets or sets start coordinates on X axis */
  69060. x1: string | number;
  69061. /** Gets or sets start coordinates on Y axis */
  69062. y1: string | number;
  69063. /** Gets or sets end coordinates on X axis */
  69064. x2: string | number;
  69065. /** Gets or sets end coordinates on Y axis */
  69066. y2: string | number;
  69067. /** Gets or sets line width */
  69068. lineWidth: number;
  69069. /** Gets or sets horizontal alignment */
  69070. horizontalAlignment: number;
  69071. /** Gets or sets vertical alignment */
  69072. verticalAlignment: number;
  69073. private readonly _effectiveX2;
  69074. private readonly _effectiveY2;
  69075. /**
  69076. * Creates a new Line
  69077. * @param name defines the control name
  69078. */
  69079. constructor(name?: string | undefined);
  69080. protected _getTypeName(): string;
  69081. _draw(context: CanvasRenderingContext2D): void;
  69082. _measure(): void;
  69083. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69084. /**
  69085. * Move one end of the line given 3D cartesian coordinates.
  69086. * @param position Targeted world position
  69087. * @param scene BABYLON.Scene
  69088. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69089. */
  69090. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  69091. /**
  69092. * Move one end of the line to a position in screen absolute space.
  69093. * @param projectedPosition Position in screen absolute space (X, Y)
  69094. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  69095. */
  69096. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  69097. }
  69098. }
  69099. declare module BABYLON.GUI {
  69100. /**
  69101. * Class used to store a point for a MultiLine object.
  69102. * The point can be pure 2D coordinates, a mesh or a control
  69103. */
  69104. export class MultiLinePoint {
  69105. private _multiLine;
  69106. private _x;
  69107. private _y;
  69108. private _control;
  69109. private _mesh;
  69110. private _controlObserver;
  69111. private _meshObserver;
  69112. /** @hidden */
  69113. _point: BABYLON.Vector2;
  69114. /**
  69115. * Creates a new MultiLinePoint
  69116. * @param multiLine defines the source MultiLine object
  69117. */
  69118. constructor(multiLine: MultiLine);
  69119. /** Gets or sets x coordinate */
  69120. x: string | number;
  69121. /** Gets or sets y coordinate */
  69122. y: string | number;
  69123. /** Gets or sets the control associated with this point */
  69124. control: BABYLON.Nullable<Control>;
  69125. /** Gets or sets the mesh associated with this point */
  69126. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  69127. /** Resets links */
  69128. resetLinks(): void;
  69129. /**
  69130. * Gets a translation vector
  69131. * @returns the translation vector
  69132. */
  69133. translate(): BABYLON.Vector2;
  69134. private _translatePoint;
  69135. /** Release associated resources */
  69136. dispose(): void;
  69137. }
  69138. }
  69139. declare module BABYLON.GUI {
  69140. /**
  69141. * Class used to create multi line control
  69142. */
  69143. export class MultiLine extends Control {
  69144. name?: string | undefined;
  69145. private _lineWidth;
  69146. private _dash;
  69147. private _points;
  69148. private _minX;
  69149. private _minY;
  69150. private _maxX;
  69151. private _maxY;
  69152. /**
  69153. * Creates a new MultiLine
  69154. * @param name defines the control name
  69155. */
  69156. constructor(name?: string | undefined);
  69157. /** Gets or sets dash pattern */
  69158. dash: Array<number>;
  69159. /**
  69160. * Gets point stored at specified index
  69161. * @param index defines the index to look for
  69162. * @returns the requested point if found
  69163. */
  69164. getAt(index: number): MultiLinePoint;
  69165. /** Function called when a point is updated */
  69166. onPointUpdate: () => void;
  69167. /**
  69168. * Adds new points to the point collection
  69169. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  69170. * @returns the list of created MultiLinePoint
  69171. */
  69172. add(...items: (AbstractMesh | Control | {
  69173. x: string | number;
  69174. y: string | number;
  69175. })[]): MultiLinePoint[];
  69176. /**
  69177. * Adds a new point to the point collection
  69178. * @param item defines the item (mesh, control or 2d coordiantes) to add
  69179. * @returns the created MultiLinePoint
  69180. */
  69181. push(item?: (AbstractMesh | Control | {
  69182. x: string | number;
  69183. y: string | number;
  69184. })): MultiLinePoint;
  69185. /**
  69186. * Remove a specific value or point from the active point collection
  69187. * @param value defines the value or point to remove
  69188. */
  69189. remove(value: number | MultiLinePoint): void;
  69190. /**
  69191. * Resets this object to initial state (no point)
  69192. */
  69193. reset(): void;
  69194. /**
  69195. * Resets all links
  69196. */
  69197. resetLinks(): void;
  69198. /** Gets or sets line width */
  69199. lineWidth: number;
  69200. horizontalAlignment: number;
  69201. verticalAlignment: number;
  69202. protected _getTypeName(): string;
  69203. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69204. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69205. _measure(): void;
  69206. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69207. dispose(): void;
  69208. }
  69209. }
  69210. declare module BABYLON.GUI {
  69211. /**
  69212. * Class used to create radio button controls
  69213. */
  69214. export class RadioButton extends Control {
  69215. name?: string | undefined;
  69216. private _isChecked;
  69217. private _background;
  69218. private _checkSizeRatio;
  69219. private _thickness;
  69220. /** Gets or sets border thickness */
  69221. thickness: number;
  69222. /** Gets or sets group name */
  69223. group: string;
  69224. /** BABYLON.Observable raised when isChecked is changed */
  69225. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  69226. /** Gets or sets a value indicating the ratio between overall size and check size */
  69227. checkSizeRatio: number;
  69228. /** Gets or sets background color */
  69229. background: string;
  69230. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  69231. isChecked: boolean;
  69232. /**
  69233. * Creates a new RadioButton
  69234. * @param name defines the control name
  69235. */
  69236. constructor(name?: string | undefined);
  69237. protected _getTypeName(): string;
  69238. _draw(context: CanvasRenderingContext2D): void;
  69239. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69240. /**
  69241. * Utility function to easily create a radio button with a header
  69242. * @param title defines the label to use for the header
  69243. * @param group defines the group to use for the radio button
  69244. * @param isChecked defines the initial state of the radio button
  69245. * @param onValueChanged defines the callback to call when value changes
  69246. * @returns a StackPanel containing the radio button and a textBlock
  69247. */
  69248. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  69249. }
  69250. }
  69251. declare module BABYLON.GUI {
  69252. /**
  69253. * Class used to create slider controls
  69254. */
  69255. export class BaseSlider extends Control {
  69256. name?: string | undefined;
  69257. protected _thumbWidth: ValueAndUnit;
  69258. private _minimum;
  69259. private _maximum;
  69260. private _value;
  69261. private _isVertical;
  69262. protected _barOffset: ValueAndUnit;
  69263. private _isThumbClamped;
  69264. protected _displayThumb: boolean;
  69265. private _step;
  69266. private _lastPointerDownID;
  69267. protected _effectiveBarOffset: number;
  69268. protected _renderLeft: number;
  69269. protected _renderTop: number;
  69270. protected _renderWidth: number;
  69271. protected _renderHeight: number;
  69272. protected _backgroundBoxLength: number;
  69273. protected _backgroundBoxThickness: number;
  69274. protected _effectiveThumbThickness: number;
  69275. /** BABYLON.Observable raised when the sldier value changes */
  69276. onValueChangedObservable: BABYLON.Observable<number>;
  69277. /** Gets or sets a boolean indicating if the thumb must be rendered */
  69278. displayThumb: boolean;
  69279. /** Gets or sets a step to apply to values (0 by default) */
  69280. step: number;
  69281. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  69282. barOffset: string | number;
  69283. /** Gets main bar offset in pixels*/
  69284. readonly barOffsetInPixels: number;
  69285. /** Gets or sets thumb width */
  69286. thumbWidth: string | number;
  69287. /** Gets thumb width in pixels */
  69288. readonly thumbWidthInPixels: number;
  69289. /** Gets or sets minimum value */
  69290. minimum: number;
  69291. /** Gets or sets maximum value */
  69292. maximum: number;
  69293. /** Gets or sets current value */
  69294. value: number;
  69295. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  69296. isVertical: boolean;
  69297. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  69298. isThumbClamped: boolean;
  69299. /**
  69300. * Creates a new BaseSlider
  69301. * @param name defines the control name
  69302. */
  69303. constructor(name?: string | undefined);
  69304. protected _getTypeName(): string;
  69305. protected _getThumbPosition(): number;
  69306. protected _getThumbThickness(type: string): number;
  69307. protected _prepareRenderingData(type: string): void;
  69308. private _pointerIsDown;
  69309. /** @hidden */
  69310. protected _updateValueFromPointer(x: number, y: number): void;
  69311. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69312. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  69313. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  69314. }
  69315. }
  69316. declare module BABYLON.GUI {
  69317. /**
  69318. * Class used to create slider controls
  69319. */
  69320. export class Slider extends BaseSlider {
  69321. name?: string | undefined;
  69322. private _background;
  69323. private _borderColor;
  69324. private _isThumbCircle;
  69325. protected _displayValueBar: boolean;
  69326. /** Gets or sets a boolean indicating if the value bar must be rendered */
  69327. displayValueBar: boolean;
  69328. /** Gets or sets border color */
  69329. borderColor: string;
  69330. /** Gets or sets background color */
  69331. background: string;
  69332. /** Gets or sets a boolean indicating if the thumb should be round or square */
  69333. isThumbCircle: boolean;
  69334. /**
  69335. * Creates a new Slider
  69336. * @param name defines the control name
  69337. */
  69338. constructor(name?: string | undefined);
  69339. protected _getTypeName(): string;
  69340. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69341. }
  69342. }
  69343. declare module BABYLON.GUI {
  69344. /** Class used to create a RadioGroup
  69345. * which contains groups of radio buttons
  69346. */
  69347. export class SelectorGroup {
  69348. /** name of SelectorGroup */
  69349. name: string;
  69350. private _groupPanel;
  69351. private _selectors;
  69352. private _groupHeader;
  69353. /**
  69354. * Creates a new SelectorGroup
  69355. * @param name of group, used as a group heading
  69356. */
  69357. constructor(
  69358. /** name of SelectorGroup */
  69359. name: string);
  69360. /** Gets the groupPanel of the SelectorGroup */
  69361. readonly groupPanel: StackPanel;
  69362. /** Gets the selectors array */
  69363. readonly selectors: StackPanel[];
  69364. /** Gets and sets the group header */
  69365. header: string;
  69366. /** @hidden */
  69367. private _addGroupHeader;
  69368. /** @hidden*/
  69369. _getSelector(selectorNb: number): StackPanel | undefined;
  69370. /** Removes the selector at the given position
  69371. * @param selectorNb the position of the selector within the group
  69372. */
  69373. removeSelector(selectorNb: number): void;
  69374. }
  69375. /** Class used to create a CheckboxGroup
  69376. * which contains groups of checkbox buttons
  69377. */
  69378. export class CheckboxGroup extends SelectorGroup {
  69379. /** Adds a checkbox as a control
  69380. * @param text is the label for the selector
  69381. * @param func is the function called when the Selector is checked
  69382. * @param checked is true when Selector is checked
  69383. */
  69384. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  69385. /** @hidden */
  69386. _setSelectorLabel(selectorNb: number, label: string): void;
  69387. /** @hidden */
  69388. _setSelectorLabelColor(selectorNb: number, color: string): void;
  69389. /** @hidden */
  69390. _setSelectorButtonColor(selectorNb: number, color: string): void;
  69391. /** @hidden */
  69392. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  69393. }
  69394. /** Class used to create a RadioGroup
  69395. * which contains groups of radio buttons
  69396. */
  69397. export class RadioGroup extends SelectorGroup {
  69398. private _selectNb;
  69399. /** Adds a radio button as a control
  69400. * @param label is the label for the selector
  69401. * @param func is the function called when the Selector is checked
  69402. * @param checked is true when Selector is checked
  69403. */
  69404. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  69405. /** @hidden */
  69406. _setSelectorLabel(selectorNb: number, label: string): void;
  69407. /** @hidden */
  69408. _setSelectorLabelColor(selectorNb: number, color: string): void;
  69409. /** @hidden */
  69410. _setSelectorButtonColor(selectorNb: number, color: string): void;
  69411. /** @hidden */
  69412. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  69413. }
  69414. /** Class used to create a SliderGroup
  69415. * which contains groups of slider buttons
  69416. */
  69417. export class SliderGroup extends SelectorGroup {
  69418. /**
  69419. * Adds a slider to the SelectorGroup
  69420. * @param label is the label for the SliderBar
  69421. * @param func is the function called when the Slider moves
  69422. * @param unit is a string describing the units used, eg degrees or metres
  69423. * @param min is the minimum value for the Slider
  69424. * @param max is the maximum value for the Slider
  69425. * @param value is the start value for the Slider between min and max
  69426. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  69427. */
  69428. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  69429. /** @hidden */
  69430. _setSelectorLabel(selectorNb: number, label: string): void;
  69431. /** @hidden */
  69432. _setSelectorLabelColor(selectorNb: number, color: string): void;
  69433. /** @hidden */
  69434. _setSelectorButtonColor(selectorNb: number, color: string): void;
  69435. /** @hidden */
  69436. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  69437. }
  69438. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  69439. * @see http://doc.babylonjs.com/how_to/selector
  69440. */
  69441. export class SelectionPanel extends Rectangle {
  69442. /** name of SelectionPanel */
  69443. name: string;
  69444. /** an array of SelectionGroups */
  69445. groups: SelectorGroup[];
  69446. private _panel;
  69447. private _buttonColor;
  69448. private _buttonBackground;
  69449. private _headerColor;
  69450. private _barColor;
  69451. private _barHeight;
  69452. private _spacerHeight;
  69453. private _labelColor;
  69454. private _groups;
  69455. private _bars;
  69456. /**
  69457. * Creates a new SelectionPanel
  69458. * @param name of SelectionPanel
  69459. * @param groups is an array of SelectionGroups
  69460. */
  69461. constructor(
  69462. /** name of SelectionPanel */
  69463. name: string,
  69464. /** an array of SelectionGroups */
  69465. groups?: SelectorGroup[]);
  69466. protected _getTypeName(): string;
  69467. /** Gets or sets the headerColor */
  69468. headerColor: string;
  69469. private _setHeaderColor;
  69470. /** Gets or sets the button color */
  69471. buttonColor: string;
  69472. private _setbuttonColor;
  69473. /** Gets or sets the label color */
  69474. labelColor: string;
  69475. private _setLabelColor;
  69476. /** Gets or sets the button background */
  69477. buttonBackground: string;
  69478. private _setButtonBackground;
  69479. /** Gets or sets the color of separator bar */
  69480. barColor: string;
  69481. private _setBarColor;
  69482. /** Gets or sets the height of separator bar */
  69483. barHeight: string;
  69484. private _setBarHeight;
  69485. /** Gets or sets the height of spacers*/
  69486. spacerHeight: string;
  69487. private _setSpacerHeight;
  69488. /** Adds a bar between groups */
  69489. private _addSpacer;
  69490. /** Add a group to the selection panel
  69491. * @param group is the selector group to add
  69492. */
  69493. addGroup(group: SelectorGroup): void;
  69494. /** Remove the group from the given position
  69495. * @param groupNb is the position of the group in the list
  69496. */
  69497. removeGroup(groupNb: number): void;
  69498. /** Change a group header label
  69499. * @param label is the new group header label
  69500. * @param groupNb is the number of the group to relabel
  69501. * */
  69502. setHeaderName(label: string, groupNb: number): void;
  69503. /** Change selector label to the one given
  69504. * @param label is the new selector label
  69505. * @param groupNb is the number of the groupcontaining the selector
  69506. * @param selectorNb is the number of the selector within a group to relabel
  69507. * */
  69508. relabel(label: string, groupNb: number, selectorNb: number): void;
  69509. /** For a given group position remove the selector at the given position
  69510. * @param groupNb is the number of the group to remove the selector from
  69511. * @param selectorNb is the number of the selector within the group
  69512. */
  69513. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  69514. /** For a given group position of correct type add a checkbox button
  69515. * @param groupNb is the number of the group to remove the selector from
  69516. * @param label is the label for the selector
  69517. * @param func is the function called when the Selector is checked
  69518. * @param checked is true when Selector is checked
  69519. */
  69520. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  69521. /** For a given group position of correct type add a radio button
  69522. * @param groupNb is the number of the group to remove the selector from
  69523. * @param label is the label for the selector
  69524. * @param func is the function called when the Selector is checked
  69525. * @param checked is true when Selector is checked
  69526. */
  69527. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  69528. /**
  69529. * For a given slider group add a slider
  69530. * @param groupNb is the number of the group to add the slider to
  69531. * @param label is the label for the Slider
  69532. * @param func is the function called when the Slider moves
  69533. * @param unit is a string describing the units used, eg degrees or metres
  69534. * @param min is the minimum value for the Slider
  69535. * @param max is the maximum value for the Slider
  69536. * @param value is the start value for the Slider between min and max
  69537. * @param onVal is the function used to format the value displayed, eg radians to degrees
  69538. */
  69539. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  69540. }
  69541. }
  69542. declare module BABYLON.GUI {
  69543. /**
  69544. * Class used to hold a the container for ScrollViewer
  69545. * @hidden
  69546. */
  69547. export class _ScrollViewerWindow extends Container {
  69548. parentClientWidth: number;
  69549. parentClientHeight: number;
  69550. /**
  69551. * Creates a new ScrollViewerWindow
  69552. * @param name of ScrollViewerWindow
  69553. */
  69554. constructor(name?: string);
  69555. protected _getTypeName(): string;
  69556. /** @hidden */
  69557. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69558. protected _postMeasure(): void;
  69559. }
  69560. }
  69561. declare module BABYLON.GUI {
  69562. /**
  69563. * Class used to create slider controls
  69564. */
  69565. export class ScrollBar extends BaseSlider {
  69566. name?: string | undefined;
  69567. private _background;
  69568. private _borderColor;
  69569. private _tempMeasure;
  69570. /** Gets or sets border color */
  69571. borderColor: string;
  69572. /** Gets or sets background color */
  69573. background: string;
  69574. /**
  69575. * Creates a new Slider
  69576. * @param name defines the control name
  69577. */
  69578. constructor(name?: string | undefined);
  69579. protected _getTypeName(): string;
  69580. protected _getThumbThickness(): number;
  69581. _draw(context: CanvasRenderingContext2D): void;
  69582. private _first;
  69583. private _originX;
  69584. private _originY;
  69585. /** @hidden */
  69586. protected _updateValueFromPointer(x: number, y: number): void;
  69587. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69588. }
  69589. }
  69590. declare module BABYLON.GUI {
  69591. /**
  69592. * Class used to create slider controls
  69593. */
  69594. export class ImageScrollBar extends BaseSlider {
  69595. name?: string | undefined;
  69596. private _backgroundBaseImage;
  69597. private _backgroundImage;
  69598. private _thumbImage;
  69599. private _thumbBaseImage;
  69600. private _thumbLength;
  69601. private _thumbHeight;
  69602. private _barImageHeight;
  69603. private _tempMeasure;
  69604. /**
  69605. * Gets or sets the image used to render the background for horizontal bar
  69606. */
  69607. backgroundImage: Image;
  69608. /**
  69609. * Gets or sets the image used to render the thumb
  69610. */
  69611. thumbImage: Image;
  69612. /**
  69613. * Gets or sets the length of the thumb
  69614. */
  69615. thumbLength: number;
  69616. /**
  69617. * Gets or sets the height of the thumb
  69618. */
  69619. thumbHeight: number;
  69620. /**
  69621. * Gets or sets the height of the bar image
  69622. */
  69623. barImageHeight: number;
  69624. /**
  69625. * Creates a new ImageScrollBar
  69626. * @param name defines the control name
  69627. */
  69628. constructor(name?: string | undefined);
  69629. protected _getTypeName(): string;
  69630. protected _getThumbThickness(): number;
  69631. _draw(context: CanvasRenderingContext2D): void;
  69632. private _first;
  69633. private _originX;
  69634. private _originY;
  69635. /** @hidden */
  69636. protected _updateValueFromPointer(x: number, y: number): void;
  69637. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  69638. }
  69639. }
  69640. declare module BABYLON.GUI {
  69641. /**
  69642. * Class used to hold a viewer window and sliders in a grid
  69643. */
  69644. export class ScrollViewer extends Rectangle {
  69645. private _grid;
  69646. private _horizontalBarSpace;
  69647. private _verticalBarSpace;
  69648. private _dragSpace;
  69649. private _horizontalBar;
  69650. private _verticalBar;
  69651. private _barColor;
  69652. private _barBackground;
  69653. private _barImage;
  69654. private _barBackgroundImage;
  69655. private _barSize;
  69656. private _endLeft;
  69657. private _endTop;
  69658. private _window;
  69659. private _pointerIsOver;
  69660. private _wheelPrecision;
  69661. private _onPointerObserver;
  69662. private _clientWidth;
  69663. private _clientHeight;
  69664. private _useImageBar;
  69665. private _thumbLength;
  69666. private _thumbHeight;
  69667. private _barImageHeight;
  69668. /**
  69669. * Gets the horizontal scrollbar
  69670. */
  69671. readonly horizontalBar: ScrollBar | ImageScrollBar;
  69672. /**
  69673. * Gets the vertical scrollbar
  69674. */
  69675. readonly verticalBar: ScrollBar | ImageScrollBar;
  69676. /**
  69677. * Adds a new control to the current container
  69678. * @param control defines the control to add
  69679. * @returns the current container
  69680. */
  69681. addControl(control: BABYLON.Nullable<Control>): Container;
  69682. /**
  69683. * Removes a control from the current container
  69684. * @param control defines the control to remove
  69685. * @returns the current container
  69686. */
  69687. removeControl(control: Control): Container;
  69688. /** Gets the list of children */
  69689. readonly children: Control[];
  69690. _flagDescendantsAsMatrixDirty(): void;
  69691. /**
  69692. * Creates a new ScrollViewer
  69693. * @param name of ScrollViewer
  69694. */
  69695. constructor(name?: string, isImageBased?: boolean);
  69696. /** Reset the scroll viewer window to initial size */
  69697. resetWindow(): void;
  69698. protected _getTypeName(): string;
  69699. private _buildClientSizes;
  69700. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  69701. protected _postMeasure(): void;
  69702. /**
  69703. * Gets or sets the mouse wheel precision
  69704. * from 0 to 1 with a default value of 0.05
  69705. * */
  69706. wheelPrecision: number;
  69707. /** Gets or sets the scroll bar container background color */
  69708. scrollBackground: string;
  69709. /** Gets or sets the bar color */
  69710. barColor: string;
  69711. /** Gets or sets the bar image */
  69712. thumbImage: Image;
  69713. /** Gets or sets the size of the bar */
  69714. barSize: number;
  69715. /** Gets or sets the length of the thumb */
  69716. thumbLength: number;
  69717. /** Gets or sets the height of the thumb */
  69718. thumbHeight: number;
  69719. /** Gets or sets the height of the bar image */
  69720. barImageHeight: number;
  69721. /** Gets or sets the bar background */
  69722. barBackground: string;
  69723. /** Gets or sets the bar background image */
  69724. barImage: Image;
  69725. /** @hidden */
  69726. private _updateScroller;
  69727. _link(host: AdvancedDynamicTexture): void;
  69728. /** @hidden */
  69729. private _addBar;
  69730. /** @hidden */
  69731. private _attachWheel;
  69732. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  69733. /** Releases associated resources */
  69734. dispose(): void;
  69735. }
  69736. }
  69737. declare module BABYLON.GUI {
  69738. /** Class used to render a grid */
  69739. export class DisplayGrid extends Control {
  69740. name?: string | undefined;
  69741. private _cellWidth;
  69742. private _cellHeight;
  69743. private _minorLineTickness;
  69744. private _minorLineColor;
  69745. private _majorLineTickness;
  69746. private _majorLineColor;
  69747. private _majorLineFrequency;
  69748. private _background;
  69749. private _displayMajorLines;
  69750. private _displayMinorLines;
  69751. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  69752. displayMinorLines: boolean;
  69753. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  69754. displayMajorLines: boolean;
  69755. /** Gets or sets background color (Black by default) */
  69756. background: string;
  69757. /** Gets or sets the width of each cell (20 by default) */
  69758. cellWidth: number;
  69759. /** Gets or sets the height of each cell (20 by default) */
  69760. cellHeight: number;
  69761. /** Gets or sets the tickness of minor lines (1 by default) */
  69762. minorLineTickness: number;
  69763. /** Gets or sets the color of minor lines (DarkGray by default) */
  69764. minorLineColor: string;
  69765. /** Gets or sets the tickness of major lines (2 by default) */
  69766. majorLineTickness: number;
  69767. /** Gets or sets the color of major lines (White by default) */
  69768. majorLineColor: string;
  69769. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  69770. majorLineFrequency: number;
  69771. /**
  69772. * Creates a new GridDisplayRectangle
  69773. * @param name defines the control name
  69774. */
  69775. constructor(name?: string | undefined);
  69776. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69777. protected _getTypeName(): string;
  69778. }
  69779. }
  69780. declare module BABYLON.GUI {
  69781. /**
  69782. * Class used to create slider controls based on images
  69783. */
  69784. export class ImageBasedSlider extends BaseSlider {
  69785. name?: string | undefined;
  69786. private _backgroundImage;
  69787. private _thumbImage;
  69788. private _valueBarImage;
  69789. private _tempMeasure;
  69790. displayThumb: boolean;
  69791. /**
  69792. * Gets or sets the image used to render the background
  69793. */
  69794. backgroundImage: Image;
  69795. /**
  69796. * Gets or sets the image used to render the value bar
  69797. */
  69798. valueBarImage: Image;
  69799. /**
  69800. * Gets or sets the image used to render the thumb
  69801. */
  69802. thumbImage: Image;
  69803. /**
  69804. * Creates a new ImageBasedSlider
  69805. * @param name defines the control name
  69806. */
  69807. constructor(name?: string | undefined);
  69808. protected _getTypeName(): string;
  69809. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  69810. }
  69811. }
  69812. declare module BABYLON.GUI {
  69813. /**
  69814. * Forcing an export so that this code will execute
  69815. * @hidden
  69816. */
  69817. const name = "Statics";
  69818. }
  69819. declare module BABYLON.GUI {
  69820. /**
  69821. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  69822. */
  69823. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  69824. /**
  69825. * Define the instrumented AdvancedDynamicTexture.
  69826. */
  69827. texture: AdvancedDynamicTexture;
  69828. private _captureRenderTime;
  69829. private _renderTime;
  69830. private _captureLayoutTime;
  69831. private _layoutTime;
  69832. private _onBeginRenderObserver;
  69833. private _onEndRenderObserver;
  69834. private _onBeginLayoutObserver;
  69835. private _onEndLayoutObserver;
  69836. /**
  69837. * Gets the perf counter used to capture render time
  69838. */
  69839. readonly renderTimeCounter: BABYLON.PerfCounter;
  69840. /**
  69841. * Gets the perf counter used to capture layout time
  69842. */
  69843. readonly layoutTimeCounter: BABYLON.PerfCounter;
  69844. /**
  69845. * Enable or disable the render time capture
  69846. */
  69847. captureRenderTime: boolean;
  69848. /**
  69849. * Enable or disable the layout time capture
  69850. */
  69851. captureLayoutTime: boolean;
  69852. /**
  69853. * Instantiates a new advanced dynamic texture instrumentation.
  69854. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  69855. * @param texture Defines the AdvancedDynamicTexture to instrument
  69856. */
  69857. constructor(
  69858. /**
  69859. * Define the instrumented AdvancedDynamicTexture.
  69860. */
  69861. texture: AdvancedDynamicTexture);
  69862. /**
  69863. * Dispose and release associated resources.
  69864. */
  69865. dispose(): void;
  69866. }
  69867. }
  69868. declare module BABYLON.GUI {
  69869. /**
  69870. * Class used to load GUI via XML.
  69871. */
  69872. export class XmlLoader {
  69873. private _nodes;
  69874. private _nodeTypes;
  69875. private _isLoaded;
  69876. private _objectAttributes;
  69877. private _parentClass;
  69878. /**
  69879. * Create a new xml loader
  69880. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  69881. */
  69882. constructor(parentClass?: null);
  69883. private _getChainElement;
  69884. private _getClassAttribute;
  69885. private _createGuiElement;
  69886. private _parseGrid;
  69887. private _parseElement;
  69888. private _prepareSourceElement;
  69889. private _parseElementsFromSource;
  69890. private _parseXml;
  69891. /**
  69892. * Gets if the loading has finished.
  69893. * @returns whether the loading has finished or not
  69894. */
  69895. isLoaded(): boolean;
  69896. /**
  69897. * Gets a loaded node / control by id.
  69898. * @param id the Controls id set in the xml
  69899. * @returns element of type Control
  69900. */
  69901. getNodeById(id: string): any;
  69902. /**
  69903. * Gets all loaded nodes / controls
  69904. * @returns Array of controls
  69905. */
  69906. getNodes(): any;
  69907. /**
  69908. * Initiates the xml layout loading
  69909. * @param xmlFile defines the xml layout to load
  69910. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  69911. * @param callback defines the callback called on layout load.
  69912. */
  69913. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  69914. }
  69915. }
  69916. declare module BABYLON.GUI {
  69917. /**
  69918. * Class used to create containers for controls
  69919. */
  69920. export class Container3D extends Control3D {
  69921. private _blockLayout;
  69922. /**
  69923. * Gets the list of child controls
  69924. */
  69925. protected _children: Control3D[];
  69926. /**
  69927. * Gets the list of child controls
  69928. */
  69929. readonly children: Array<Control3D>;
  69930. /**
  69931. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  69932. * This is helpful to optimize layout operation when adding multiple children in a row
  69933. */
  69934. blockLayout: boolean;
  69935. /**
  69936. * Creates a new container
  69937. * @param name defines the container name
  69938. */
  69939. constructor(name?: string);
  69940. /**
  69941. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  69942. * @returns the current container
  69943. */
  69944. updateLayout(): Container3D;
  69945. /**
  69946. * Gets a boolean indicating if the given control is in the children of this control
  69947. * @param control defines the control to check
  69948. * @returns true if the control is in the child list
  69949. */
  69950. containsControl(control: Control3D): boolean;
  69951. /**
  69952. * Adds a control to the children of this control
  69953. * @param control defines the control to add
  69954. * @returns the current container
  69955. */
  69956. addControl(control: Control3D): Container3D;
  69957. /**
  69958. * This function will be called everytime a new control is added
  69959. */
  69960. protected _arrangeChildren(): void;
  69961. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  69962. /**
  69963. * Removes a control from the children of this control
  69964. * @param control defines the control to remove
  69965. * @returns the current container
  69966. */
  69967. removeControl(control: Control3D): Container3D;
  69968. protected _getTypeName(): string;
  69969. /**
  69970. * Releases all associated resources
  69971. */
  69972. dispose(): void;
  69973. /** Control rotation will remain unchanged */
  69974. static readonly UNSET_ORIENTATION: number;
  69975. /** Control will rotate to make it look at sphere central axis */
  69976. static readonly FACEORIGIN_ORIENTATION: number;
  69977. /** Control will rotate to make it look back at sphere central axis */
  69978. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  69979. /** Control will rotate to look at z axis (0, 0, 1) */
  69980. static readonly FACEFORWARD_ORIENTATION: number;
  69981. /** Control will rotate to look at negative z axis (0, 0, -1) */
  69982. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  69983. }
  69984. }
  69985. declare module BABYLON.GUI {
  69986. /**
  69987. * Class used to manage 3D user interface
  69988. * @see http://doc.babylonjs.com/how_to/gui3d
  69989. */
  69990. export class GUI3DManager implements BABYLON.IDisposable {
  69991. private _scene;
  69992. private _sceneDisposeObserver;
  69993. private _utilityLayer;
  69994. private _rootContainer;
  69995. private _pointerObserver;
  69996. private _pointerOutObserver;
  69997. /** @hidden */
  69998. _lastPickedControl: Control3D;
  69999. /** @hidden */
  70000. _lastControlOver: {
  70001. [pointerId: number]: Control3D;
  70002. };
  70003. /** @hidden */
  70004. _lastControlDown: {
  70005. [pointerId: number]: Control3D;
  70006. };
  70007. /**
  70008. * BABYLON.Observable raised when the point picked by the pointer events changed
  70009. */
  70010. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  70011. /** @hidden */
  70012. _sharedMaterials: {
  70013. [key: string]: BABYLON.Material;
  70014. };
  70015. /** Gets the hosting scene */
  70016. readonly scene: BABYLON.Scene;
  70017. /** Gets associated utility layer */
  70018. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  70019. /**
  70020. * Creates a new GUI3DManager
  70021. * @param scene
  70022. */
  70023. constructor(scene?: BABYLON.Scene);
  70024. private _handlePointerOut;
  70025. private _doPicking;
  70026. /**
  70027. * Gets the root container
  70028. */
  70029. readonly rootContainer: Container3D;
  70030. /**
  70031. * Gets a boolean indicating if the given control is in the root child list
  70032. * @param control defines the control to check
  70033. * @returns true if the control is in the root child list
  70034. */
  70035. containsControl(control: Control3D): boolean;
  70036. /**
  70037. * Adds a control to the root child list
  70038. * @param control defines the control to add
  70039. * @returns the current manager
  70040. */
  70041. addControl(control: Control3D): GUI3DManager;
  70042. /**
  70043. * Removes a control from the root child list
  70044. * @param control defines the control to remove
  70045. * @returns the current container
  70046. */
  70047. removeControl(control: Control3D): GUI3DManager;
  70048. /**
  70049. * Releases all associated resources
  70050. */
  70051. dispose(): void;
  70052. }
  70053. }
  70054. declare module BABYLON.GUI {
  70055. /**
  70056. * Class used to transport BABYLON.Vector3 information for pointer events
  70057. */
  70058. export class Vector3WithInfo extends BABYLON.Vector3 {
  70059. /** defines the current mouse button index */
  70060. buttonIndex: number;
  70061. /**
  70062. * Creates a new Vector3WithInfo
  70063. * @param source defines the vector3 data to transport
  70064. * @param buttonIndex defines the current mouse button index
  70065. */
  70066. constructor(source: BABYLON.Vector3,
  70067. /** defines the current mouse button index */
  70068. buttonIndex?: number);
  70069. }
  70070. }
  70071. declare module BABYLON.GUI {
  70072. /**
  70073. * Class used as base class for controls
  70074. */
  70075. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  70076. /** Defines the control name */
  70077. name?: string | undefined;
  70078. /** @hidden */
  70079. _host: GUI3DManager;
  70080. private _node;
  70081. private _downCount;
  70082. private _enterCount;
  70083. private _downPointerIds;
  70084. private _isVisible;
  70085. /** Gets or sets the control position in world space */
  70086. position: BABYLON.Vector3;
  70087. /** Gets or sets the control scaling in world space */
  70088. scaling: BABYLON.Vector3;
  70089. /** Callback used to start pointer enter animation */
  70090. pointerEnterAnimation: () => void;
  70091. /** Callback used to start pointer out animation */
  70092. pointerOutAnimation: () => void;
  70093. /** Callback used to start pointer down animation */
  70094. pointerDownAnimation: () => void;
  70095. /** Callback used to start pointer up animation */
  70096. pointerUpAnimation: () => void;
  70097. /**
  70098. * An event triggered when the pointer move over the control
  70099. */
  70100. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  70101. /**
  70102. * An event triggered when the pointer move out of the control
  70103. */
  70104. onPointerOutObservable: BABYLON.Observable<Control3D>;
  70105. /**
  70106. * An event triggered when the pointer taps the control
  70107. */
  70108. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  70109. /**
  70110. * An event triggered when pointer is up
  70111. */
  70112. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  70113. /**
  70114. * An event triggered when a control is clicked on (with a mouse)
  70115. */
  70116. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  70117. /**
  70118. * An event triggered when pointer enters the control
  70119. */
  70120. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  70121. /**
  70122. * Gets or sets the parent container
  70123. */
  70124. parent: BABYLON.Nullable<Container3D>;
  70125. private _behaviors;
  70126. /**
  70127. * Gets the list of attached behaviors
  70128. * @see http://doc.babylonjs.com/features/behaviour
  70129. */
  70130. readonly behaviors: BABYLON.Behavior<Control3D>[];
  70131. /**
  70132. * Attach a behavior to the control
  70133. * @see http://doc.babylonjs.com/features/behaviour
  70134. * @param behavior defines the behavior to attach
  70135. * @returns the current control
  70136. */
  70137. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  70138. /**
  70139. * Remove an attached behavior
  70140. * @see http://doc.babylonjs.com/features/behaviour
  70141. * @param behavior defines the behavior to attach
  70142. * @returns the current control
  70143. */
  70144. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  70145. /**
  70146. * Gets an attached behavior by name
  70147. * @param name defines the name of the behavior to look for
  70148. * @see http://doc.babylonjs.com/features/behaviour
  70149. * @returns null if behavior was not found else the requested behavior
  70150. */
  70151. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  70152. /** Gets or sets a boolean indicating if the control is visible */
  70153. isVisible: boolean;
  70154. /**
  70155. * Creates a new control
  70156. * @param name defines the control name
  70157. */
  70158. constructor(
  70159. /** Defines the control name */
  70160. name?: string | undefined);
  70161. /**
  70162. * Gets a string representing the class name
  70163. */
  70164. readonly typeName: string;
  70165. /**
  70166. * Get the current class name of the control.
  70167. * @returns current class name
  70168. */
  70169. getClassName(): string;
  70170. protected _getTypeName(): string;
  70171. /**
  70172. * Gets the transform node used by this control
  70173. */
  70174. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  70175. /**
  70176. * Gets the mesh used to render this control
  70177. */
  70178. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70179. /**
  70180. * Link the control as child of the given node
  70181. * @param node defines the node to link to. Use null to unlink the control
  70182. * @returns the current control
  70183. */
  70184. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  70185. /** @hidden **/
  70186. _prepareNode(scene: BABYLON.Scene): void;
  70187. /**
  70188. * Node creation.
  70189. * Can be overriden by children
  70190. * @param scene defines the scene where the node must be attached
  70191. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  70192. */
  70193. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  70194. /**
  70195. * Affect a material to the given mesh
  70196. * @param mesh defines the mesh which will represent the control
  70197. */
  70198. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  70199. /** @hidden */
  70200. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  70201. /** @hidden */
  70202. _onPointerEnter(target: Control3D): boolean;
  70203. /** @hidden */
  70204. _onPointerOut(target: Control3D): void;
  70205. /** @hidden */
  70206. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  70207. /** @hidden */
  70208. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70209. /** @hidden */
  70210. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  70211. /** @hidden */
  70212. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  70213. /** @hidden */
  70214. _disposeNode(): void;
  70215. /**
  70216. * Releases all associated resources
  70217. */
  70218. dispose(): void;
  70219. }
  70220. }
  70221. declare module BABYLON.GUI {
  70222. /**
  70223. * Class used as a root to all buttons
  70224. */
  70225. export class AbstractButton3D extends Control3D {
  70226. /**
  70227. * Creates a new button
  70228. * @param name defines the control name
  70229. */
  70230. constructor(name?: string);
  70231. protected _getTypeName(): string;
  70232. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70233. }
  70234. }
  70235. declare module BABYLON.GUI {
  70236. /**
  70237. * Class used to create a button in 3D
  70238. */
  70239. export class Button3D extends AbstractButton3D {
  70240. /** @hidden */
  70241. protected _currentMaterial: BABYLON.Material;
  70242. private _facadeTexture;
  70243. private _content;
  70244. private _contentResolution;
  70245. private _contentScaleRatio;
  70246. /**
  70247. * Gets or sets the texture resolution used to render content (512 by default)
  70248. */
  70249. contentResolution: BABYLON.int;
  70250. /**
  70251. * Gets or sets the texture scale ratio used to render content (2 by default)
  70252. */
  70253. contentScaleRatio: number;
  70254. protected _disposeFacadeTexture(): void;
  70255. protected _resetContent(): void;
  70256. /**
  70257. * Creates a new button
  70258. * @param name defines the control name
  70259. */
  70260. constructor(name?: string);
  70261. /**
  70262. * Gets or sets the GUI 2D content used to display the button's facade
  70263. */
  70264. content: Control;
  70265. /**
  70266. * Apply the facade texture (created from the content property).
  70267. * This function can be overloaded by child classes
  70268. * @param facadeTexture defines the AdvancedDynamicTexture to use
  70269. */
  70270. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  70271. protected _getTypeName(): string;
  70272. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70273. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  70274. /**
  70275. * Releases all associated resources
  70276. */
  70277. dispose(): void;
  70278. }
  70279. }
  70280. declare module BABYLON.GUI {
  70281. /**
  70282. * Abstract class used to create a container panel deployed on the surface of a volume
  70283. */
  70284. export abstract class VolumeBasedPanel extends Container3D {
  70285. private _columns;
  70286. private _rows;
  70287. private _rowThenColum;
  70288. private _orientation;
  70289. protected _cellWidth: number;
  70290. protected _cellHeight: number;
  70291. /**
  70292. * Gets or sets the distance between elements
  70293. */
  70294. margin: number;
  70295. /**
  70296. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  70297. * | Value | Type | Description |
  70298. * | ----- | ----------------------------------- | ----------- |
  70299. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  70300. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  70301. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  70302. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  70303. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  70304. */
  70305. orientation: number;
  70306. /**
  70307. * Gets or sets the number of columns requested (10 by default).
  70308. * The panel will automatically compute the number of rows based on number of child controls.
  70309. */
  70310. columns: BABYLON.int;
  70311. /**
  70312. * Gets or sets a the number of rows requested.
  70313. * The panel will automatically compute the number of columns based on number of child controls.
  70314. */
  70315. rows: BABYLON.int;
  70316. /**
  70317. * Creates new VolumeBasedPanel
  70318. */
  70319. constructor();
  70320. protected _arrangeChildren(): void;
  70321. /** Child classes must implement this function to provide correct control positioning */
  70322. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70323. /** Child classes can implement this function to provide additional processing */
  70324. protected _finalProcessing(): void;
  70325. }
  70326. }
  70327. declare module BABYLON.GUI {
  70328. /**
  70329. * Class used to create a container panel deployed on the surface of a cylinder
  70330. */
  70331. export class CylinderPanel extends VolumeBasedPanel {
  70332. private _radius;
  70333. /**
  70334. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  70335. */
  70336. radius: BABYLON.float;
  70337. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70338. private _cylindricalMapping;
  70339. }
  70340. }
  70341. declare module BABYLON.GUI {
  70342. /** @hidden */
  70343. export var fluentVertexShader: {
  70344. name: string;
  70345. shader: string;
  70346. };
  70347. }
  70348. declare module BABYLON.GUI {
  70349. /** @hidden */
  70350. export var fluentPixelShader: {
  70351. name: string;
  70352. shader: string;
  70353. };
  70354. }
  70355. declare module BABYLON.GUI {
  70356. /** @hidden */
  70357. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  70358. INNERGLOW: boolean;
  70359. BORDER: boolean;
  70360. HOVERLIGHT: boolean;
  70361. TEXTURE: boolean;
  70362. constructor();
  70363. }
  70364. /**
  70365. * Class used to render controls with fluent desgin
  70366. */
  70367. export class FluentMaterial extends BABYLON.PushMaterial {
  70368. /**
  70369. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  70370. */
  70371. innerGlowColorIntensity: number;
  70372. /**
  70373. * Gets or sets the inner glow color (white by default)
  70374. */
  70375. innerGlowColor: BABYLON.Color3;
  70376. /**
  70377. * Gets or sets alpha value (default is 1.0)
  70378. */
  70379. alpha: number;
  70380. /**
  70381. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  70382. */
  70383. albedoColor: BABYLON.Color3;
  70384. /**
  70385. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  70386. */
  70387. renderBorders: boolean;
  70388. /**
  70389. * Gets or sets border width (default is 0.5)
  70390. */
  70391. borderWidth: number;
  70392. /**
  70393. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  70394. */
  70395. edgeSmoothingValue: number;
  70396. /**
  70397. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  70398. */
  70399. borderMinValue: number;
  70400. /**
  70401. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  70402. */
  70403. renderHoverLight: boolean;
  70404. /**
  70405. * Gets or sets the radius used to render the hover light (default is 1.0)
  70406. */
  70407. hoverRadius: number;
  70408. /**
  70409. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  70410. */
  70411. hoverColor: BABYLON.Color4;
  70412. /**
  70413. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  70414. */
  70415. hoverPosition: BABYLON.Vector3;
  70416. private _albedoTexture;
  70417. /** Gets or sets the texture to use for albedo color */
  70418. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70419. /**
  70420. * Creates a new Fluent material
  70421. * @param name defines the name of the material
  70422. * @param scene defines the hosting scene
  70423. */
  70424. constructor(name: string, scene: BABYLON.Scene);
  70425. needAlphaBlending(): boolean;
  70426. needAlphaTesting(): boolean;
  70427. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70428. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70429. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70430. getActiveTextures(): BABYLON.BaseTexture[];
  70431. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70432. dispose(forceDisposeEffect?: boolean): void;
  70433. clone(name: string): FluentMaterial;
  70434. serialize(): any;
  70435. getClassName(): string;
  70436. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  70437. }
  70438. }
  70439. declare module BABYLON.GUI {
  70440. /**
  70441. * Class used to create a holographic button in 3D
  70442. */
  70443. export class HolographicButton extends Button3D {
  70444. private _backPlate;
  70445. private _textPlate;
  70446. private _frontPlate;
  70447. private _text;
  70448. private _imageUrl;
  70449. private _shareMaterials;
  70450. private _frontMaterial;
  70451. private _backMaterial;
  70452. private _plateMaterial;
  70453. private _pickedPointObserver;
  70454. private _tooltipFade;
  70455. private _tooltipTextBlock;
  70456. private _tooltipTexture;
  70457. private _tooltipMesh;
  70458. private _tooltipHoverObserver;
  70459. private _tooltipOutObserver;
  70460. private _disposeTooltip;
  70461. /**
  70462. * Rendering ground id of all the mesh in the button
  70463. */
  70464. renderingGroupId: number;
  70465. /**
  70466. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  70467. */
  70468. tooltipText: BABYLON.Nullable<string>;
  70469. /**
  70470. * Gets or sets text for the button
  70471. */
  70472. text: string;
  70473. /**
  70474. * Gets or sets the image url for the button
  70475. */
  70476. imageUrl: string;
  70477. /**
  70478. * Gets the back material used by this button
  70479. */
  70480. readonly backMaterial: FluentMaterial;
  70481. /**
  70482. * Gets the front material used by this button
  70483. */
  70484. readonly frontMaterial: FluentMaterial;
  70485. /**
  70486. * Gets the plate material used by this button
  70487. */
  70488. readonly plateMaterial: BABYLON.StandardMaterial;
  70489. /**
  70490. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  70491. */
  70492. readonly shareMaterials: boolean;
  70493. /**
  70494. * Creates a new button
  70495. * @param name defines the control name
  70496. */
  70497. constructor(name?: string, shareMaterials?: boolean);
  70498. protected _getTypeName(): string;
  70499. private _rebuildContent;
  70500. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70501. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  70502. private _createBackMaterial;
  70503. private _createFrontMaterial;
  70504. private _createPlateMaterial;
  70505. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  70506. /**
  70507. * Releases all associated resources
  70508. */
  70509. dispose(): void;
  70510. }
  70511. }
  70512. declare module BABYLON.GUI {
  70513. /**
  70514. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  70515. */
  70516. export class MeshButton3D extends Button3D {
  70517. /** @hidden */
  70518. protected _currentMesh: BABYLON.Mesh;
  70519. /**
  70520. * Creates a new 3D button based on a mesh
  70521. * @param mesh mesh to become a 3D button
  70522. * @param name defines the control name
  70523. */
  70524. constructor(mesh: BABYLON.Mesh, name?: string);
  70525. protected _getTypeName(): string;
  70526. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  70527. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  70528. }
  70529. }
  70530. declare module BABYLON.GUI {
  70531. /**
  70532. * Class used to create a container panel deployed on the surface of a plane
  70533. */
  70534. export class PlanePanel extends VolumeBasedPanel {
  70535. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70536. }
  70537. }
  70538. declare module BABYLON.GUI {
  70539. /**
  70540. * Class used to create a container panel where items get randomized planar mapping
  70541. */
  70542. export class ScatterPanel extends VolumeBasedPanel {
  70543. private _iteration;
  70544. /**
  70545. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  70546. */
  70547. iteration: BABYLON.float;
  70548. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70549. private _scatterMapping;
  70550. protected _finalProcessing(): void;
  70551. }
  70552. }
  70553. declare module BABYLON.GUI {
  70554. /**
  70555. * Class used to create a container panel deployed on the surface of a sphere
  70556. */
  70557. export class SpherePanel extends VolumeBasedPanel {
  70558. private _radius;
  70559. /**
  70560. * Gets or sets the radius of the sphere where to project controls (5 by default)
  70561. */
  70562. radius: BABYLON.float;
  70563. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  70564. private _sphericalMapping;
  70565. }
  70566. }
  70567. declare module BABYLON.GUI {
  70568. /**
  70569. * Class used to create a stack panel in 3D on XY plane
  70570. */
  70571. export class StackPanel3D extends Container3D {
  70572. private _isVertical;
  70573. /**
  70574. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  70575. */
  70576. isVertical: boolean;
  70577. /**
  70578. * Gets or sets the distance between elements
  70579. */
  70580. margin: number;
  70581. /**
  70582. * Creates new StackPanel
  70583. * @param isVertical
  70584. */
  70585. constructor(isVertical?: boolean);
  70586. protected _arrangeChildren(): void;
  70587. }
  70588. }
  70589. declare module BABYLON {
  70590. /**
  70591. * Mode that determines the coordinate system to use.
  70592. */
  70593. export enum GLTFLoaderCoordinateSystemMode {
  70594. /**
  70595. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  70596. */
  70597. AUTO = 0,
  70598. /**
  70599. * Sets the useRightHandedSystem flag on the scene.
  70600. */
  70601. FORCE_RIGHT_HANDED = 1
  70602. }
  70603. /**
  70604. * Mode that determines what animations will start.
  70605. */
  70606. export enum GLTFLoaderAnimationStartMode {
  70607. /**
  70608. * No animation will start.
  70609. */
  70610. NONE = 0,
  70611. /**
  70612. * The first animation will start.
  70613. */
  70614. FIRST = 1,
  70615. /**
  70616. * All animations will start.
  70617. */
  70618. ALL = 2
  70619. }
  70620. /**
  70621. * Interface that contains the data for the glTF asset.
  70622. */
  70623. export interface IGLTFLoaderData {
  70624. /**
  70625. * The object that represents the glTF JSON.
  70626. */
  70627. json: Object;
  70628. /**
  70629. * The BIN chunk of a binary glTF.
  70630. */
  70631. bin: Nullable<IDataBuffer>;
  70632. }
  70633. /**
  70634. * Interface for extending the loader.
  70635. */
  70636. export interface IGLTFLoaderExtension {
  70637. /**
  70638. * The name of this extension.
  70639. */
  70640. readonly name: string;
  70641. /**
  70642. * Defines whether this extension is enabled.
  70643. */
  70644. enabled: boolean;
  70645. /**
  70646. * Defines the order of this extension.
  70647. * The loader sorts the extensions using these values when loading.
  70648. */
  70649. order?: number;
  70650. }
  70651. /**
  70652. * Loader state.
  70653. */
  70654. export enum GLTFLoaderState {
  70655. /**
  70656. * The asset is loading.
  70657. */
  70658. LOADING = 0,
  70659. /**
  70660. * The asset is ready for rendering.
  70661. */
  70662. READY = 1,
  70663. /**
  70664. * The asset is completely loaded.
  70665. */
  70666. COMPLETE = 2
  70667. }
  70668. /** @hidden */
  70669. export interface IGLTFLoader extends IDisposable {
  70670. readonly state: Nullable<GLTFLoaderState>;
  70671. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  70672. meshes: AbstractMesh[];
  70673. particleSystems: IParticleSystem[];
  70674. skeletons: Skeleton[];
  70675. animationGroups: AnimationGroup[];
  70676. }>;
  70677. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  70678. }
  70679. /**
  70680. * File loader for loading glTF files into a scene.
  70681. */
  70682. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70683. /** @hidden */
  70684. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  70685. /** @hidden */
  70686. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  70687. /**
  70688. * Raised when the asset has been parsed
  70689. */
  70690. onParsedObservable: Observable<IGLTFLoaderData>;
  70691. private _onParsedObserver;
  70692. /**
  70693. * Raised when the asset has been parsed
  70694. */
  70695. onParsed: (loaderData: IGLTFLoaderData) => void;
  70696. /**
  70697. * 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.
  70698. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  70699. * Defaults to true.
  70700. * @hidden
  70701. */
  70702. static IncrementalLoading: boolean;
  70703. /**
  70704. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  70705. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  70706. * @hidden
  70707. */
  70708. static HomogeneousCoordinates: boolean;
  70709. /**
  70710. * The coordinate system mode. Defaults to AUTO.
  70711. */
  70712. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  70713. /**
  70714. * The animation start mode. Defaults to FIRST.
  70715. */
  70716. animationStartMode: GLTFLoaderAnimationStartMode;
  70717. /**
  70718. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  70719. */
  70720. compileMaterials: boolean;
  70721. /**
  70722. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  70723. */
  70724. useClipPlane: boolean;
  70725. /**
  70726. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  70727. */
  70728. compileShadowGenerators: boolean;
  70729. /**
  70730. * Defines if the Alpha blended materials are only applied as coverage.
  70731. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  70732. * If true, no extra effects are applied to transparent pixels.
  70733. */
  70734. transparencyAsCoverage: boolean;
  70735. /**
  70736. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  70737. * Enabling will disable offline support and glTF validator.
  70738. * Defaults to false.
  70739. */
  70740. useRangeRequests: boolean;
  70741. /**
  70742. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  70743. */
  70744. createInstances: boolean;
  70745. /**
  70746. * Function called before loading a url referenced by the asset.
  70747. */
  70748. preprocessUrlAsync: (url: string) => Promise<string>;
  70749. /**
  70750. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  70751. */
  70752. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  70753. private _onMeshLoadedObserver;
  70754. /**
  70755. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  70756. */
  70757. onMeshLoaded: (mesh: AbstractMesh) => void;
  70758. /**
  70759. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  70760. */
  70761. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  70762. private _onTextureLoadedObserver;
  70763. /**
  70764. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  70765. */
  70766. onTextureLoaded: (texture: BaseTexture) => void;
  70767. /**
  70768. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  70769. */
  70770. readonly onMaterialLoadedObservable: Observable<Material>;
  70771. private _onMaterialLoadedObserver;
  70772. /**
  70773. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  70774. */
  70775. onMaterialLoaded: (material: Material) => void;
  70776. /**
  70777. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  70778. */
  70779. readonly onCameraLoadedObservable: Observable<Camera>;
  70780. private _onCameraLoadedObserver;
  70781. /**
  70782. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  70783. */
  70784. onCameraLoaded: (camera: Camera) => void;
  70785. /**
  70786. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  70787. * For assets with LODs, raised when all of the LODs are complete.
  70788. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  70789. */
  70790. readonly onCompleteObservable: Observable<void>;
  70791. private _onCompleteObserver;
  70792. /**
  70793. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  70794. * For assets with LODs, raised when all of the LODs are complete.
  70795. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  70796. */
  70797. onComplete: () => void;
  70798. /**
  70799. * Observable raised when an error occurs.
  70800. */
  70801. readonly onErrorObservable: Observable<any>;
  70802. private _onErrorObserver;
  70803. /**
  70804. * Callback raised when an error occurs.
  70805. */
  70806. onError: (reason: any) => void;
  70807. /**
  70808. * Observable raised after the loader is disposed.
  70809. */
  70810. readonly onDisposeObservable: Observable<void>;
  70811. private _onDisposeObserver;
  70812. /**
  70813. * Callback raised after the loader is disposed.
  70814. */
  70815. onDispose: () => void;
  70816. /**
  70817. * Observable raised after a loader extension is created.
  70818. * Set additional options for a loader extension in this event.
  70819. */
  70820. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  70821. private _onExtensionLoadedObserver;
  70822. /**
  70823. * Callback raised after a loader extension is created.
  70824. */
  70825. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  70826. /**
  70827. * Defines if the loader logging is enabled.
  70828. */
  70829. loggingEnabled: boolean;
  70830. /**
  70831. * Defines if the loader should capture performance counters.
  70832. */
  70833. capturePerformanceCounters: boolean;
  70834. /**
  70835. * Defines if the loader should validate the asset.
  70836. */
  70837. validate: boolean;
  70838. /**
  70839. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  70840. */
  70841. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  70842. private _onValidatedObserver;
  70843. /**
  70844. * Callback raised after a loader extension is created.
  70845. */
  70846. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  70847. private _loader;
  70848. /**
  70849. * Name of the loader ("gltf")
  70850. */
  70851. name: string;
  70852. /** @hidden */
  70853. extensions: ISceneLoaderPluginExtensions;
  70854. /**
  70855. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  70856. */
  70857. dispose(): void;
  70858. /** @hidden */
  70859. _clear(): void;
  70860. /** @hidden */
  70861. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  70862. /** @hidden */
  70863. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  70864. /** @hidden */
  70865. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70866. meshes: AbstractMesh[];
  70867. particleSystems: IParticleSystem[];
  70868. skeletons: Skeleton[];
  70869. animationGroups: AnimationGroup[];
  70870. }>;
  70871. /** @hidden */
  70872. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70873. /** @hidden */
  70874. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70875. /** @hidden */
  70876. canDirectLoad(data: string): boolean;
  70877. /** @hidden */
  70878. directLoad(scene: Scene, data: string): any;
  70879. /**
  70880. * The callback that allows custom handling of the root url based on the response url.
  70881. * @param rootUrl the original root url
  70882. * @param responseURL the response url if available
  70883. * @returns the new root url
  70884. */
  70885. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  70886. /** @hidden */
  70887. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  70888. /**
  70889. * The loader state or null if the loader is not active.
  70890. */
  70891. readonly loaderState: Nullable<GLTFLoaderState>;
  70892. /**
  70893. * Returns a promise that resolves when the asset is completely loaded.
  70894. * @returns a promise that resolves when the asset is completely loaded.
  70895. */
  70896. whenCompleteAsync(): Promise<void>;
  70897. private _validateAsync;
  70898. private _getLoader;
  70899. private _parseJson;
  70900. private _unpackBinaryAsync;
  70901. private _unpackBinaryV1Async;
  70902. private _unpackBinaryV2Async;
  70903. private static _parseVersion;
  70904. private static _compareVersion;
  70905. private static readonly _logSpaces;
  70906. private _logIndentLevel;
  70907. private _loggingEnabled;
  70908. /** @hidden */
  70909. _log: (message: string) => void;
  70910. /** @hidden */
  70911. _logOpen(message: string): void;
  70912. /** @hidden */
  70913. _logClose(): void;
  70914. private _logEnabled;
  70915. private _logDisabled;
  70916. private _capturePerformanceCounters;
  70917. /** @hidden */
  70918. _startPerformanceCounter: (counterName: string) => void;
  70919. /** @hidden */
  70920. _endPerformanceCounter: (counterName: string) => void;
  70921. private _startPerformanceCounterEnabled;
  70922. private _startPerformanceCounterDisabled;
  70923. private _endPerformanceCounterEnabled;
  70924. private _endPerformanceCounterDisabled;
  70925. }
  70926. }
  70927. declare module BABYLON.GLTF1 {
  70928. /**
  70929. * Enums
  70930. * @hidden
  70931. */
  70932. export enum EComponentType {
  70933. BYTE = 5120,
  70934. UNSIGNED_BYTE = 5121,
  70935. SHORT = 5122,
  70936. UNSIGNED_SHORT = 5123,
  70937. FLOAT = 5126
  70938. }
  70939. /** @hidden */
  70940. export enum EShaderType {
  70941. FRAGMENT = 35632,
  70942. VERTEX = 35633
  70943. }
  70944. /** @hidden */
  70945. export enum EParameterType {
  70946. BYTE = 5120,
  70947. UNSIGNED_BYTE = 5121,
  70948. SHORT = 5122,
  70949. UNSIGNED_SHORT = 5123,
  70950. INT = 5124,
  70951. UNSIGNED_INT = 5125,
  70952. FLOAT = 5126,
  70953. FLOAT_VEC2 = 35664,
  70954. FLOAT_VEC3 = 35665,
  70955. FLOAT_VEC4 = 35666,
  70956. INT_VEC2 = 35667,
  70957. INT_VEC3 = 35668,
  70958. INT_VEC4 = 35669,
  70959. BOOL = 35670,
  70960. BOOL_VEC2 = 35671,
  70961. BOOL_VEC3 = 35672,
  70962. BOOL_VEC4 = 35673,
  70963. FLOAT_MAT2 = 35674,
  70964. FLOAT_MAT3 = 35675,
  70965. FLOAT_MAT4 = 35676,
  70966. SAMPLER_2D = 35678
  70967. }
  70968. /** @hidden */
  70969. export enum ETextureWrapMode {
  70970. CLAMP_TO_EDGE = 33071,
  70971. MIRRORED_REPEAT = 33648,
  70972. REPEAT = 10497
  70973. }
  70974. /** @hidden */
  70975. export enum ETextureFilterType {
  70976. NEAREST = 9728,
  70977. LINEAR = 9728,
  70978. NEAREST_MIPMAP_NEAREST = 9984,
  70979. LINEAR_MIPMAP_NEAREST = 9985,
  70980. NEAREST_MIPMAP_LINEAR = 9986,
  70981. LINEAR_MIPMAP_LINEAR = 9987
  70982. }
  70983. /** @hidden */
  70984. export enum ETextureFormat {
  70985. ALPHA = 6406,
  70986. RGB = 6407,
  70987. RGBA = 6408,
  70988. LUMINANCE = 6409,
  70989. LUMINANCE_ALPHA = 6410
  70990. }
  70991. /** @hidden */
  70992. export enum ECullingType {
  70993. FRONT = 1028,
  70994. BACK = 1029,
  70995. FRONT_AND_BACK = 1032
  70996. }
  70997. /** @hidden */
  70998. export enum EBlendingFunction {
  70999. ZERO = 0,
  71000. ONE = 1,
  71001. SRC_COLOR = 768,
  71002. ONE_MINUS_SRC_COLOR = 769,
  71003. DST_COLOR = 774,
  71004. ONE_MINUS_DST_COLOR = 775,
  71005. SRC_ALPHA = 770,
  71006. ONE_MINUS_SRC_ALPHA = 771,
  71007. DST_ALPHA = 772,
  71008. ONE_MINUS_DST_ALPHA = 773,
  71009. CONSTANT_COLOR = 32769,
  71010. ONE_MINUS_CONSTANT_COLOR = 32770,
  71011. CONSTANT_ALPHA = 32771,
  71012. ONE_MINUS_CONSTANT_ALPHA = 32772,
  71013. SRC_ALPHA_SATURATE = 776
  71014. }
  71015. /** @hidden */
  71016. export interface IGLTFProperty {
  71017. extensions?: {
  71018. [key: string]: any;
  71019. };
  71020. extras?: Object;
  71021. }
  71022. /** @hidden */
  71023. export interface IGLTFChildRootProperty extends IGLTFProperty {
  71024. name?: string;
  71025. }
  71026. /** @hidden */
  71027. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  71028. bufferView: string;
  71029. byteOffset: number;
  71030. byteStride: number;
  71031. count: number;
  71032. type: string;
  71033. componentType: EComponentType;
  71034. max?: number[];
  71035. min?: number[];
  71036. name?: string;
  71037. }
  71038. /** @hidden */
  71039. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  71040. buffer: string;
  71041. byteOffset: number;
  71042. byteLength: number;
  71043. byteStride: number;
  71044. target?: number;
  71045. }
  71046. /** @hidden */
  71047. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  71048. uri: string;
  71049. byteLength?: number;
  71050. type?: string;
  71051. }
  71052. /** @hidden */
  71053. export interface IGLTFShader extends IGLTFChildRootProperty {
  71054. uri: string;
  71055. type: EShaderType;
  71056. }
  71057. /** @hidden */
  71058. export interface IGLTFProgram extends IGLTFChildRootProperty {
  71059. attributes: string[];
  71060. fragmentShader: string;
  71061. vertexShader: string;
  71062. }
  71063. /** @hidden */
  71064. export interface IGLTFTechniqueParameter {
  71065. type: number;
  71066. count?: number;
  71067. semantic?: string;
  71068. node?: string;
  71069. value?: number | boolean | string | Array<any>;
  71070. source?: string;
  71071. babylonValue?: any;
  71072. }
  71073. /** @hidden */
  71074. export interface IGLTFTechniqueCommonProfile {
  71075. lightingModel: string;
  71076. texcoordBindings: Object;
  71077. parameters?: Array<any>;
  71078. }
  71079. /** @hidden */
  71080. export interface IGLTFTechniqueStatesFunctions {
  71081. blendColor?: number[];
  71082. blendEquationSeparate?: number[];
  71083. blendFuncSeparate?: number[];
  71084. colorMask: boolean[];
  71085. cullFace: number[];
  71086. }
  71087. /** @hidden */
  71088. export interface IGLTFTechniqueStates {
  71089. enable: number[];
  71090. functions: IGLTFTechniqueStatesFunctions;
  71091. }
  71092. /** @hidden */
  71093. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  71094. parameters: {
  71095. [key: string]: IGLTFTechniqueParameter;
  71096. };
  71097. program: string;
  71098. attributes: {
  71099. [key: string]: string;
  71100. };
  71101. uniforms: {
  71102. [key: string]: string;
  71103. };
  71104. states: IGLTFTechniqueStates;
  71105. }
  71106. /** @hidden */
  71107. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  71108. technique?: string;
  71109. values: string[];
  71110. }
  71111. /** @hidden */
  71112. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  71113. attributes: {
  71114. [key: string]: string;
  71115. };
  71116. indices: string;
  71117. material: string;
  71118. mode?: number;
  71119. }
  71120. /** @hidden */
  71121. export interface IGLTFMesh extends IGLTFChildRootProperty {
  71122. primitives: IGLTFMeshPrimitive[];
  71123. }
  71124. /** @hidden */
  71125. export interface IGLTFImage extends IGLTFChildRootProperty {
  71126. uri: string;
  71127. }
  71128. /** @hidden */
  71129. export interface IGLTFSampler extends IGLTFChildRootProperty {
  71130. magFilter?: number;
  71131. minFilter?: number;
  71132. wrapS?: number;
  71133. wrapT?: number;
  71134. }
  71135. /** @hidden */
  71136. export interface IGLTFTexture extends IGLTFChildRootProperty {
  71137. sampler: string;
  71138. source: string;
  71139. format?: ETextureFormat;
  71140. internalFormat?: ETextureFormat;
  71141. target?: number;
  71142. type?: number;
  71143. babylonTexture?: Texture;
  71144. }
  71145. /** @hidden */
  71146. export interface IGLTFAmbienLight {
  71147. color?: number[];
  71148. }
  71149. /** @hidden */
  71150. export interface IGLTFDirectionalLight {
  71151. color?: number[];
  71152. }
  71153. /** @hidden */
  71154. export interface IGLTFPointLight {
  71155. color?: number[];
  71156. constantAttenuation?: number;
  71157. linearAttenuation?: number;
  71158. quadraticAttenuation?: number;
  71159. }
  71160. /** @hidden */
  71161. export interface IGLTFSpotLight {
  71162. color?: number[];
  71163. constantAttenuation?: number;
  71164. fallOfAngle?: number;
  71165. fallOffExponent?: number;
  71166. linearAttenuation?: number;
  71167. quadraticAttenuation?: number;
  71168. }
  71169. /** @hidden */
  71170. export interface IGLTFLight extends IGLTFChildRootProperty {
  71171. type: string;
  71172. }
  71173. /** @hidden */
  71174. export interface IGLTFCameraOrthographic {
  71175. xmag: number;
  71176. ymag: number;
  71177. zfar: number;
  71178. znear: number;
  71179. }
  71180. /** @hidden */
  71181. export interface IGLTFCameraPerspective {
  71182. aspectRatio: number;
  71183. yfov: number;
  71184. zfar: number;
  71185. znear: number;
  71186. }
  71187. /** @hidden */
  71188. export interface IGLTFCamera extends IGLTFChildRootProperty {
  71189. type: string;
  71190. }
  71191. /** @hidden */
  71192. export interface IGLTFAnimationChannelTarget {
  71193. id: string;
  71194. path: string;
  71195. }
  71196. /** @hidden */
  71197. export interface IGLTFAnimationChannel {
  71198. sampler: string;
  71199. target: IGLTFAnimationChannelTarget;
  71200. }
  71201. /** @hidden */
  71202. export interface IGLTFAnimationSampler {
  71203. input: string;
  71204. output: string;
  71205. interpolation?: string;
  71206. }
  71207. /** @hidden */
  71208. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  71209. channels?: IGLTFAnimationChannel[];
  71210. parameters?: {
  71211. [key: string]: string;
  71212. };
  71213. samplers?: {
  71214. [key: string]: IGLTFAnimationSampler;
  71215. };
  71216. }
  71217. /** @hidden */
  71218. export interface IGLTFNodeInstanceSkin {
  71219. skeletons: string[];
  71220. skin: string;
  71221. meshes: string[];
  71222. }
  71223. /** @hidden */
  71224. export interface IGLTFSkins extends IGLTFChildRootProperty {
  71225. bindShapeMatrix: number[];
  71226. inverseBindMatrices: string;
  71227. jointNames: string[];
  71228. babylonSkeleton?: Skeleton;
  71229. }
  71230. /** @hidden */
  71231. export interface IGLTFNode extends IGLTFChildRootProperty {
  71232. camera?: string;
  71233. children: string[];
  71234. skin?: string;
  71235. jointName?: string;
  71236. light?: string;
  71237. matrix: number[];
  71238. mesh?: string;
  71239. meshes?: string[];
  71240. rotation?: number[];
  71241. scale?: number[];
  71242. translation?: number[];
  71243. babylonNode?: Node;
  71244. }
  71245. /** @hidden */
  71246. export interface IGLTFScene extends IGLTFChildRootProperty {
  71247. nodes: string[];
  71248. }
  71249. /** @hidden */
  71250. export interface IGLTFRuntime {
  71251. extensions: {
  71252. [key: string]: any;
  71253. };
  71254. accessors: {
  71255. [key: string]: IGLTFAccessor;
  71256. };
  71257. buffers: {
  71258. [key: string]: IGLTFBuffer;
  71259. };
  71260. bufferViews: {
  71261. [key: string]: IGLTFBufferView;
  71262. };
  71263. meshes: {
  71264. [key: string]: IGLTFMesh;
  71265. };
  71266. lights: {
  71267. [key: string]: IGLTFLight;
  71268. };
  71269. cameras: {
  71270. [key: string]: IGLTFCamera;
  71271. };
  71272. nodes: {
  71273. [key: string]: IGLTFNode;
  71274. };
  71275. images: {
  71276. [key: string]: IGLTFImage;
  71277. };
  71278. textures: {
  71279. [key: string]: IGLTFTexture;
  71280. };
  71281. shaders: {
  71282. [key: string]: IGLTFShader;
  71283. };
  71284. programs: {
  71285. [key: string]: IGLTFProgram;
  71286. };
  71287. samplers: {
  71288. [key: string]: IGLTFSampler;
  71289. };
  71290. techniques: {
  71291. [key: string]: IGLTFTechnique;
  71292. };
  71293. materials: {
  71294. [key: string]: IGLTFMaterial;
  71295. };
  71296. animations: {
  71297. [key: string]: IGLTFAnimation;
  71298. };
  71299. skins: {
  71300. [key: string]: IGLTFSkins;
  71301. };
  71302. currentScene?: Object;
  71303. scenes: {
  71304. [key: string]: IGLTFScene;
  71305. };
  71306. extensionsUsed: string[];
  71307. extensionsRequired?: string[];
  71308. buffersCount: number;
  71309. shaderscount: number;
  71310. scene: Scene;
  71311. rootUrl: string;
  71312. loadedBufferCount: number;
  71313. loadedBufferViews: {
  71314. [name: string]: ArrayBufferView;
  71315. };
  71316. loadedShaderCount: number;
  71317. importOnlyMeshes: boolean;
  71318. importMeshesNames?: string[];
  71319. dummyNodes: Node[];
  71320. }
  71321. /** @hidden */
  71322. export interface INodeToRoot {
  71323. bone: Bone;
  71324. node: IGLTFNode;
  71325. id: string;
  71326. }
  71327. /** @hidden */
  71328. export interface IJointNode {
  71329. node: IGLTFNode;
  71330. id: string;
  71331. }
  71332. }
  71333. declare module BABYLON.GLTF1 {
  71334. /**
  71335. * Utils functions for GLTF
  71336. * @hidden
  71337. */
  71338. export class GLTFUtils {
  71339. /**
  71340. * Sets the given "parameter" matrix
  71341. * @param scene: the Scene object
  71342. * @param source: the source node where to pick the matrix
  71343. * @param parameter: the GLTF technique parameter
  71344. * @param uniformName: the name of the shader's uniform
  71345. * @param shaderMaterial: the shader material
  71346. */
  71347. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  71348. /**
  71349. * Sets the given "parameter" matrix
  71350. * @param shaderMaterial: the shader material
  71351. * @param uniform: the name of the shader's uniform
  71352. * @param value: the value of the uniform
  71353. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  71354. */
  71355. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  71356. /**
  71357. * Returns the wrap mode of the texture
  71358. * @param mode: the mode value
  71359. */
  71360. static GetWrapMode(mode: number): number;
  71361. /**
  71362. * Returns the byte stride giving an accessor
  71363. * @param accessor: the GLTF accessor objet
  71364. */
  71365. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  71366. /**
  71367. * Returns the texture filter mode giving a mode value
  71368. * @param mode: the filter mode value
  71369. */
  71370. static GetTextureFilterMode(mode: number): ETextureFilterType;
  71371. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  71372. /**
  71373. * Returns a buffer from its accessor
  71374. * @param gltfRuntime: the GLTF runtime
  71375. * @param accessor: the GLTF accessor
  71376. */
  71377. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  71378. /**
  71379. * Decodes a buffer view into a string
  71380. * @param view: the buffer view
  71381. */
  71382. static DecodeBufferToText(view: ArrayBufferView): string;
  71383. /**
  71384. * Returns the default material of gltf. Related to
  71385. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  71386. * @param scene: the Babylon.js scene
  71387. */
  71388. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  71389. private static _DefaultMaterial;
  71390. }
  71391. }
  71392. declare module BABYLON.GLTF1 {
  71393. /**
  71394. * Implementation of the base glTF spec
  71395. * @hidden
  71396. */
  71397. export class GLTFLoaderBase {
  71398. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  71399. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  71400. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  71401. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  71402. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  71403. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  71404. }
  71405. /**
  71406. * glTF V1 Loader
  71407. * @hidden
  71408. */
  71409. export class GLTFLoader implements IGLTFLoader {
  71410. static Extensions: {
  71411. [name: string]: GLTFLoaderExtension;
  71412. };
  71413. static RegisterExtension(extension: GLTFLoaderExtension): void;
  71414. state: Nullable<GLTFLoaderState>;
  71415. dispose(): void;
  71416. private _importMeshAsync;
  71417. /**
  71418. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  71419. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  71420. * @param scene the scene the meshes should be added to
  71421. * @param data gltf data containing information of the meshes in a loaded file
  71422. * @param rootUrl root url to load from
  71423. * @param onProgress event that fires when loading progress has occured
  71424. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  71425. */
  71426. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  71427. meshes: AbstractMesh[];
  71428. particleSystems: IParticleSystem[];
  71429. skeletons: Skeleton[];
  71430. animationGroups: AnimationGroup[];
  71431. }>;
  71432. private _loadAsync;
  71433. /**
  71434. * Imports all objects from a loaded gltf file and adds them to the scene
  71435. * @param scene the scene the objects should be added to
  71436. * @param data gltf data containing information of the meshes in a loaded file
  71437. * @param rootUrl root url to load from
  71438. * @param onProgress event that fires when loading progress has occured
  71439. * @returns a promise which completes when objects have been loaded to the scene
  71440. */
  71441. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  71442. private _loadShadersAsync;
  71443. private _loadBuffersAsync;
  71444. private _createNodes;
  71445. }
  71446. /** @hidden */
  71447. export abstract class GLTFLoaderExtension {
  71448. private _name;
  71449. constructor(name: string);
  71450. readonly name: string;
  71451. /**
  71452. * Defines an override for loading the runtime
  71453. * Return true to stop further extensions from loading the runtime
  71454. */
  71455. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  71456. /**
  71457. * Defines an onverride for creating gltf runtime
  71458. * Return true to stop further extensions from creating the runtime
  71459. */
  71460. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  71461. /**
  71462. * Defines an override for loading buffers
  71463. * Return true to stop further extensions from loading this buffer
  71464. */
  71465. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  71466. /**
  71467. * Defines an override for loading texture buffers
  71468. * Return true to stop further extensions from loading this texture data
  71469. */
  71470. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  71471. /**
  71472. * Defines an override for creating textures
  71473. * Return true to stop further extensions from loading this texture
  71474. */
  71475. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  71476. /**
  71477. * Defines an override for loading shader strings
  71478. * Return true to stop further extensions from loading this shader data
  71479. */
  71480. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  71481. /**
  71482. * Defines an override for loading materials
  71483. * Return true to stop further extensions from loading this material
  71484. */
  71485. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  71486. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  71487. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  71488. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  71489. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  71490. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  71491. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  71492. private static LoadTextureBufferAsync;
  71493. private static CreateTextureAsync;
  71494. private static ApplyExtensions;
  71495. }
  71496. }
  71497. declare module BABYLON.GLTF1 {
  71498. /** @hidden */
  71499. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  71500. private _bin;
  71501. constructor();
  71502. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  71503. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  71504. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  71505. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  71506. }
  71507. }
  71508. declare module BABYLON.GLTF1 {
  71509. /** @hidden */
  71510. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  71511. constructor();
  71512. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  71513. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  71514. private _loadTexture;
  71515. }
  71516. }
  71517. declare module BABYLON.GLTF2.Loader {
  71518. /**
  71519. * Loader interface with an index field.
  71520. */
  71521. export interface IArrayItem {
  71522. /**
  71523. * The index of this item in the array.
  71524. */
  71525. index: number;
  71526. }
  71527. /**
  71528. * Loader interface with additional members.
  71529. */
  71530. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  71531. /** @hidden */
  71532. _data?: Promise<ArrayBufferView>;
  71533. /** @hidden */
  71534. _babylonVertexBuffer?: Promise<VertexBuffer>;
  71535. }
  71536. /**
  71537. * Loader interface with additional members.
  71538. */
  71539. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  71540. }
  71541. /** @hidden */
  71542. export interface _IAnimationSamplerData {
  71543. input: Float32Array;
  71544. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  71545. output: Float32Array;
  71546. }
  71547. /**
  71548. * Loader interface with additional members.
  71549. */
  71550. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  71551. /** @hidden */
  71552. _data?: Promise<_IAnimationSamplerData>;
  71553. }
  71554. /**
  71555. * Loader interface with additional members.
  71556. */
  71557. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  71558. channels: IAnimationChannel[];
  71559. samplers: IAnimationSampler[];
  71560. /** @hidden */
  71561. _babylonAnimationGroup?: AnimationGroup;
  71562. }
  71563. /**
  71564. * Loader interface with additional members.
  71565. */
  71566. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  71567. /** @hidden */
  71568. _data?: Promise<ArrayBufferView>;
  71569. }
  71570. /**
  71571. * Loader interface with additional members.
  71572. */
  71573. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  71574. /** @hidden */
  71575. _data?: Promise<ArrayBufferView>;
  71576. /** @hidden */
  71577. _babylonBuffer?: Promise<Buffer>;
  71578. }
  71579. /**
  71580. * Loader interface with additional members.
  71581. */
  71582. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  71583. }
  71584. /**
  71585. * Loader interface with additional members.
  71586. */
  71587. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  71588. /** @hidden */
  71589. _data?: Promise<ArrayBufferView>;
  71590. }
  71591. /**
  71592. * Loader interface with additional members.
  71593. */
  71594. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  71595. }
  71596. /**
  71597. * Loader interface with additional members.
  71598. */
  71599. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  71600. }
  71601. /**
  71602. * Loader interface with additional members.
  71603. */
  71604. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  71605. baseColorTexture?: ITextureInfo;
  71606. metallicRoughnessTexture?: ITextureInfo;
  71607. }
  71608. /**
  71609. * Loader interface with additional members.
  71610. */
  71611. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  71612. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71613. normalTexture?: IMaterialNormalTextureInfo;
  71614. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71615. emissiveTexture?: ITextureInfo;
  71616. /** @hidden */
  71617. _data?: {
  71618. [babylonDrawMode: number]: {
  71619. babylonMaterial: Material;
  71620. babylonMeshes: AbstractMesh[];
  71621. promise: Promise<void>;
  71622. };
  71623. };
  71624. }
  71625. /**
  71626. * Loader interface with additional members.
  71627. */
  71628. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  71629. primitives: IMeshPrimitive[];
  71630. }
  71631. /**
  71632. * Loader interface with additional members.
  71633. */
  71634. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  71635. /** @hidden */
  71636. _instanceData?: {
  71637. babylonSourceMesh: Mesh;
  71638. promise: Promise<any>;
  71639. };
  71640. }
  71641. /**
  71642. * Loader interface with additional members.
  71643. */
  71644. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  71645. /**
  71646. * The parent glTF node.
  71647. */
  71648. parent?: INode;
  71649. /** @hidden */
  71650. _babylonTransformNode?: TransformNode;
  71651. /** @hidden */
  71652. _primitiveBabylonMeshes?: AbstractMesh[];
  71653. /** @hidden */
  71654. _babylonBones?: Bone[];
  71655. /** @hidden */
  71656. _numMorphTargets?: number;
  71657. }
  71658. /** @hidden */
  71659. export interface _ISamplerData {
  71660. noMipMaps: boolean;
  71661. samplingMode: number;
  71662. wrapU: number;
  71663. wrapV: number;
  71664. }
  71665. /**
  71666. * Loader interface with additional members.
  71667. */
  71668. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  71669. /** @hidden */
  71670. _data?: _ISamplerData;
  71671. }
  71672. /**
  71673. * Loader interface with additional members.
  71674. */
  71675. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  71676. }
  71677. /**
  71678. * Loader interface with additional members.
  71679. */
  71680. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  71681. /** @hidden */
  71682. _data?: {
  71683. babylonSkeleton: Skeleton;
  71684. promise: Promise<void>;
  71685. };
  71686. }
  71687. /**
  71688. * Loader interface with additional members.
  71689. */
  71690. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  71691. }
  71692. /**
  71693. * Loader interface with additional members.
  71694. */
  71695. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  71696. }
  71697. /**
  71698. * Loader interface with additional members.
  71699. */
  71700. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  71701. accessors?: IAccessor[];
  71702. animations?: IAnimation[];
  71703. buffers?: IBuffer[];
  71704. bufferViews?: IBufferView[];
  71705. cameras?: ICamera[];
  71706. images?: IImage[];
  71707. materials?: IMaterial[];
  71708. meshes?: IMesh[];
  71709. nodes?: INode[];
  71710. samplers?: ISampler[];
  71711. scenes?: IScene[];
  71712. skins?: ISkin[];
  71713. textures?: ITexture[];
  71714. }
  71715. }
  71716. declare module BABYLON.GLTF2 {
  71717. /**
  71718. * Interface for a glTF loader extension.
  71719. */
  71720. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  71721. /**
  71722. * Called after the loader state changes to LOADING.
  71723. */
  71724. onLoading?(): void;
  71725. /**
  71726. * Called after the loader state changes to READY.
  71727. */
  71728. onReady?(): void;
  71729. /**
  71730. * Define this method to modify the default behavior when loading scenes.
  71731. * @param context The context when loading the asset
  71732. * @param scene The glTF scene property
  71733. * @returns A promise that resolves when the load is complete or null if not handled
  71734. */
  71735. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  71736. /**
  71737. * Define this method to modify the default behavior when loading nodes.
  71738. * @param context The context when loading the asset
  71739. * @param node The glTF node property
  71740. * @param assign A function called synchronously after parsing the glTF properties
  71741. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  71742. */
  71743. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  71744. /**
  71745. * Define this method to modify the default behavior when loading cameras.
  71746. * @param context The context when loading the asset
  71747. * @param camera The glTF camera property
  71748. * @param assign A function called synchronously after parsing the glTF properties
  71749. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  71750. */
  71751. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  71752. /**
  71753. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  71754. * @param context The context when loading the asset
  71755. * @param primitive The glTF mesh primitive property
  71756. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  71757. */
  71758. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  71759. /**
  71760. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  71761. * @param context The context when loading the asset
  71762. * @param name The mesh name when loading the asset
  71763. * @param node The glTF node when loading the asset
  71764. * @param mesh The glTF mesh when loading the asset
  71765. * @param primitive The glTF mesh primitive property
  71766. * @param assign A function called synchronously after parsing the glTF properties
  71767. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  71768. */
  71769. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  71770. /**
  71771. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  71772. * @param context The context when loading the asset
  71773. * @param material The glTF material property
  71774. * @param assign A function called synchronously after parsing the glTF properties
  71775. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  71776. */
  71777. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  71778. /**
  71779. * Define this method to modify the default behavior when creating materials.
  71780. * @param context The context when loading the asset
  71781. * @param material The glTF material property
  71782. * @param babylonDrawMode The draw mode for the Babylon material
  71783. * @returns The Babylon material or null if not handled
  71784. */
  71785. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  71786. /**
  71787. * Define this method to modify the default behavior when loading material properties.
  71788. * @param context The context when loading the asset
  71789. * @param material The glTF material property
  71790. * @param babylonMaterial The Babylon material
  71791. * @returns A promise that resolves when the load is complete or null if not handled
  71792. */
  71793. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  71794. /**
  71795. * Define this method to modify the default behavior when loading texture infos.
  71796. * @param context The context when loading the asset
  71797. * @param textureInfo The glTF texture info property
  71798. * @param assign A function called synchronously after parsing the glTF properties
  71799. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  71800. */
  71801. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  71802. /**
  71803. * Define this method to modify the default behavior when loading animations.
  71804. * @param context The context when loading the asset
  71805. * @param animation The glTF animation property
  71806. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  71807. */
  71808. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  71809. /**
  71810. * @hidden Define this method to modify the default behavior when loading skins.
  71811. * @param context The context when loading the asset
  71812. * @param node The glTF node property
  71813. * @param skin The glTF skin property
  71814. * @returns A promise that resolves when the load is complete or null if not handled
  71815. */
  71816. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  71817. /**
  71818. * @hidden Define this method to modify the default behavior when loading uris.
  71819. * @param context The context when loading the asset
  71820. * @param property The glTF property associated with the uri
  71821. * @param uri The uri to load
  71822. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71823. */
  71824. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  71825. /**
  71826. * Define this method to modify the default behavior when loading buffer views.
  71827. * @param context The context when loading the asset
  71828. * @param bufferView The glTF buffer view property
  71829. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71830. */
  71831. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  71832. /**
  71833. * Define this method to modify the default behavior when loading buffers.
  71834. * @param context The context when loading the asset
  71835. * @param buffer The glTF buffer property
  71836. * @param byteOffset The byte offset to load
  71837. * @param byteLength The byte length to load
  71838. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  71839. */
  71840. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  71841. }
  71842. }
  71843. declare module BABYLON.GLTF2 {
  71844. /**
  71845. * Helper class for working with arrays when loading the glTF asset
  71846. */
  71847. export class ArrayItem {
  71848. /**
  71849. * Gets an item from the given array.
  71850. * @param context The context when loading the asset
  71851. * @param array The array to get the item from
  71852. * @param index The index to the array
  71853. * @returns The array item
  71854. */
  71855. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  71856. /**
  71857. * Assign an `index` field to each item of the given array.
  71858. * @param array The array of items
  71859. */
  71860. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  71861. }
  71862. /**
  71863. * The glTF 2.0 loader
  71864. */
  71865. export class GLTFLoader implements IGLTFLoader {
  71866. /** @hidden */
  71867. _completePromises: Promise<any>[];
  71868. private _disposed;
  71869. private _parent;
  71870. private _state;
  71871. private _extensions;
  71872. private _rootUrl;
  71873. private _fileName;
  71874. private _uniqueRootUrl;
  71875. private _gltf;
  71876. private _bin;
  71877. private _babylonScene;
  71878. private _rootBabylonMesh;
  71879. private _defaultBabylonMaterialData;
  71880. private _progressCallback?;
  71881. private _requests;
  71882. private static readonly _DefaultSampler;
  71883. private static _RegisteredExtensions;
  71884. /**
  71885. * Registers a loader extension.
  71886. * @param name The name of the loader extension.
  71887. * @param factory The factory function that creates the loader extension.
  71888. */
  71889. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  71890. /**
  71891. * Unregisters a loader extension.
  71892. * @param name The name of the loader extension.
  71893. * @returns A boolean indicating whether the extension has been unregistered
  71894. */
  71895. static UnregisterExtension(name: string): boolean;
  71896. /**
  71897. * Gets the loader state.
  71898. */
  71899. readonly state: Nullable<GLTFLoaderState>;
  71900. /**
  71901. * The object that represents the glTF JSON.
  71902. */
  71903. readonly gltf: IGLTF;
  71904. /**
  71905. * The BIN chunk of a binary glTF.
  71906. */
  71907. readonly bin: Nullable<IDataBuffer>;
  71908. /**
  71909. * The parent file loader.
  71910. */
  71911. readonly parent: GLTFFileLoader;
  71912. /**
  71913. * The Babylon scene when loading the asset.
  71914. */
  71915. readonly babylonScene: Scene;
  71916. /**
  71917. * The root Babylon mesh when loading the asset.
  71918. */
  71919. readonly rootBabylonMesh: Mesh;
  71920. /** @hidden */
  71921. constructor(parent: GLTFFileLoader);
  71922. /** @hidden */
  71923. dispose(): void;
  71924. /** @hidden */
  71925. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  71926. meshes: AbstractMesh[];
  71927. particleSystems: IParticleSystem[];
  71928. skeletons: Skeleton[];
  71929. animationGroups: AnimationGroup[];
  71930. }>;
  71931. /** @hidden */
  71932. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  71933. private _loadAsync;
  71934. private _loadData;
  71935. private _setupData;
  71936. private _loadExtensions;
  71937. private _checkExtensions;
  71938. private _setState;
  71939. private _createRootNode;
  71940. /**
  71941. * Loads a glTF scene.
  71942. * @param context The context when loading the asset
  71943. * @param scene The glTF scene property
  71944. * @returns A promise that resolves when the load is complete
  71945. */
  71946. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  71947. private _forEachPrimitive;
  71948. private _getMeshes;
  71949. private _getSkeletons;
  71950. private _getAnimationGroups;
  71951. private _startAnimations;
  71952. /**
  71953. * Loads a glTF node.
  71954. * @param context The context when loading the asset
  71955. * @param node The glTF node property
  71956. * @param assign A function called synchronously after parsing the glTF properties
  71957. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  71958. */
  71959. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  71960. private _loadMeshAsync;
  71961. /**
  71962. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  71963. * @param context The context when loading the asset
  71964. * @param name The mesh name when loading the asset
  71965. * @param node The glTF node when loading the asset
  71966. * @param mesh The glTF mesh when loading the asset
  71967. * @param primitive The glTF mesh primitive property
  71968. * @param assign A function called synchronously after parsing the glTF properties
  71969. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  71970. */
  71971. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  71972. private _loadVertexDataAsync;
  71973. private _createMorphTargets;
  71974. private _loadMorphTargetsAsync;
  71975. private _loadMorphTargetVertexDataAsync;
  71976. private static _LoadTransform;
  71977. private _loadSkinAsync;
  71978. private _loadBones;
  71979. private _loadBone;
  71980. private _loadSkinInverseBindMatricesDataAsync;
  71981. private _updateBoneMatrices;
  71982. private _getNodeMatrix;
  71983. /**
  71984. * Loads a glTF camera.
  71985. * @param context The context when loading the asset
  71986. * @param camera The glTF camera property
  71987. * @param assign A function called synchronously after parsing the glTF properties
  71988. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  71989. */
  71990. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  71991. private _loadAnimationsAsync;
  71992. /**
  71993. * Loads a glTF animation.
  71994. * @param context The context when loading the asset
  71995. * @param animation The glTF animation property
  71996. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  71997. */
  71998. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  71999. /**
  72000. * @hidden Loads a glTF animation channel.
  72001. * @param context The context when loading the asset
  72002. * @param animationContext The context of the animation when loading the asset
  72003. * @param animation The glTF animation property
  72004. * @param channel The glTF animation channel property
  72005. * @param babylonAnimationGroup The babylon animation group property
  72006. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  72007. * @returns A void promise when the channel load is complete
  72008. */
  72009. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  72010. private _loadAnimationSamplerAsync;
  72011. private _loadBufferAsync;
  72012. /**
  72013. * Loads a glTF buffer view.
  72014. * @param context The context when loading the asset
  72015. * @param bufferView The glTF buffer view property
  72016. * @returns A promise that resolves with the loaded data when the load is complete
  72017. */
  72018. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  72019. private _loadAccessorAsync;
  72020. private _loadFloatAccessorAsync;
  72021. private _loadIndicesAccessorAsync;
  72022. private _loadVertexBufferViewAsync;
  72023. private _loadVertexAccessorAsync;
  72024. private _loadMaterialMetallicRoughnessPropertiesAsync;
  72025. /** @hidden */
  72026. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  72027. private _createDefaultMaterial;
  72028. /**
  72029. * Creates a Babylon material from a glTF material.
  72030. * @param context The context when loading the asset
  72031. * @param material The glTF material property
  72032. * @param babylonDrawMode The draw mode for the Babylon material
  72033. * @returns The Babylon material
  72034. */
  72035. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  72036. /**
  72037. * Loads properties from a glTF material into a Babylon material.
  72038. * @param context The context when loading the asset
  72039. * @param material The glTF material property
  72040. * @param babylonMaterial The Babylon material
  72041. * @returns A promise that resolves when the load is complete
  72042. */
  72043. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72044. /**
  72045. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  72046. * @param context The context when loading the asset
  72047. * @param material The glTF material property
  72048. * @param babylonMaterial The Babylon material
  72049. * @returns A promise that resolves when the load is complete
  72050. */
  72051. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  72052. /**
  72053. * Loads the alpha properties from a glTF material into a Babylon material.
  72054. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  72055. * @param context The context when loading the asset
  72056. * @param material The glTF material property
  72057. * @param babylonMaterial The Babylon material
  72058. */
  72059. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  72060. /**
  72061. * Loads a glTF texture info.
  72062. * @param context The context when loading the asset
  72063. * @param textureInfo The glTF texture info property
  72064. * @param assign A function called synchronously after parsing the glTF properties
  72065. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  72066. */
  72067. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  72068. private _loadTextureAsync;
  72069. private _loadSampler;
  72070. /**
  72071. * Loads a glTF image.
  72072. * @param context The context when loading the asset
  72073. * @param image The glTF image property
  72074. * @returns A promise that resolves with the loaded data when the load is complete
  72075. */
  72076. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  72077. /**
  72078. * Loads a glTF uri.
  72079. * @param context The context when loading the asset
  72080. * @param property The glTF property associated with the uri
  72081. * @param uri The base64 or relative uri
  72082. * @returns A promise that resolves with the loaded data when the load is complete
  72083. */
  72084. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  72085. private _onProgress;
  72086. /**
  72087. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  72088. * @param babylonObject the Babylon object with metadata
  72089. * @param pointer the JSON pointer
  72090. */
  72091. static AddPointerMetadata(babylonObject: {
  72092. metadata: any;
  72093. }, pointer: string): void;
  72094. private static _GetTextureWrapMode;
  72095. private static _GetTextureSamplingMode;
  72096. private static _GetTypedArrayConstructor;
  72097. private static _GetTypedArray;
  72098. private static _GetNumComponents;
  72099. private static _ValidateUri;
  72100. private static _GetDrawMode;
  72101. private _compileMaterialsAsync;
  72102. private _compileShadowGeneratorsAsync;
  72103. private _forEachExtensions;
  72104. private _applyExtensions;
  72105. private _extensionsOnLoading;
  72106. private _extensionsOnReady;
  72107. private _extensionsLoadSceneAsync;
  72108. private _extensionsLoadNodeAsync;
  72109. private _extensionsLoadCameraAsync;
  72110. private _extensionsLoadVertexDataAsync;
  72111. private _extensionsLoadMeshPrimitiveAsync;
  72112. private _extensionsLoadMaterialAsync;
  72113. private _extensionsCreateMaterial;
  72114. private _extensionsLoadMaterialPropertiesAsync;
  72115. private _extensionsLoadTextureInfoAsync;
  72116. private _extensionsLoadAnimationAsync;
  72117. private _extensionsLoadSkinAsync;
  72118. private _extensionsLoadUriAsync;
  72119. private _extensionsLoadBufferViewAsync;
  72120. private _extensionsLoadBufferAsync;
  72121. /**
  72122. * Helper method called by a loader extension to load an glTF extension.
  72123. * @param context The context when loading the asset
  72124. * @param property The glTF property to load the extension from
  72125. * @param extensionName The name of the extension to load
  72126. * @param actionAsync The action to run
  72127. * @returns The promise returned by actionAsync or null if the extension does not exist
  72128. */
  72129. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  72130. /**
  72131. * Helper method called by a loader extension to load a glTF extra.
  72132. * @param context The context when loading the asset
  72133. * @param property The glTF property to load the extra from
  72134. * @param extensionName The name of the extension to load
  72135. * @param actionAsync The action to run
  72136. * @returns The promise returned by actionAsync or null if the extra does not exist
  72137. */
  72138. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  72139. /**
  72140. * Checks for presence of an extension.
  72141. * @param name The name of the extension to check
  72142. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  72143. */
  72144. isExtensionUsed(name: string): boolean;
  72145. /**
  72146. * Increments the indentation level and logs a message.
  72147. * @param message The message to log
  72148. */
  72149. logOpen(message: string): void;
  72150. /**
  72151. * Decrements the indentation level.
  72152. */
  72153. logClose(): void;
  72154. /**
  72155. * Logs a message
  72156. * @param message The message to log
  72157. */
  72158. log(message: string): void;
  72159. /**
  72160. * Starts a performance counter.
  72161. * @param counterName The name of the performance counter
  72162. */
  72163. startPerformanceCounter(counterName: string): void;
  72164. /**
  72165. * Ends a performance counter.
  72166. * @param counterName The name of the performance counter
  72167. */
  72168. endPerformanceCounter(counterName: string): void;
  72169. }
  72170. }
  72171. declare module BABYLON.GLTF2.Loader.Extensions {
  72172. /**
  72173. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  72174. */
  72175. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  72176. /**
  72177. * The name of this extension.
  72178. */
  72179. readonly name: string;
  72180. /**
  72181. * Defines whether this extension is enabled.
  72182. */
  72183. enabled: boolean;
  72184. private _loader;
  72185. private _lights?;
  72186. /** @hidden */
  72187. constructor(loader: GLTFLoader);
  72188. /** @hidden */
  72189. dispose(): void;
  72190. /** @hidden */
  72191. onLoading(): void;
  72192. /** @hidden */
  72193. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  72194. private _loadLightAsync;
  72195. }
  72196. }
  72197. declare module BABYLON.GLTF2.Loader.Extensions {
  72198. /**
  72199. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  72200. */
  72201. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  72202. /**
  72203. * The name of this extension.
  72204. */
  72205. readonly name: string;
  72206. /**
  72207. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  72208. */
  72209. dracoCompression?: DracoCompression;
  72210. /**
  72211. * Defines whether this extension is enabled.
  72212. */
  72213. enabled: boolean;
  72214. private _loader;
  72215. /** @hidden */
  72216. constructor(loader: GLTFLoader);
  72217. /** @hidden */
  72218. dispose(): void;
  72219. /** @hidden */
  72220. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  72221. }
  72222. }
  72223. declare module BABYLON.GLTF2.Loader.Extensions {
  72224. /**
  72225. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  72226. */
  72227. export class KHR_lights implements IGLTFLoaderExtension {
  72228. /**
  72229. * The name of this extension.
  72230. */
  72231. readonly name: string;
  72232. /**
  72233. * Defines whether this extension is enabled.
  72234. */
  72235. enabled: boolean;
  72236. private _loader;
  72237. private _lights?;
  72238. /** @hidden */
  72239. constructor(loader: GLTFLoader);
  72240. /** @hidden */
  72241. dispose(): void;
  72242. /** @hidden */
  72243. onLoading(): void;
  72244. /** @hidden */
  72245. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72246. }
  72247. }
  72248. declare module BABYLON.GLTF2.Loader.Extensions {
  72249. /**
  72250. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  72251. */
  72252. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  72253. /**
  72254. * The name of this extension.
  72255. */
  72256. readonly name: string;
  72257. /**
  72258. * Defines whether this extension is enabled.
  72259. */
  72260. enabled: boolean;
  72261. /**
  72262. * Defines a number that determines the order the extensions are applied.
  72263. */
  72264. order: number;
  72265. private _loader;
  72266. /** @hidden */
  72267. constructor(loader: GLTFLoader);
  72268. /** @hidden */
  72269. dispose(): void;
  72270. /** @hidden */
  72271. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72272. private _loadSpecularGlossinessPropertiesAsync;
  72273. }
  72274. }
  72275. declare module BABYLON.GLTF2.Loader.Extensions {
  72276. /**
  72277. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  72278. */
  72279. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  72280. /**
  72281. * The name of this extension.
  72282. */
  72283. readonly name: string;
  72284. /**
  72285. * Defines whether this extension is enabled.
  72286. */
  72287. enabled: boolean;
  72288. /**
  72289. * Defines a number that determines the order the extensions are applied.
  72290. */
  72291. order: number;
  72292. private _loader;
  72293. /** @hidden */
  72294. constructor(loader: GLTFLoader);
  72295. /** @hidden */
  72296. dispose(): void;
  72297. /** @hidden */
  72298. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72299. private _loadUnlitPropertiesAsync;
  72300. }
  72301. }
  72302. declare module BABYLON.GLTF2.Loader.Extensions {
  72303. /**
  72304. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  72305. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  72306. * !!! Experimental Extension Subject to Changes !!!
  72307. */
  72308. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  72309. /**
  72310. * The name of this extension.
  72311. */
  72312. readonly name: string;
  72313. /**
  72314. * Defines whether this extension is enabled.
  72315. */
  72316. enabled: boolean;
  72317. /**
  72318. * Defines a number that determines the order the extensions are applied.
  72319. */
  72320. order: number;
  72321. private _loader;
  72322. /** @hidden */
  72323. constructor(loader: GLTFLoader);
  72324. /** @hidden */
  72325. dispose(): void;
  72326. /** @hidden */
  72327. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72328. private _loadClearCoatPropertiesAsync;
  72329. }
  72330. }
  72331. declare module BABYLON.GLTF2.Loader.Extensions {
  72332. /**
  72333. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  72334. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  72335. * !!! Experimental Extension Subject to Changes !!!
  72336. */
  72337. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  72338. /**
  72339. * The name of this extension.
  72340. */
  72341. readonly name: string;
  72342. /**
  72343. * Defines whether this extension is enabled.
  72344. */
  72345. enabled: boolean;
  72346. /**
  72347. * Defines a number that determines the order the extensions are applied.
  72348. */
  72349. order: number;
  72350. private _loader;
  72351. /** @hidden */
  72352. constructor(loader: GLTFLoader);
  72353. /** @hidden */
  72354. dispose(): void;
  72355. /** @hidden */
  72356. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72357. private _loadSheenPropertiesAsync;
  72358. }
  72359. }
  72360. declare module BABYLON.GLTF2.Loader.Extensions {
  72361. /**
  72362. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  72363. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  72364. * !!! Experimental Extension Subject to Changes !!!
  72365. */
  72366. export class KHR_materials_specular implements IGLTFLoaderExtension {
  72367. /**
  72368. * The name of this extension.
  72369. */
  72370. readonly name: string;
  72371. /**
  72372. * Defines whether this extension is enabled.
  72373. */
  72374. enabled: boolean;
  72375. /**
  72376. * Defines a number that determines the order the extensions are applied.
  72377. */
  72378. order: number;
  72379. private _loader;
  72380. /** @hidden */
  72381. constructor(loader: GLTFLoader);
  72382. /** @hidden */
  72383. dispose(): void;
  72384. /** @hidden */
  72385. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72386. private _loadSpecularPropertiesAsync;
  72387. }
  72388. }
  72389. declare module BABYLON.GLTF2.Loader.Extensions {
  72390. /**
  72391. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  72392. */
  72393. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  72394. /**
  72395. * The name of this extension.
  72396. */
  72397. readonly name: string;
  72398. /**
  72399. * Defines whether this extension is enabled.
  72400. */
  72401. enabled: boolean;
  72402. /** @hidden */
  72403. constructor(loader: GLTFLoader);
  72404. /** @hidden */
  72405. dispose(): void;
  72406. }
  72407. }
  72408. declare module BABYLON.GLTF2.Loader.Extensions {
  72409. /**
  72410. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  72411. */
  72412. export class KHR_texture_transform implements IGLTFLoaderExtension {
  72413. /**
  72414. * The name of this extension.
  72415. */
  72416. readonly name: string;
  72417. /**
  72418. * Defines whether this extension is enabled.
  72419. */
  72420. enabled: boolean;
  72421. private _loader;
  72422. /** @hidden */
  72423. constructor(loader: GLTFLoader);
  72424. /** @hidden */
  72425. dispose(): void;
  72426. /** @hidden */
  72427. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  72428. }
  72429. }
  72430. declare module BABYLON.GLTF2.Loader.Extensions {
  72431. /**
  72432. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  72433. */
  72434. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  72435. /**
  72436. * The name of this extension.
  72437. */
  72438. readonly name: string;
  72439. /**
  72440. * Defines whether this extension is enabled.
  72441. */
  72442. enabled: boolean;
  72443. private _loader;
  72444. private _clips;
  72445. private _emitters;
  72446. /** @hidden */
  72447. constructor(loader: GLTFLoader);
  72448. /** @hidden */
  72449. dispose(): void;
  72450. /** @hidden */
  72451. onLoading(): void;
  72452. /** @hidden */
  72453. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  72454. /** @hidden */
  72455. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72456. /** @hidden */
  72457. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  72458. private _loadClipAsync;
  72459. private _loadEmitterAsync;
  72460. private _getEventAction;
  72461. private _loadAnimationEventAsync;
  72462. }
  72463. }
  72464. declare module BABYLON.GLTF2.Loader.Extensions {
  72465. /**
  72466. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  72467. */
  72468. export class MSFT_lod implements IGLTFLoaderExtension {
  72469. /**
  72470. * The name of this extension.
  72471. */
  72472. readonly name: string;
  72473. /**
  72474. * Defines whether this extension is enabled.
  72475. */
  72476. enabled: boolean;
  72477. /**
  72478. * Defines a number that determines the order the extensions are applied.
  72479. */
  72480. order: number;
  72481. /**
  72482. * Maximum number of LODs to load, starting from the lowest LOD.
  72483. */
  72484. maxLODsToLoad: number;
  72485. /**
  72486. * Observable raised when all node LODs of one level are loaded.
  72487. * The event data is the index of the loaded LOD starting from zero.
  72488. * Dispose the loader to cancel the loading of the next level of LODs.
  72489. */
  72490. onNodeLODsLoadedObservable: Observable<number>;
  72491. /**
  72492. * Observable raised when all material LODs of one level are loaded.
  72493. * The event data is the index of the loaded LOD starting from zero.
  72494. * Dispose the loader to cancel the loading of the next level of LODs.
  72495. */
  72496. onMaterialLODsLoadedObservable: Observable<number>;
  72497. private _loader;
  72498. private _nodeIndexLOD;
  72499. private _nodeSignalLODs;
  72500. private _nodePromiseLODs;
  72501. private _materialIndexLOD;
  72502. private _materialSignalLODs;
  72503. private _materialPromiseLODs;
  72504. private _indexLOD;
  72505. private _bufferLODs;
  72506. /** @hidden */
  72507. constructor(loader: GLTFLoader);
  72508. /** @hidden */
  72509. dispose(): void;
  72510. /** @hidden */
  72511. onReady(): void;
  72512. /** @hidden */
  72513. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72514. /** @hidden */
  72515. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  72516. /** @hidden */
  72517. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  72518. /** @hidden */
  72519. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  72520. private _loadBufferLOD;
  72521. /**
  72522. * Gets an array of LOD properties from lowest to highest.
  72523. */
  72524. private _getLODs;
  72525. private _disposeUnusedMaterials;
  72526. }
  72527. }
  72528. declare module BABYLON.GLTF2.Loader.Extensions {
  72529. /** @hidden */
  72530. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  72531. readonly name: string;
  72532. enabled: boolean;
  72533. private _loader;
  72534. constructor(loader: GLTFLoader);
  72535. dispose(): void;
  72536. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72537. }
  72538. }
  72539. declare module BABYLON.GLTF2.Loader.Extensions {
  72540. /** @hidden */
  72541. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  72542. readonly name: string;
  72543. enabled: boolean;
  72544. private _loader;
  72545. constructor(loader: GLTFLoader);
  72546. dispose(): void;
  72547. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  72548. }
  72549. }
  72550. declare module BABYLON.GLTF2.Loader.Extensions {
  72551. /**
  72552. * Store glTF extras (if present) in BJS objects' metadata
  72553. */
  72554. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  72555. /**
  72556. * The name of this extension.
  72557. */
  72558. readonly name: string;
  72559. /**
  72560. * Defines whether this extension is enabled.
  72561. */
  72562. enabled: boolean;
  72563. private _loader;
  72564. private _assignExtras;
  72565. /** @hidden */
  72566. constructor(loader: GLTFLoader);
  72567. /** @hidden */
  72568. dispose(): void;
  72569. /** @hidden */
  72570. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  72571. /** @hidden */
  72572. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  72573. /** @hidden */
  72574. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  72575. }
  72576. }
  72577. declare module BABYLON {
  72578. /**
  72579. * Class reading and parsing the MTL file bundled with the obj file.
  72580. */
  72581. export class MTLFileLoader {
  72582. /**
  72583. * All material loaded from the mtl will be set here
  72584. */
  72585. materials: StandardMaterial[];
  72586. /**
  72587. * This function will read the mtl file and create each material described inside
  72588. * This function could be improve by adding :
  72589. * -some component missing (Ni, Tf...)
  72590. * -including the specific options available
  72591. *
  72592. * @param scene defines the scene the material will be created in
  72593. * @param data defines the mtl data to parse
  72594. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  72595. */
  72596. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  72597. /**
  72598. * Gets the texture for the material.
  72599. *
  72600. * If the material is imported from input file,
  72601. * We sanitize the url to ensure it takes the textre from aside the material.
  72602. *
  72603. * @param rootUrl The root url to load from
  72604. * @param value The value stored in the mtl
  72605. * @return The Texture
  72606. */
  72607. private static _getTexture;
  72608. }
  72609. /**
  72610. * Options for loading OBJ/MTL files
  72611. */
  72612. type MeshLoadOptions = {
  72613. /**
  72614. * Defines if UVs are optimized by default during load.
  72615. */
  72616. OptimizeWithUV: boolean;
  72617. /**
  72618. * Defines custom scaling of UV coordinates of loaded meshes.
  72619. */
  72620. UVScaling: Vector2;
  72621. /**
  72622. * Invert model on y-axis (does a model scaling inversion)
  72623. */
  72624. InvertY: boolean;
  72625. /**
  72626. * Invert Y-Axis of referenced textures on load
  72627. */
  72628. InvertTextureY: boolean;
  72629. /**
  72630. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  72631. */
  72632. ImportVertexColors: boolean;
  72633. /**
  72634. * Compute the normals for the model, even if normals are present in the file.
  72635. */
  72636. ComputeNormals: boolean;
  72637. /**
  72638. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  72639. */
  72640. SkipMaterials: boolean;
  72641. /**
  72642. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  72643. */
  72644. MaterialLoadingFailsSilently: boolean;
  72645. };
  72646. /**
  72647. * OBJ file type loader.
  72648. * This is a babylon scene loader plugin.
  72649. */
  72650. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  72651. /**
  72652. * Defines if UVs are optimized by default during load.
  72653. */
  72654. static OPTIMIZE_WITH_UV: boolean;
  72655. /**
  72656. * Invert model on y-axis (does a model scaling inversion)
  72657. */
  72658. static INVERT_Y: boolean;
  72659. /**
  72660. * Invert Y-Axis of referenced textures on load
  72661. */
  72662. static INVERT_TEXTURE_Y: boolean;
  72663. /**
  72664. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  72665. */
  72666. static IMPORT_VERTEX_COLORS: boolean;
  72667. /**
  72668. * Compute the normals for the model, even if normals are present in the file.
  72669. */
  72670. static COMPUTE_NORMALS: boolean;
  72671. /**
  72672. * Defines custom scaling of UV coordinates of loaded meshes.
  72673. */
  72674. static UV_SCALING: Vector2;
  72675. /**
  72676. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  72677. */
  72678. static SKIP_MATERIALS: boolean;
  72679. /**
  72680. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  72681. *
  72682. * Defaults to true for backwards compatibility.
  72683. */
  72684. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  72685. /**
  72686. * Defines the name of the plugin.
  72687. */
  72688. name: string;
  72689. /**
  72690. * Defines the extension the plugin is able to load.
  72691. */
  72692. extensions: string;
  72693. /** @hidden */
  72694. obj: RegExp;
  72695. /** @hidden */
  72696. group: RegExp;
  72697. /** @hidden */
  72698. mtllib: RegExp;
  72699. /** @hidden */
  72700. usemtl: RegExp;
  72701. /** @hidden */
  72702. smooth: RegExp;
  72703. /** @hidden */
  72704. vertexPattern: RegExp;
  72705. /** @hidden */
  72706. normalPattern: RegExp;
  72707. /** @hidden */
  72708. uvPattern: RegExp;
  72709. /** @hidden */
  72710. facePattern1: RegExp;
  72711. /** @hidden */
  72712. facePattern2: RegExp;
  72713. /** @hidden */
  72714. facePattern3: RegExp;
  72715. /** @hidden */
  72716. facePattern4: RegExp;
  72717. /** @hidden */
  72718. facePattern5: RegExp;
  72719. private _meshLoadOptions;
  72720. /**
  72721. * Creates loader for .OBJ files
  72722. *
  72723. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  72724. */
  72725. constructor(meshLoadOptions?: MeshLoadOptions);
  72726. private static readonly currentMeshLoadOptions;
  72727. /**
  72728. * Calls synchronously the MTL file attached to this obj.
  72729. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  72730. * Without this function materials are not displayed in the first frame (but displayed after).
  72731. * In consequence it is impossible to get material information in your HTML file
  72732. *
  72733. * @param url The URL of the MTL file
  72734. * @param rootUrl
  72735. * @param onSuccess Callback function to be called when the MTL file is loaded
  72736. * @private
  72737. */
  72738. private _loadMTL;
  72739. /**
  72740. * Instantiates a OBJ file loader plugin.
  72741. * @returns the created plugin
  72742. */
  72743. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  72744. /**
  72745. * If the data string can be loaded directly.
  72746. *
  72747. * @param data string containing the file data
  72748. * @returns if the data can be loaded directly
  72749. */
  72750. canDirectLoad(data: string): boolean;
  72751. /**
  72752. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  72753. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  72754. * @param scene the scene the meshes should be added to
  72755. * @param data the OBJ data to load
  72756. * @param rootUrl root url to load from
  72757. * @param onProgress event that fires when loading progress has occured
  72758. * @param fileName Defines the name of the file to load
  72759. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  72760. */
  72761. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  72762. meshes: AbstractMesh[];
  72763. particleSystems: IParticleSystem[];
  72764. skeletons: Skeleton[];
  72765. animationGroups: AnimationGroup[];
  72766. }>;
  72767. /**
  72768. * Imports all objects from the loaded OBJ data and adds them to the scene
  72769. * @param scene the scene the objects should be added to
  72770. * @param data the OBJ data to load
  72771. * @param rootUrl root url to load from
  72772. * @param onProgress event that fires when loading progress has occured
  72773. * @param fileName Defines the name of the file to load
  72774. * @returns a promise which completes when objects have been loaded to the scene
  72775. */
  72776. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  72777. /**
  72778. * Load into an asset container.
  72779. * @param scene The scene to load into
  72780. * @param data The data to import
  72781. * @param rootUrl The root url for scene and resources
  72782. * @param onProgress The callback when the load progresses
  72783. * @param fileName Defines the name of the file to load
  72784. * @returns The loaded asset container
  72785. */
  72786. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  72787. /**
  72788. * Read the OBJ file and create an Array of meshes.
  72789. * Each mesh contains all information given by the OBJ and the MTL file.
  72790. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  72791. *
  72792. * @param meshesNames
  72793. * @param scene Scene The scene where are displayed the data
  72794. * @param data String The content of the obj file
  72795. * @param rootUrl String The path to the folder
  72796. * @returns Array<AbstractMesh>
  72797. * @private
  72798. */
  72799. private _parseSolid;
  72800. }
  72801. }
  72802. declare module BABYLON {
  72803. /**
  72804. * STL file type loader.
  72805. * This is a babylon scene loader plugin.
  72806. */
  72807. export class STLFileLoader implements ISceneLoaderPlugin {
  72808. /** @hidden */
  72809. solidPattern: RegExp;
  72810. /** @hidden */
  72811. facetsPattern: RegExp;
  72812. /** @hidden */
  72813. normalPattern: RegExp;
  72814. /** @hidden */
  72815. vertexPattern: RegExp;
  72816. /**
  72817. * Defines the name of the plugin.
  72818. */
  72819. name: string;
  72820. /**
  72821. * Defines the extensions the stl loader is able to load.
  72822. * force data to come in as an ArrayBuffer
  72823. * we'll convert to string if it looks like it's an ASCII .stl
  72824. */
  72825. extensions: ISceneLoaderPluginExtensions;
  72826. /**
  72827. * Import meshes into a scene.
  72828. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  72829. * @param scene The scene to import into
  72830. * @param data The data to import
  72831. * @param rootUrl The root url for scene and resources
  72832. * @param meshes The meshes array to import into
  72833. * @param particleSystems The particle systems array to import into
  72834. * @param skeletons The skeletons array to import into
  72835. * @param onError The callback when import fails
  72836. * @returns True if successful or false otherwise
  72837. */
  72838. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  72839. /**
  72840. * Load into a scene.
  72841. * @param scene The scene to load into
  72842. * @param data The data to import
  72843. * @param rootUrl The root url for scene and resources
  72844. * @param onError The callback when import fails
  72845. * @returns true if successful or false otherwise
  72846. */
  72847. load(scene: Scene, data: any, rootUrl: string): boolean;
  72848. /**
  72849. * Load into an asset container.
  72850. * @param scene The scene to load into
  72851. * @param data The data to import
  72852. * @param rootUrl The root url for scene and resources
  72853. * @param onError The callback when import fails
  72854. * @returns The loaded asset container
  72855. */
  72856. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  72857. private _isBinary;
  72858. private _parseBinary;
  72859. private _parseASCII;
  72860. }
  72861. }
  72862. declare module BABYLON {
  72863. /**
  72864. * Class for generating OBJ data from a Babylon scene.
  72865. */
  72866. export class OBJExport {
  72867. /**
  72868. * Exports the geometry of a Mesh array in .OBJ file format (text)
  72869. * @param mesh defines the list of meshes to serialize
  72870. * @param materials defines if materials should be exported
  72871. * @param matlibname defines the name of the associated mtl file
  72872. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  72873. * @returns the OBJ content
  72874. */
  72875. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  72876. /**
  72877. * Exports the material(s) of a mesh in .MTL file format (text)
  72878. * @param mesh defines the mesh to extract the material from
  72879. * @returns the mtl content
  72880. */
  72881. static MTL(mesh: Mesh): string;
  72882. }
  72883. }
  72884. declare module BABYLON {
  72885. /** @hidden */
  72886. export var __IGLTFExporterExtension: number;
  72887. /**
  72888. * Interface for extending the exporter
  72889. * @hidden
  72890. */
  72891. export interface IGLTFExporterExtension {
  72892. /**
  72893. * The name of this extension
  72894. */
  72895. readonly name: string;
  72896. /**
  72897. * Defines whether this extension is enabled
  72898. */
  72899. enabled: boolean;
  72900. /**
  72901. * Defines whether this extension is required
  72902. */
  72903. required: boolean;
  72904. }
  72905. }
  72906. declare module BABYLON.GLTF2.Exporter {
  72907. /** @hidden */
  72908. export var __IGLTFExporterExtensionV2: number;
  72909. /**
  72910. * Interface for a glTF exporter extension
  72911. * @hidden
  72912. */
  72913. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  72914. /**
  72915. * Define this method to modify the default behavior before exporting a texture
  72916. * @param context The context when loading the asset
  72917. * @param babylonTexture The Babylon.js texture
  72918. * @param mimeType The mime-type of the generated image
  72919. * @returns A promise that resolves with the exported texture
  72920. */
  72921. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  72922. /**
  72923. * Define this method to get notified when a texture info is created
  72924. * @param context The context when loading the asset
  72925. * @param textureInfo The glTF texture info
  72926. * @param babylonTexture The Babylon.js texture
  72927. */
  72928. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  72929. /**
  72930. * Define this method to modify the default behavior when exporting texture info
  72931. * @param context The context when loading the asset
  72932. * @param meshPrimitive glTF mesh primitive
  72933. * @param babylonSubMesh Babylon submesh
  72934. * @param binaryWriter glTF serializer binary writer instance
  72935. * @returns nullable IMeshPrimitive promise
  72936. */
  72937. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  72938. /**
  72939. * Define this method to modify the default behavior when exporting a node
  72940. * @param context The context when exporting the node
  72941. * @param node glTF node
  72942. * @param babylonNode BabylonJS node
  72943. * @returns nullable INode promise
  72944. */
  72945. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  72946. /**
  72947. * Define this method to modify the default behavior when exporting a material
  72948. * @param material glTF material
  72949. * @param babylonMaterial BabylonJS material
  72950. * @returns nullable IMaterial promise
  72951. */
  72952. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  72953. /**
  72954. * Define this method to return additional textures to export from a material
  72955. * @param material glTF material
  72956. * @param babylonMaterial BabylonJS material
  72957. * @returns List of textures
  72958. */
  72959. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  72960. /** Gets a boolean indicating that this extension was used */
  72961. wasUsed: boolean;
  72962. /** Gets a boolean indicating that this extension is required for the file to work */
  72963. required: boolean;
  72964. /**
  72965. * Called after the exporter state changes to EXPORTING
  72966. */
  72967. onExporting?(): void;
  72968. }
  72969. }
  72970. declare module BABYLON.GLTF2.Exporter {
  72971. /**
  72972. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  72973. * @hidden
  72974. */
  72975. export class _GLTFMaterialExporter {
  72976. /**
  72977. * Represents the dielectric specular values for R, G and B
  72978. */
  72979. private static readonly _DielectricSpecular;
  72980. /**
  72981. * Allows the maximum specular power to be defined for material calculations
  72982. */
  72983. private static readonly _MaxSpecularPower;
  72984. /**
  72985. * Mapping to store textures
  72986. */
  72987. private _textureMap;
  72988. /**
  72989. * Numeric tolerance value
  72990. */
  72991. private static readonly _Epsilon;
  72992. /**
  72993. * Reference to the glTF Exporter
  72994. */
  72995. private _exporter;
  72996. constructor(exporter: _Exporter);
  72997. /**
  72998. * Specifies if two colors are approximately equal in value
  72999. * @param color1 first color to compare to
  73000. * @param color2 second color to compare to
  73001. * @param epsilon threshold value
  73002. */
  73003. private static FuzzyEquals;
  73004. /**
  73005. * Gets the materials from a Babylon scene and converts them to glTF materials
  73006. * @param scene babylonjs scene
  73007. * @param mimeType texture mime type
  73008. * @param images array of images
  73009. * @param textures array of textures
  73010. * @param materials array of materials
  73011. * @param imageData mapping of texture names to base64 textures
  73012. * @param hasTextureCoords specifies if texture coordinates are present on the material
  73013. */
  73014. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  73015. /**
  73016. * Makes a copy of the glTF material without the texture parameters
  73017. * @param originalMaterial original glTF material
  73018. * @returns glTF material without texture parameters
  73019. */
  73020. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  73021. /**
  73022. * Specifies if the material has any texture parameters present
  73023. * @param material glTF Material
  73024. * @returns boolean specifying if texture parameters are present
  73025. */
  73026. _hasTexturesPresent(material: IMaterial): boolean;
  73027. /**
  73028. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  73029. * @param babylonStandardMaterial
  73030. * @returns glTF Metallic Roughness Material representation
  73031. */
  73032. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  73033. /**
  73034. * Computes the metallic factor
  73035. * @param diffuse diffused value
  73036. * @param specular specular value
  73037. * @param oneMinusSpecularStrength one minus the specular strength
  73038. * @returns metallic value
  73039. */
  73040. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  73041. /**
  73042. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  73043. * @param glTFMaterial glTF material
  73044. * @param babylonMaterial Babylon material
  73045. */
  73046. private static _SetAlphaMode;
  73047. /**
  73048. * Converts a Babylon Standard Material to a glTF Material
  73049. * @param babylonStandardMaterial BJS Standard Material
  73050. * @param mimeType mime type to use for the textures
  73051. * @param images array of glTF image interfaces
  73052. * @param textures array of glTF texture interfaces
  73053. * @param materials array of glTF material interfaces
  73054. * @param imageData map of image file name to data
  73055. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73056. */
  73057. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73058. private _finishMaterial;
  73059. /**
  73060. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  73061. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  73062. * @param mimeType mime type to use for the textures
  73063. * @param images array of glTF image interfaces
  73064. * @param textures array of glTF texture interfaces
  73065. * @param materials array of glTF material interfaces
  73066. * @param imageData map of image file name to data
  73067. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73068. */
  73069. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73070. /**
  73071. * Converts an image typed array buffer to a base64 image
  73072. * @param buffer typed array buffer
  73073. * @param width width of the image
  73074. * @param height height of the image
  73075. * @param mimeType mimetype of the image
  73076. * @returns base64 image string
  73077. */
  73078. private _createBase64FromCanvasAsync;
  73079. /**
  73080. * Generates a white texture based on the specified width and height
  73081. * @param width width of the texture in pixels
  73082. * @param height height of the texture in pixels
  73083. * @param scene babylonjs scene
  73084. * @returns white texture
  73085. */
  73086. private _createWhiteTexture;
  73087. /**
  73088. * 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
  73089. * @param texture1 first texture to resize
  73090. * @param texture2 second texture to resize
  73091. * @param scene babylonjs scene
  73092. * @returns resized textures or null
  73093. */
  73094. private _resizeTexturesToSameDimensions;
  73095. /**
  73096. * Converts an array of pixels to a Float32Array
  73097. * Throws an error if the pixel format is not supported
  73098. * @param pixels - array buffer containing pixel values
  73099. * @returns Float32 of pixels
  73100. */
  73101. private _convertPixelArrayToFloat32;
  73102. /**
  73103. * Convert Specular Glossiness Textures to Metallic Roughness
  73104. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  73105. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  73106. * @param diffuseTexture texture used to store diffuse information
  73107. * @param specularGlossinessTexture texture used to store specular and glossiness information
  73108. * @param factors specular glossiness material factors
  73109. * @param mimeType the mime type to use for the texture
  73110. * @returns pbr metallic roughness interface or null
  73111. */
  73112. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  73113. /**
  73114. * Converts specular glossiness material properties to metallic roughness
  73115. * @param specularGlossiness interface with specular glossiness material properties
  73116. * @returns interface with metallic roughness material properties
  73117. */
  73118. private _convertSpecularGlossinessToMetallicRoughness;
  73119. /**
  73120. * Calculates the surface reflectance, independent of lighting conditions
  73121. * @param color Color source to calculate brightness from
  73122. * @returns number representing the perceived brightness, or zero if color is undefined
  73123. */
  73124. private _getPerceivedBrightness;
  73125. /**
  73126. * Returns the maximum color component value
  73127. * @param color
  73128. * @returns maximum color component value, or zero if color is null or undefined
  73129. */
  73130. private _getMaxComponent;
  73131. /**
  73132. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  73133. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73134. * @param mimeType mime type to use for the textures
  73135. * @param images array of glTF image interfaces
  73136. * @param textures array of glTF texture interfaces
  73137. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  73138. * @param imageData map of image file name to data
  73139. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73140. * @returns glTF PBR Metallic Roughness factors
  73141. */
  73142. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  73143. private _getGLTFTextureSampler;
  73144. private _getGLTFTextureWrapMode;
  73145. private _getGLTFTextureWrapModesSampler;
  73146. /**
  73147. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  73148. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73149. * @param mimeType mime type to use for the textures
  73150. * @param images array of glTF image interfaces
  73151. * @param textures array of glTF texture interfaces
  73152. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  73153. * @param imageData map of image file name to data
  73154. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73155. * @returns glTF PBR Metallic Roughness factors
  73156. */
  73157. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  73158. /**
  73159. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  73160. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  73161. * @param mimeType mime type to use for the textures
  73162. * @param images array of glTF image interfaces
  73163. * @param textures array of glTF texture interfaces
  73164. * @param materials array of glTF material interfaces
  73165. * @param imageData map of image file name to data
  73166. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  73167. */
  73168. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  73169. private setMetallicRoughnessPbrMaterial;
  73170. private getPixelsFromTexture;
  73171. /**
  73172. * Extracts a texture from a Babylon texture into file data and glTF data
  73173. * @param babylonTexture Babylon texture to extract
  73174. * @param mimeType Mime Type of the babylonTexture
  73175. * @return glTF texture info, or null if the texture format is not supported
  73176. */
  73177. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  73178. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  73179. /**
  73180. * Builds a texture from base64 string
  73181. * @param base64Texture base64 texture string
  73182. * @param baseTextureName Name to use for the texture
  73183. * @param mimeType image mime type for the texture
  73184. * @param images array of images
  73185. * @param textures array of textures
  73186. * @param imageData map of image data
  73187. * @returns glTF texture info, or null if the texture format is not supported
  73188. */
  73189. private _getTextureInfoFromBase64;
  73190. }
  73191. }
  73192. declare module BABYLON {
  73193. /**
  73194. * Class for holding and downloading glTF file data
  73195. */
  73196. export class GLTFData {
  73197. /**
  73198. * Object which contains the file name as the key and its data as the value
  73199. */
  73200. glTFFiles: {
  73201. [fileName: string]: string | Blob;
  73202. };
  73203. /**
  73204. * Initializes the glTF file object
  73205. */
  73206. constructor();
  73207. /**
  73208. * Downloads the glTF data as files based on their names and data
  73209. */
  73210. downloadFiles(): void;
  73211. }
  73212. }
  73213. declare module BABYLON {
  73214. /**
  73215. * Holds a collection of exporter options and parameters
  73216. */
  73217. export interface IExportOptions {
  73218. /**
  73219. * Function which indicates whether a babylon node should be exported or not
  73220. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  73221. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  73222. */
  73223. shouldExportNode?(node: Node): boolean;
  73224. /**
  73225. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  73226. * @param metadata source metadata to read from
  73227. * @returns the data to store to glTF node extras
  73228. */
  73229. metadataSelector?(metadata: any): any;
  73230. /**
  73231. * The sample rate to bake animation curves
  73232. */
  73233. animationSampleRate?: number;
  73234. /**
  73235. * Begin serialization without waiting for the scene to be ready
  73236. */
  73237. exportWithoutWaitingForScene?: boolean;
  73238. }
  73239. /**
  73240. * Class for generating glTF data from a Babylon scene.
  73241. */
  73242. export class GLTF2Export {
  73243. /**
  73244. * Exports the geometry of the scene to .gltf file format asynchronously
  73245. * @param scene Babylon scene with scene hierarchy information
  73246. * @param filePrefix File prefix to use when generating the glTF file
  73247. * @param options Exporter options
  73248. * @returns Returns an object with a .gltf file and associates texture names
  73249. * as keys and their data and paths as values
  73250. */
  73251. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  73252. private static _PreExportAsync;
  73253. private static _PostExportAsync;
  73254. /**
  73255. * Exports the geometry of the scene to .glb file format asychronously
  73256. * @param scene Babylon scene with scene hierarchy information
  73257. * @param filePrefix File prefix to use when generating glb file
  73258. * @param options Exporter options
  73259. * @returns Returns an object with a .glb filename as key and data as value
  73260. */
  73261. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  73262. }
  73263. }
  73264. declare module BABYLON.GLTF2.Exporter {
  73265. /**
  73266. * @hidden
  73267. */
  73268. export class _GLTFUtilities {
  73269. /**
  73270. * Creates a buffer view based on the supplied arguments
  73271. * @param bufferIndex index value of the specified buffer
  73272. * @param byteOffset byte offset value
  73273. * @param byteLength byte length of the bufferView
  73274. * @param byteStride byte distance between conequential elements
  73275. * @param name name of the buffer view
  73276. * @returns bufferView for glTF
  73277. */
  73278. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  73279. /**
  73280. * Creates an accessor based on the supplied arguments
  73281. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  73282. * @param name The name of the accessor
  73283. * @param type The type of the accessor
  73284. * @param componentType The datatype of components in the attribute
  73285. * @param count The number of attributes referenced by this accessor
  73286. * @param byteOffset The offset relative to the start of the bufferView in bytes
  73287. * @param min Minimum value of each component in this attribute
  73288. * @param max Maximum value of each component in this attribute
  73289. * @returns accessor for glTF
  73290. */
  73291. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  73292. /**
  73293. * Calculates the minimum and maximum values of an array of position floats
  73294. * @param positions Positions array of a mesh
  73295. * @param vertexStart Starting vertex offset to calculate min and max values
  73296. * @param vertexCount Number of vertices to check for min and max values
  73297. * @returns min number array and max number array
  73298. */
  73299. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  73300. min: number[];
  73301. max: number[];
  73302. };
  73303. /**
  73304. * Converts a new right-handed Vector3
  73305. * @param vector vector3 array
  73306. * @returns right-handed Vector3
  73307. */
  73308. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  73309. /**
  73310. * Converts a Vector3 to right-handed
  73311. * @param vector Vector3 to convert to right-handed
  73312. */
  73313. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  73314. /**
  73315. * Converts a three element number array to right-handed
  73316. * @param vector number array to convert to right-handed
  73317. */
  73318. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  73319. /**
  73320. * Converts a new right-handed Vector3
  73321. * @param vector vector3 array
  73322. * @returns right-handed Vector3
  73323. */
  73324. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  73325. /**
  73326. * Converts a Vector3 to right-handed
  73327. * @param vector Vector3 to convert to right-handed
  73328. */
  73329. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  73330. /**
  73331. * Converts a three element number array to right-handed
  73332. * @param vector number array to convert to right-handed
  73333. */
  73334. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  73335. /**
  73336. * Converts a Vector4 to right-handed
  73337. * @param vector Vector4 to convert to right-handed
  73338. */
  73339. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  73340. /**
  73341. * Converts a Vector4 to right-handed
  73342. * @param vector Vector4 to convert to right-handed
  73343. */
  73344. static _GetRightHandedArray4FromRef(vector: number[]): void;
  73345. /**
  73346. * Converts a Quaternion to right-handed
  73347. * @param quaternion Source quaternion to convert to right-handed
  73348. */
  73349. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  73350. /**
  73351. * Converts a Quaternion to right-handed
  73352. * @param quaternion Source quaternion to convert to right-handed
  73353. */
  73354. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  73355. static _NormalizeTangentFromRef(tangent: Vector4): void;
  73356. }
  73357. }
  73358. declare module BABYLON.GLTF2.Exporter {
  73359. /**
  73360. * Converts Babylon Scene into glTF 2.0.
  73361. * @hidden
  73362. */
  73363. export class _Exporter {
  73364. /**
  73365. * Stores the glTF to export
  73366. */
  73367. _glTF: IGLTF;
  73368. /**
  73369. * Stores all generated buffer views, which represents views into the main glTF buffer data
  73370. */
  73371. _bufferViews: IBufferView[];
  73372. /**
  73373. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  73374. */
  73375. _accessors: IAccessor[];
  73376. /**
  73377. * Stores all the generated nodes, which contains transform and/or mesh information per node
  73378. */
  73379. private _nodes;
  73380. /**
  73381. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  73382. */
  73383. private _scenes;
  73384. /**
  73385. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  73386. */
  73387. private _meshes;
  73388. /**
  73389. * Stores all the generated material information, which represents the appearance of each primitive
  73390. */
  73391. _materials: IMaterial[];
  73392. _materialMap: {
  73393. [materialID: number]: number;
  73394. };
  73395. /**
  73396. * Stores all the generated texture information, which is referenced by glTF materials
  73397. */
  73398. _textures: ITexture[];
  73399. /**
  73400. * Stores all the generated image information, which is referenced by glTF textures
  73401. */
  73402. _images: IImage[];
  73403. /**
  73404. * Stores all the texture samplers
  73405. */
  73406. _samplers: ISampler[];
  73407. /**
  73408. * Stores all the generated animation samplers, which is referenced by glTF animations
  73409. */
  73410. /**
  73411. * Stores the animations for glTF models
  73412. */
  73413. private _animations;
  73414. /**
  73415. * Stores the total amount of bytes stored in the glTF buffer
  73416. */
  73417. private _totalByteLength;
  73418. /**
  73419. * Stores a reference to the Babylon scene containing the source geometry and material information
  73420. */
  73421. _babylonScene: Scene;
  73422. /**
  73423. * Stores a map of the image data, where the key is the file name and the value
  73424. * is the image data
  73425. */
  73426. _imageData: {
  73427. [fileName: string]: {
  73428. data: Uint8Array;
  73429. mimeType: ImageMimeType;
  73430. };
  73431. };
  73432. /**
  73433. * Stores a map of the unique id of a node to its index in the node array
  73434. */
  73435. private _nodeMap;
  73436. /**
  73437. * Specifies if the Babylon scene should be converted to right-handed on export
  73438. */
  73439. _convertToRightHandedSystem: boolean;
  73440. /**
  73441. * Baked animation sample rate
  73442. */
  73443. private _animationSampleRate;
  73444. private _options;
  73445. private _localEngine;
  73446. _glTFMaterialExporter: _GLTFMaterialExporter;
  73447. private _extensions;
  73448. private static _ExtensionNames;
  73449. private static _ExtensionFactories;
  73450. private _applyExtension;
  73451. private _applyExtensions;
  73452. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  73453. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  73454. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  73455. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  73456. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  73457. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  73458. private _forEachExtensions;
  73459. private _extensionsOnExporting;
  73460. /**
  73461. * Load glTF serializer extensions
  73462. */
  73463. private _loadExtensions;
  73464. /**
  73465. * Creates a glTF Exporter instance, which can accept optional exporter options
  73466. * @param babylonScene Babylon scene object
  73467. * @param options Options to modify the behavior of the exporter
  73468. */
  73469. constructor(babylonScene: Scene, options?: IExportOptions);
  73470. dispose(): void;
  73471. /**
  73472. * Registers a glTF exporter extension
  73473. * @param name Name of the extension to export
  73474. * @param factory The factory function that creates the exporter extension
  73475. */
  73476. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  73477. /**
  73478. * Un-registers an exporter extension
  73479. * @param name The name fo the exporter extension
  73480. * @returns A boolean indicating whether the extension has been un-registered
  73481. */
  73482. static UnregisterExtension(name: string): boolean;
  73483. /**
  73484. * Lazy load a local engine with premultiplied alpha set to false
  73485. */
  73486. _getLocalEngine(): Engine;
  73487. private reorderIndicesBasedOnPrimitiveMode;
  73488. /**
  73489. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  73490. * clock-wise during export to glTF
  73491. * @param submesh BabylonJS submesh
  73492. * @param primitiveMode Primitive mode of the mesh
  73493. * @param sideOrientation the winding order of the submesh
  73494. * @param vertexBufferKind The type of vertex attribute
  73495. * @param meshAttributeArray The vertex attribute data
  73496. * @param byteOffset The offset to the binary data
  73497. * @param binaryWriter The binary data for the glTF file
  73498. */
  73499. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  73500. /**
  73501. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  73502. * clock-wise during export to glTF
  73503. * @param submesh BabylonJS submesh
  73504. * @param primitiveMode Primitive mode of the mesh
  73505. * @param sideOrientation the winding order of the submesh
  73506. * @param vertexBufferKind The type of vertex attribute
  73507. * @param meshAttributeArray The vertex attribute data
  73508. * @param byteOffset The offset to the binary data
  73509. * @param binaryWriter The binary data for the glTF file
  73510. */
  73511. private reorderTriangleFillMode;
  73512. /**
  73513. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  73514. * clock-wise during export to glTF
  73515. * @param submesh BabylonJS submesh
  73516. * @param primitiveMode Primitive mode of the mesh
  73517. * @param sideOrientation the winding order of the submesh
  73518. * @param vertexBufferKind The type of vertex attribute
  73519. * @param meshAttributeArray The vertex attribute data
  73520. * @param byteOffset The offset to the binary data
  73521. * @param binaryWriter The binary data for the glTF file
  73522. */
  73523. private reorderTriangleStripDrawMode;
  73524. /**
  73525. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  73526. * clock-wise during export to glTF
  73527. * @param submesh BabylonJS submesh
  73528. * @param primitiveMode Primitive mode of the mesh
  73529. * @param sideOrientation the winding order of the submesh
  73530. * @param vertexBufferKind The type of vertex attribute
  73531. * @param meshAttributeArray The vertex attribute data
  73532. * @param byteOffset The offset to the binary data
  73533. * @param binaryWriter The binary data for the glTF file
  73534. */
  73535. private reorderTriangleFanMode;
  73536. /**
  73537. * Writes the vertex attribute data to binary
  73538. * @param vertices The vertices to write to the binary writer
  73539. * @param byteOffset The offset into the binary writer to overwrite binary data
  73540. * @param vertexAttributeKind The vertex attribute type
  73541. * @param meshAttributeArray The vertex attribute data
  73542. * @param binaryWriter The writer containing the binary data
  73543. */
  73544. private writeVertexAttributeData;
  73545. /**
  73546. * Writes mesh attribute data to a data buffer
  73547. * Returns the bytelength of the data
  73548. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  73549. * @param meshAttributeArray Array containing the attribute data
  73550. * @param binaryWriter The buffer to write the binary data to
  73551. * @param indices Used to specify the order of the vertex data
  73552. */
  73553. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  73554. /**
  73555. * Generates glTF json data
  73556. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  73557. * @param glTFPrefix Text to use when prefixing a glTF file
  73558. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  73559. * @returns json data as string
  73560. */
  73561. private generateJSON;
  73562. /**
  73563. * Generates data for .gltf and .bin files based on the glTF prefix string
  73564. * @param glTFPrefix Text to use when prefixing a glTF file
  73565. * @param dispose Dispose the exporter
  73566. * @returns GLTFData with glTF file data
  73567. */
  73568. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  73569. /**
  73570. * Creates a binary buffer for glTF
  73571. * @returns array buffer for binary data
  73572. */
  73573. private _generateBinaryAsync;
  73574. /**
  73575. * Pads the number to a multiple of 4
  73576. * @param num number to pad
  73577. * @returns padded number
  73578. */
  73579. private _getPadding;
  73580. /**
  73581. * @hidden
  73582. */
  73583. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  73584. /**
  73585. * Sets the TRS for each node
  73586. * @param node glTF Node for storing the transformation data
  73587. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  73588. */
  73589. private setNodeTransformation;
  73590. private getVertexBufferFromMesh;
  73591. /**
  73592. * Creates a bufferview based on the vertices type for the Babylon mesh
  73593. * @param kind Indicates the type of vertices data
  73594. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  73595. * @param binaryWriter The buffer to write the bufferview data to
  73596. */
  73597. private createBufferViewKind;
  73598. /**
  73599. * The primitive mode of the Babylon mesh
  73600. * @param babylonMesh The BabylonJS mesh
  73601. */
  73602. private getMeshPrimitiveMode;
  73603. /**
  73604. * Sets the primitive mode of the glTF mesh primitive
  73605. * @param meshPrimitive glTF mesh primitive
  73606. * @param primitiveMode The primitive mode
  73607. */
  73608. private setPrimitiveMode;
  73609. /**
  73610. * Sets the vertex attribute accessor based of the glTF mesh primitive
  73611. * @param meshPrimitive glTF mesh primitive
  73612. * @param attributeKind vertex attribute
  73613. * @returns boolean specifying if uv coordinates are present
  73614. */
  73615. private setAttributeKind;
  73616. /**
  73617. * Sets data for the primitive attributes of each submesh
  73618. * @param mesh glTF Mesh object to store the primitive attribute information
  73619. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  73620. * @param binaryWriter Buffer to write the attribute data to
  73621. */
  73622. private setPrimitiveAttributesAsync;
  73623. /**
  73624. * Creates a glTF scene based on the array of meshes
  73625. * Returns the the total byte offset
  73626. * @param babylonScene Babylon scene to get the mesh data from
  73627. * @param binaryWriter Buffer to write binary data to
  73628. */
  73629. private createSceneAsync;
  73630. /**
  73631. * Creates a mapping of Node unique id to node index and handles animations
  73632. * @param babylonScene Babylon Scene
  73633. * @param nodes Babylon transform nodes
  73634. * @param binaryWriter Buffer to write binary data to
  73635. * @returns Node mapping of unique id to index
  73636. */
  73637. private createNodeMapAndAnimationsAsync;
  73638. /**
  73639. * Creates a glTF node from a Babylon mesh
  73640. * @param babylonMesh Source Babylon mesh
  73641. * @param binaryWriter Buffer for storing geometry data
  73642. * @returns glTF node
  73643. */
  73644. private createNodeAsync;
  73645. }
  73646. /**
  73647. * @hidden
  73648. *
  73649. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  73650. */
  73651. export class _BinaryWriter {
  73652. /**
  73653. * Array buffer which stores all binary data
  73654. */
  73655. private _arrayBuffer;
  73656. /**
  73657. * View of the array buffer
  73658. */
  73659. private _dataView;
  73660. /**
  73661. * byte offset of data in array buffer
  73662. */
  73663. private _byteOffset;
  73664. /**
  73665. * Initialize binary writer with an initial byte length
  73666. * @param byteLength Initial byte length of the array buffer
  73667. */
  73668. constructor(byteLength: number);
  73669. /**
  73670. * Resize the array buffer to the specified byte length
  73671. * @param byteLength
  73672. */
  73673. private resizeBuffer;
  73674. /**
  73675. * Get an array buffer with the length of the byte offset
  73676. * @returns ArrayBuffer resized to the byte offset
  73677. */
  73678. getArrayBuffer(): ArrayBuffer;
  73679. /**
  73680. * Get the byte offset of the array buffer
  73681. * @returns byte offset
  73682. */
  73683. getByteOffset(): number;
  73684. /**
  73685. * Stores an UInt8 in the array buffer
  73686. * @param entry
  73687. * @param byteOffset If defined, specifies where to set the value as an offset.
  73688. */
  73689. setUInt8(entry: number, byteOffset?: number): void;
  73690. /**
  73691. * Gets an UInt32 in the array buffer
  73692. * @param entry
  73693. * @param byteOffset If defined, specifies where to set the value as an offset.
  73694. */
  73695. getUInt32(byteOffset: number): number;
  73696. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  73697. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  73698. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  73699. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  73700. /**
  73701. * Stores a Float32 in the array buffer
  73702. * @param entry
  73703. */
  73704. setFloat32(entry: number, byteOffset?: number): void;
  73705. /**
  73706. * Stores an UInt32 in the array buffer
  73707. * @param entry
  73708. * @param byteOffset If defined, specifies where to set the value as an offset.
  73709. */
  73710. setUInt32(entry: number, byteOffset?: number): void;
  73711. }
  73712. }
  73713. declare module BABYLON.GLTF2.Exporter {
  73714. /**
  73715. * @hidden
  73716. * Interface to store animation data.
  73717. */
  73718. export interface _IAnimationData {
  73719. /**
  73720. * Keyframe data.
  73721. */
  73722. inputs: number[];
  73723. /**
  73724. * Value data.
  73725. */
  73726. outputs: number[][];
  73727. /**
  73728. * Animation interpolation data.
  73729. */
  73730. samplerInterpolation: AnimationSamplerInterpolation;
  73731. /**
  73732. * Minimum keyframe value.
  73733. */
  73734. inputsMin: number;
  73735. /**
  73736. * Maximum keyframe value.
  73737. */
  73738. inputsMax: number;
  73739. }
  73740. /**
  73741. * @hidden
  73742. */
  73743. export interface _IAnimationInfo {
  73744. /**
  73745. * The target channel for the animation
  73746. */
  73747. animationChannelTargetPath: AnimationChannelTargetPath;
  73748. /**
  73749. * The glTF accessor type for the data.
  73750. */
  73751. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  73752. /**
  73753. * Specifies if quaternions should be used.
  73754. */
  73755. useQuaternion: boolean;
  73756. }
  73757. /**
  73758. * @hidden
  73759. * Utility class for generating glTF animation data from BabylonJS.
  73760. */
  73761. export class _GLTFAnimation {
  73762. /**
  73763. * @ignore
  73764. *
  73765. * Creates glTF channel animation from BabylonJS animation.
  73766. * @param babylonTransformNode - BabylonJS mesh.
  73767. * @param animation - animation.
  73768. * @param animationChannelTargetPath - The target animation channel.
  73769. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  73770. * @param useQuaternion - Specifies if quaternions are used.
  73771. * @returns nullable IAnimationData
  73772. */
  73773. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  73774. private static _DeduceAnimationInfo;
  73775. /**
  73776. * @ignore
  73777. * Create node animations from the transform node animations
  73778. * @param babylonNode
  73779. * @param runtimeGLTFAnimation
  73780. * @param idleGLTFAnimations
  73781. * @param nodeMap
  73782. * @param nodes
  73783. * @param binaryWriter
  73784. * @param bufferViews
  73785. * @param accessors
  73786. * @param convertToRightHandedSystem
  73787. */
  73788. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  73789. [key: number]: number;
  73790. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  73791. /**
  73792. * @ignore
  73793. * Create node animations from the animation groups
  73794. * @param babylonScene
  73795. * @param glTFAnimations
  73796. * @param nodeMap
  73797. * @param nodes
  73798. * @param binaryWriter
  73799. * @param bufferViews
  73800. * @param accessors
  73801. * @param convertToRightHandedSystem
  73802. */
  73803. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  73804. [key: number]: number;
  73805. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  73806. private static AddAnimation;
  73807. /**
  73808. * Create a baked animation
  73809. * @param babylonTransformNode BabylonJS mesh
  73810. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  73811. * @param animationChannelTargetPath animation target channel
  73812. * @param minFrame minimum animation frame
  73813. * @param maxFrame maximum animation frame
  73814. * @param fps frames per second of the animation
  73815. * @param inputs input key frames of the animation
  73816. * @param outputs output key frame data of the animation
  73817. * @param convertToRightHandedSystem converts the values to right-handed
  73818. * @param useQuaternion specifies if quaternions should be used
  73819. */
  73820. private static _CreateBakedAnimation;
  73821. private static _ConvertFactorToVector3OrQuaternion;
  73822. private static _SetInterpolatedValue;
  73823. /**
  73824. * Creates linear animation from the animation key frames
  73825. * @param babylonTransformNode BabylonJS mesh
  73826. * @param animation BabylonJS animation
  73827. * @param animationChannelTargetPath The target animation channel
  73828. * @param frameDelta The difference between the last and first frame of the animation
  73829. * @param inputs Array to store the key frame times
  73830. * @param outputs Array to store the key frame data
  73831. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  73832. * @param useQuaternion Specifies if quaternions are used in the animation
  73833. */
  73834. private static _CreateLinearOrStepAnimation;
  73835. /**
  73836. * Creates cubic spline animation from the animation key frames
  73837. * @param babylonTransformNode BabylonJS mesh
  73838. * @param animation BabylonJS animation
  73839. * @param animationChannelTargetPath The target animation channel
  73840. * @param frameDelta The difference between the last and first frame of the animation
  73841. * @param inputs Array to store the key frame times
  73842. * @param outputs Array to store the key frame data
  73843. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  73844. * @param useQuaternion Specifies if quaternions are used in the animation
  73845. */
  73846. private static _CreateCubicSplineAnimation;
  73847. private static _GetBasePositionRotationOrScale;
  73848. /**
  73849. * Adds a key frame value
  73850. * @param keyFrame
  73851. * @param animation
  73852. * @param outputs
  73853. * @param animationChannelTargetPath
  73854. * @param basePositionRotationOrScale
  73855. * @param convertToRightHandedSystem
  73856. * @param useQuaternion
  73857. */
  73858. private static _AddKeyframeValue;
  73859. /**
  73860. * Determine the interpolation based on the key frames
  73861. * @param keyFrames
  73862. * @param animationChannelTargetPath
  73863. * @param useQuaternion
  73864. */
  73865. private static _DeduceInterpolation;
  73866. /**
  73867. * Adds an input tangent or output tangent to the output data
  73868. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  73869. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  73870. * @param outputs The animation data by keyframe
  73871. * @param animationChannelTargetPath The target animation channel
  73872. * @param interpolation The interpolation type
  73873. * @param keyFrame The key frame with the animation data
  73874. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  73875. * @param useQuaternion Specifies if quaternions are used
  73876. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  73877. */
  73878. private static AddSplineTangent;
  73879. /**
  73880. * Get the minimum and maximum key frames' frame values
  73881. * @param keyFrames animation key frames
  73882. * @returns the minimum and maximum key frame value
  73883. */
  73884. private static calculateMinMaxKeyFrames;
  73885. }
  73886. }
  73887. declare module BABYLON.GLTF2.Exporter {
  73888. /** @hidden */
  73889. export var textureTransformPixelShader: {
  73890. name: string;
  73891. shader: string;
  73892. };
  73893. }
  73894. declare module BABYLON.GLTF2.Exporter.Extensions {
  73895. /**
  73896. * @hidden
  73897. */
  73898. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  73899. private _recordedTextures;
  73900. /** Name of this extension */
  73901. readonly name: string;
  73902. /** Defines whether this extension is enabled */
  73903. enabled: boolean;
  73904. /** Defines whether this extension is required */
  73905. required: boolean;
  73906. /** Reference to the glTF exporter */
  73907. private _wasUsed;
  73908. constructor(exporter: _Exporter);
  73909. dispose(): void;
  73910. /** @hidden */
  73911. readonly wasUsed: boolean;
  73912. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  73913. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  73914. /**
  73915. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  73916. * @param babylonTexture
  73917. * @param offset
  73918. * @param rotation
  73919. * @param scale
  73920. * @param scene
  73921. */
  73922. private _textureTransformTextureAsync;
  73923. }
  73924. }
  73925. declare module BABYLON.GLTF2.Exporter.Extensions {
  73926. /**
  73927. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  73928. */
  73929. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  73930. /** The name of this extension. */
  73931. readonly name: string;
  73932. /** Defines whether this extension is enabled. */
  73933. enabled: boolean;
  73934. /** Defines whether this extension is required */
  73935. required: boolean;
  73936. /** Reference to the glTF exporter */
  73937. private _exporter;
  73938. private _lights;
  73939. /** @hidden */
  73940. constructor(exporter: _Exporter);
  73941. /** @hidden */
  73942. dispose(): void;
  73943. /** @hidden */
  73944. readonly wasUsed: boolean;
  73945. /** @hidden */
  73946. onExporting(): void;
  73947. /**
  73948. * Define this method to modify the default behavior when exporting a node
  73949. * @param context The context when exporting the node
  73950. * @param node glTF node
  73951. * @param babylonNode BabylonJS node
  73952. * @returns nullable INode promise
  73953. */
  73954. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  73955. }
  73956. }
  73957. declare module BABYLON.GLTF2.Exporter.Extensions {
  73958. /**
  73959. * @hidden
  73960. */
  73961. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  73962. /** Name of this extension */
  73963. readonly name: string;
  73964. /** Defines whether this extension is enabled */
  73965. enabled: boolean;
  73966. /** Defines whether this extension is required */
  73967. required: boolean;
  73968. /** Reference to the glTF exporter */
  73969. private _textureInfos;
  73970. private _exportedTextures;
  73971. private _wasUsed;
  73972. constructor(exporter: _Exporter);
  73973. dispose(): void;
  73974. /** @hidden */
  73975. readonly wasUsed: boolean;
  73976. private _getTextureIndex;
  73977. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  73978. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  73979. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  73980. }
  73981. }
  73982. declare module BABYLON {
  73983. /**
  73984. * Class for generating STL data from a Babylon scene.
  73985. */
  73986. export class STLExport {
  73987. /**
  73988. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  73989. * @param meshes list defines the mesh to serialize
  73990. * @param download triggers the automatic download of the file.
  73991. * @param fileName changes the downloads fileName.
  73992. * @param binary changes the STL to a binary type.
  73993. * @param isLittleEndian toggle for binary type exporter.
  73994. * @returns the STL as UTF8 string
  73995. */
  73996. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  73997. }
  73998. }
  73999. declare module "babylonjs-gltf2interface" {
  74000. export = BABYLON.GLTF2;
  74001. }
  74002. /**
  74003. * Module for glTF 2.0 Interface
  74004. */
  74005. declare module BABYLON.GLTF2 {
  74006. /**
  74007. * The datatype of the components in the attribute
  74008. */
  74009. const enum AccessorComponentType {
  74010. /**
  74011. * Byte
  74012. */
  74013. BYTE = 5120,
  74014. /**
  74015. * Unsigned Byte
  74016. */
  74017. UNSIGNED_BYTE = 5121,
  74018. /**
  74019. * Short
  74020. */
  74021. SHORT = 5122,
  74022. /**
  74023. * Unsigned Short
  74024. */
  74025. UNSIGNED_SHORT = 5123,
  74026. /**
  74027. * Unsigned Int
  74028. */
  74029. UNSIGNED_INT = 5125,
  74030. /**
  74031. * Float
  74032. */
  74033. FLOAT = 5126,
  74034. }
  74035. /**
  74036. * Specifies if the attirbute is a scalar, vector, or matrix
  74037. */
  74038. const enum AccessorType {
  74039. /**
  74040. * Scalar
  74041. */
  74042. SCALAR = "SCALAR",
  74043. /**
  74044. * Vector2
  74045. */
  74046. VEC2 = "VEC2",
  74047. /**
  74048. * Vector3
  74049. */
  74050. VEC3 = "VEC3",
  74051. /**
  74052. * Vector4
  74053. */
  74054. VEC4 = "VEC4",
  74055. /**
  74056. * Matrix2x2
  74057. */
  74058. MAT2 = "MAT2",
  74059. /**
  74060. * Matrix3x3
  74061. */
  74062. MAT3 = "MAT3",
  74063. /**
  74064. * Matrix4x4
  74065. */
  74066. MAT4 = "MAT4",
  74067. }
  74068. /**
  74069. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  74070. */
  74071. const enum AnimationChannelTargetPath {
  74072. /**
  74073. * Translation
  74074. */
  74075. TRANSLATION = "translation",
  74076. /**
  74077. * Rotation
  74078. */
  74079. ROTATION = "rotation",
  74080. /**
  74081. * Scale
  74082. */
  74083. SCALE = "scale",
  74084. /**
  74085. * Weights
  74086. */
  74087. WEIGHTS = "weights",
  74088. }
  74089. /**
  74090. * Interpolation algorithm
  74091. */
  74092. const enum AnimationSamplerInterpolation {
  74093. /**
  74094. * The animated values are linearly interpolated between keyframes
  74095. */
  74096. LINEAR = "LINEAR",
  74097. /**
  74098. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  74099. */
  74100. STEP = "STEP",
  74101. /**
  74102. * The animation's interpolation is computed using a cubic spline with specified tangents
  74103. */
  74104. CUBICSPLINE = "CUBICSPLINE",
  74105. }
  74106. /**
  74107. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  74108. */
  74109. const enum CameraType {
  74110. /**
  74111. * A perspective camera containing properties to create a perspective projection matrix
  74112. */
  74113. PERSPECTIVE = "perspective",
  74114. /**
  74115. * An orthographic camera containing properties to create an orthographic projection matrix
  74116. */
  74117. ORTHOGRAPHIC = "orthographic",
  74118. }
  74119. /**
  74120. * The mime-type of the image
  74121. */
  74122. const enum ImageMimeType {
  74123. /**
  74124. * JPEG Mime-type
  74125. */
  74126. JPEG = "image/jpeg",
  74127. /**
  74128. * PNG Mime-type
  74129. */
  74130. PNG = "image/png",
  74131. }
  74132. /**
  74133. * The alpha rendering mode of the material
  74134. */
  74135. const enum MaterialAlphaMode {
  74136. /**
  74137. * The alpha value is ignored and the rendered output is fully opaque
  74138. */
  74139. OPAQUE = "OPAQUE",
  74140. /**
  74141. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  74142. */
  74143. MASK = "MASK",
  74144. /**
  74145. * 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)
  74146. */
  74147. BLEND = "BLEND",
  74148. }
  74149. /**
  74150. * The type of the primitives to render
  74151. */
  74152. const enum MeshPrimitiveMode {
  74153. /**
  74154. * Points
  74155. */
  74156. POINTS = 0,
  74157. /**
  74158. * Lines
  74159. */
  74160. LINES = 1,
  74161. /**
  74162. * Line Loop
  74163. */
  74164. LINE_LOOP = 2,
  74165. /**
  74166. * Line Strip
  74167. */
  74168. LINE_STRIP = 3,
  74169. /**
  74170. * Triangles
  74171. */
  74172. TRIANGLES = 4,
  74173. /**
  74174. * Triangle Strip
  74175. */
  74176. TRIANGLE_STRIP = 5,
  74177. /**
  74178. * Triangle Fan
  74179. */
  74180. TRIANGLE_FAN = 6,
  74181. }
  74182. /**
  74183. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  74184. */
  74185. const enum TextureMagFilter {
  74186. /**
  74187. * Nearest
  74188. */
  74189. NEAREST = 9728,
  74190. /**
  74191. * Linear
  74192. */
  74193. LINEAR = 9729,
  74194. }
  74195. /**
  74196. * Minification filter. All valid values correspond to WebGL enums
  74197. */
  74198. const enum TextureMinFilter {
  74199. /**
  74200. * Nearest
  74201. */
  74202. NEAREST = 9728,
  74203. /**
  74204. * Linear
  74205. */
  74206. LINEAR = 9729,
  74207. /**
  74208. * Nearest Mip-Map Nearest
  74209. */
  74210. NEAREST_MIPMAP_NEAREST = 9984,
  74211. /**
  74212. * Linear Mipmap Nearest
  74213. */
  74214. LINEAR_MIPMAP_NEAREST = 9985,
  74215. /**
  74216. * Nearest Mipmap Linear
  74217. */
  74218. NEAREST_MIPMAP_LINEAR = 9986,
  74219. /**
  74220. * Linear Mipmap Linear
  74221. */
  74222. LINEAR_MIPMAP_LINEAR = 9987,
  74223. }
  74224. /**
  74225. * S (U) wrapping mode. All valid values correspond to WebGL enums
  74226. */
  74227. const enum TextureWrapMode {
  74228. /**
  74229. * Clamp to Edge
  74230. */
  74231. CLAMP_TO_EDGE = 33071,
  74232. /**
  74233. * Mirrored Repeat
  74234. */
  74235. MIRRORED_REPEAT = 33648,
  74236. /**
  74237. * Repeat
  74238. */
  74239. REPEAT = 10497,
  74240. }
  74241. /**
  74242. * glTF Property
  74243. */
  74244. interface IProperty {
  74245. /**
  74246. * Dictionary object with extension-specific objects
  74247. */
  74248. extensions?: {
  74249. [key: string]: any;
  74250. };
  74251. /**
  74252. * Application-Specific data
  74253. */
  74254. extras?: any;
  74255. }
  74256. /**
  74257. * glTF Child of Root Property
  74258. */
  74259. interface IChildRootProperty extends IProperty {
  74260. /**
  74261. * The user-defined name of this object
  74262. */
  74263. name?: string;
  74264. }
  74265. /**
  74266. * Indices of those attributes that deviate from their initialization value
  74267. */
  74268. interface IAccessorSparseIndices extends IProperty {
  74269. /**
  74270. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  74271. */
  74272. bufferView: number;
  74273. /**
  74274. * The offset relative to the start of the bufferView in bytes. Must be aligned
  74275. */
  74276. byteOffset?: number;
  74277. /**
  74278. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  74279. */
  74280. componentType: AccessorComponentType;
  74281. }
  74282. /**
  74283. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  74284. */
  74285. interface IAccessorSparseValues extends IProperty {
  74286. /**
  74287. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  74288. */
  74289. bufferView: number;
  74290. /**
  74291. * The offset relative to the start of the bufferView in bytes. Must be aligned
  74292. */
  74293. byteOffset?: number;
  74294. }
  74295. /**
  74296. * Sparse storage of attributes that deviate from their initialization value
  74297. */
  74298. interface IAccessorSparse extends IProperty {
  74299. /**
  74300. * The number of attributes encoded in this sparse accessor
  74301. */
  74302. count: number;
  74303. /**
  74304. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  74305. */
  74306. indices: IAccessorSparseIndices;
  74307. /**
  74308. * 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
  74309. */
  74310. values: IAccessorSparseValues;
  74311. }
  74312. /**
  74313. * 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
  74314. */
  74315. interface IAccessor extends IChildRootProperty {
  74316. /**
  74317. * The index of the bufferview
  74318. */
  74319. bufferView?: number;
  74320. /**
  74321. * The offset relative to the start of the bufferView in bytes
  74322. */
  74323. byteOffset?: number;
  74324. /**
  74325. * The datatype of components in the attribute
  74326. */
  74327. componentType: AccessorComponentType;
  74328. /**
  74329. * Specifies whether integer data values should be normalized
  74330. */
  74331. normalized?: boolean;
  74332. /**
  74333. * The number of attributes referenced by this accessor
  74334. */
  74335. count: number;
  74336. /**
  74337. * Specifies if the attribute is a scalar, vector, or matrix
  74338. */
  74339. type: AccessorType;
  74340. /**
  74341. * Maximum value of each component in this attribute
  74342. */
  74343. max?: number[];
  74344. /**
  74345. * Minimum value of each component in this attribute
  74346. */
  74347. min?: number[];
  74348. /**
  74349. * Sparse storage of attributes that deviate from their initialization value
  74350. */
  74351. sparse?: IAccessorSparse;
  74352. }
  74353. /**
  74354. * Targets an animation's sampler at a node's property
  74355. */
  74356. interface IAnimationChannel extends IProperty {
  74357. /**
  74358. * The index of a sampler in this animation used to compute the value for the target
  74359. */
  74360. sampler: number;
  74361. /**
  74362. * The index of the node and TRS property to target
  74363. */
  74364. target: IAnimationChannelTarget;
  74365. }
  74366. /**
  74367. * The index of the node and TRS property that an animation channel targets
  74368. */
  74369. interface IAnimationChannelTarget extends IProperty {
  74370. /**
  74371. * The index of the node to target
  74372. */
  74373. node: number;
  74374. /**
  74375. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  74376. */
  74377. path: AnimationChannelTargetPath;
  74378. }
  74379. /**
  74380. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  74381. */
  74382. interface IAnimationSampler extends IProperty {
  74383. /**
  74384. * The index of an accessor containing keyframe input values, e.g., time
  74385. */
  74386. input: number;
  74387. /**
  74388. * Interpolation algorithm
  74389. */
  74390. interpolation?: AnimationSamplerInterpolation;
  74391. /**
  74392. * The index of an accessor, containing keyframe output values
  74393. */
  74394. output: number;
  74395. }
  74396. /**
  74397. * A keyframe animation
  74398. */
  74399. interface IAnimation extends IChildRootProperty {
  74400. /**
  74401. * An array of channels, each of which targets an animation's sampler at a node's property
  74402. */
  74403. channels: IAnimationChannel[];
  74404. /**
  74405. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  74406. */
  74407. samplers: IAnimationSampler[];
  74408. }
  74409. /**
  74410. * Metadata about the glTF asset
  74411. */
  74412. interface IAsset extends IChildRootProperty {
  74413. /**
  74414. * A copyright message suitable for display to credit the content creator
  74415. */
  74416. copyright?: string;
  74417. /**
  74418. * Tool that generated this glTF model. Useful for debugging
  74419. */
  74420. generator?: string;
  74421. /**
  74422. * The glTF version that this asset targets
  74423. */
  74424. version: string;
  74425. /**
  74426. * The minimum glTF version that this asset targets
  74427. */
  74428. minVersion?: string;
  74429. }
  74430. /**
  74431. * A buffer points to binary geometry, animation, or skins
  74432. */
  74433. interface IBuffer extends IChildRootProperty {
  74434. /**
  74435. * 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
  74436. */
  74437. uri?: string;
  74438. /**
  74439. * The length of the buffer in bytes
  74440. */
  74441. byteLength: number;
  74442. }
  74443. /**
  74444. * A view into a buffer generally representing a subset of the buffer
  74445. */
  74446. interface IBufferView extends IChildRootProperty {
  74447. /**
  74448. * The index of the buffer
  74449. */
  74450. buffer: number;
  74451. /**
  74452. * The offset into the buffer in bytes
  74453. */
  74454. byteOffset?: number;
  74455. /**
  74456. * The lenth of the bufferView in bytes
  74457. */
  74458. byteLength: number;
  74459. /**
  74460. * The stride, in bytes
  74461. */
  74462. byteStride?: number;
  74463. }
  74464. /**
  74465. * An orthographic camera containing properties to create an orthographic projection matrix
  74466. */
  74467. interface ICameraOrthographic extends IProperty {
  74468. /**
  74469. * The floating-point horizontal magnification of the view. Must not be zero
  74470. */
  74471. xmag: number;
  74472. /**
  74473. * The floating-point vertical magnification of the view. Must not be zero
  74474. */
  74475. ymag: number;
  74476. /**
  74477. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  74478. */
  74479. zfar: number;
  74480. /**
  74481. * The floating-point distance to the near clipping plane
  74482. */
  74483. znear: number;
  74484. }
  74485. /**
  74486. * A perspective camera containing properties to create a perspective projection matrix
  74487. */
  74488. interface ICameraPerspective extends IProperty {
  74489. /**
  74490. * The floating-point aspect ratio of the field of view
  74491. */
  74492. aspectRatio?: number;
  74493. /**
  74494. * The floating-point vertical field of view in radians
  74495. */
  74496. yfov: number;
  74497. /**
  74498. * The floating-point distance to the far clipping plane
  74499. */
  74500. zfar?: number;
  74501. /**
  74502. * The floating-point distance to the near clipping plane
  74503. */
  74504. znear: number;
  74505. }
  74506. /**
  74507. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  74508. */
  74509. interface ICamera extends IChildRootProperty {
  74510. /**
  74511. * An orthographic camera containing properties to create an orthographic projection matrix
  74512. */
  74513. orthographic?: ICameraOrthographic;
  74514. /**
  74515. * A perspective camera containing properties to create a perspective projection matrix
  74516. */
  74517. perspective?: ICameraPerspective;
  74518. /**
  74519. * Specifies if the camera uses a perspective or orthographic projection
  74520. */
  74521. type: CameraType;
  74522. }
  74523. /**
  74524. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  74525. */
  74526. interface IImage extends IChildRootProperty {
  74527. /**
  74528. * 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
  74529. */
  74530. uri?: string;
  74531. /**
  74532. * The image's MIME type
  74533. */
  74534. mimeType?: ImageMimeType;
  74535. /**
  74536. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  74537. */
  74538. bufferView?: number;
  74539. }
  74540. /**
  74541. * Material Normal Texture Info
  74542. */
  74543. interface IMaterialNormalTextureInfo extends ITextureInfo {
  74544. /**
  74545. * The scalar multiplier applied to each normal vector of the normal texture
  74546. */
  74547. scale?: number;
  74548. }
  74549. /**
  74550. * Material Occlusion Texture Info
  74551. */
  74552. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  74553. /**
  74554. * A scalar multiplier controlling the amount of occlusion applied
  74555. */
  74556. strength?: number;
  74557. }
  74558. /**
  74559. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  74560. */
  74561. interface IMaterialPbrMetallicRoughness {
  74562. /**
  74563. * The material's base color factor
  74564. */
  74565. baseColorFactor?: number[];
  74566. /**
  74567. * The base color texture
  74568. */
  74569. baseColorTexture?: ITextureInfo;
  74570. /**
  74571. * The metalness of the material
  74572. */
  74573. metallicFactor?: number;
  74574. /**
  74575. * The roughness of the material
  74576. */
  74577. roughnessFactor?: number;
  74578. /**
  74579. * The metallic-roughness texture
  74580. */
  74581. metallicRoughnessTexture?: ITextureInfo;
  74582. }
  74583. /**
  74584. * The material appearance of a primitive
  74585. */
  74586. interface IMaterial extends IChildRootProperty {
  74587. /**
  74588. * 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
  74589. */
  74590. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  74591. /**
  74592. * The normal map texture
  74593. */
  74594. normalTexture?: IMaterialNormalTextureInfo;
  74595. /**
  74596. * The occlusion map texture
  74597. */
  74598. occlusionTexture?: IMaterialOcclusionTextureInfo;
  74599. /**
  74600. * The emissive map texture
  74601. */
  74602. emissiveTexture?: ITextureInfo;
  74603. /**
  74604. * 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
  74605. */
  74606. emissiveFactor?: number[];
  74607. /**
  74608. * The alpha rendering mode of the material
  74609. */
  74610. alphaMode?: MaterialAlphaMode;
  74611. /**
  74612. * The alpha cutoff value of the material
  74613. */
  74614. alphaCutoff?: number;
  74615. /**
  74616. * Specifies whether the material is double sided
  74617. */
  74618. doubleSided?: boolean;
  74619. }
  74620. /**
  74621. * Geometry to be rendered with the given material
  74622. */
  74623. interface IMeshPrimitive extends IProperty {
  74624. /**
  74625. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  74626. */
  74627. attributes: {
  74628. [name: string]: number;
  74629. };
  74630. /**
  74631. * The index of the accessor that contains the indices
  74632. */
  74633. indices?: number;
  74634. /**
  74635. * The index of the material to apply to this primitive when rendering
  74636. */
  74637. material?: number;
  74638. /**
  74639. * The type of primitives to render. All valid values correspond to WebGL enums
  74640. */
  74641. mode?: MeshPrimitiveMode;
  74642. /**
  74643. * 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
  74644. */
  74645. targets?: {
  74646. [name: string]: number;
  74647. }[];
  74648. }
  74649. /**
  74650. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  74651. */
  74652. interface IMesh extends IChildRootProperty {
  74653. /**
  74654. * An array of primitives, each defining geometry to be rendered with a material
  74655. */
  74656. primitives: IMeshPrimitive[];
  74657. /**
  74658. * Array of weights to be applied to the Morph Targets
  74659. */
  74660. weights?: number[];
  74661. }
  74662. /**
  74663. * A node in the node hierarchy
  74664. */
  74665. interface INode extends IChildRootProperty {
  74666. /**
  74667. * The index of the camera referenced by this node
  74668. */
  74669. camera?: number;
  74670. /**
  74671. * The indices of this node's children
  74672. */
  74673. children?: number[];
  74674. /**
  74675. * The index of the skin referenced by this node
  74676. */
  74677. skin?: number;
  74678. /**
  74679. * A floating-point 4x4 transformation matrix stored in column-major order
  74680. */
  74681. matrix?: number[];
  74682. /**
  74683. * The index of the mesh in this node
  74684. */
  74685. mesh?: number;
  74686. /**
  74687. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  74688. */
  74689. rotation?: number[];
  74690. /**
  74691. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  74692. */
  74693. scale?: number[];
  74694. /**
  74695. * The node's translation along the x, y, and z axes
  74696. */
  74697. translation?: number[];
  74698. /**
  74699. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  74700. */
  74701. weights?: number[];
  74702. }
  74703. /**
  74704. * Texture sampler properties for filtering and wrapping modes
  74705. */
  74706. interface ISampler extends IChildRootProperty {
  74707. /**
  74708. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  74709. */
  74710. magFilter?: TextureMagFilter;
  74711. /**
  74712. * Minification filter. All valid values correspond to WebGL enums
  74713. */
  74714. minFilter?: TextureMinFilter;
  74715. /**
  74716. * S (U) wrapping mode. All valid values correspond to WebGL enums
  74717. */
  74718. wrapS?: TextureWrapMode;
  74719. /**
  74720. * T (V) wrapping mode. All valid values correspond to WebGL enums
  74721. */
  74722. wrapT?: TextureWrapMode;
  74723. }
  74724. /**
  74725. * The root nodes of a scene
  74726. */
  74727. interface IScene extends IChildRootProperty {
  74728. /**
  74729. * The indices of each root node
  74730. */
  74731. nodes: number[];
  74732. }
  74733. /**
  74734. * Joints and matrices defining a skin
  74735. */
  74736. interface ISkin extends IChildRootProperty {
  74737. /**
  74738. * 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
  74739. */
  74740. inverseBindMatrices?: number;
  74741. /**
  74742. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  74743. */
  74744. skeleton?: number;
  74745. /**
  74746. * 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)
  74747. */
  74748. joints: number[];
  74749. }
  74750. /**
  74751. * A texture and its sampler
  74752. */
  74753. interface ITexture extends IChildRootProperty {
  74754. /**
  74755. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  74756. */
  74757. sampler?: number;
  74758. /**
  74759. * The index of the image used by this texture
  74760. */
  74761. source: number;
  74762. }
  74763. /**
  74764. * Reference to a texture
  74765. */
  74766. interface ITextureInfo extends IProperty {
  74767. /**
  74768. * The index of the texture
  74769. */
  74770. index: number;
  74771. /**
  74772. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  74773. */
  74774. texCoord?: number;
  74775. }
  74776. /**
  74777. * The root object for a glTF asset
  74778. */
  74779. interface IGLTF extends IProperty {
  74780. /**
  74781. * An array of accessors. An accessor is a typed view into a bufferView
  74782. */
  74783. accessors?: IAccessor[];
  74784. /**
  74785. * An array of keyframe animations
  74786. */
  74787. animations?: IAnimation[];
  74788. /**
  74789. * Metadata about the glTF asset
  74790. */
  74791. asset: IAsset;
  74792. /**
  74793. * An array of buffers. A buffer points to binary geometry, animation, or skins
  74794. */
  74795. buffers?: IBuffer[];
  74796. /**
  74797. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  74798. */
  74799. bufferViews?: IBufferView[];
  74800. /**
  74801. * An array of cameras
  74802. */
  74803. cameras?: ICamera[];
  74804. /**
  74805. * Names of glTF extensions used somewhere in this asset
  74806. */
  74807. extensionsUsed?: string[];
  74808. /**
  74809. * Names of glTF extensions required to properly load this asset
  74810. */
  74811. extensionsRequired?: string[];
  74812. /**
  74813. * An array of images. An image defines data used to create a texture
  74814. */
  74815. images?: IImage[];
  74816. /**
  74817. * An array of materials. A material defines the appearance of a primitive
  74818. */
  74819. materials?: IMaterial[];
  74820. /**
  74821. * An array of meshes. A mesh is a set of primitives to be rendered
  74822. */
  74823. meshes?: IMesh[];
  74824. /**
  74825. * An array of nodes
  74826. */
  74827. nodes?: INode[];
  74828. /**
  74829. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  74830. */
  74831. samplers?: ISampler[];
  74832. /**
  74833. * The index of the default scene
  74834. */
  74835. scene?: number;
  74836. /**
  74837. * An array of scenes
  74838. */
  74839. scenes?: IScene[];
  74840. /**
  74841. * An array of skins. A skin is defined by joints and matrices
  74842. */
  74843. skins?: ISkin[];
  74844. /**
  74845. * An array of textures
  74846. */
  74847. textures?: ITexture[];
  74848. }
  74849. /**
  74850. * The glTF validation results
  74851. * @ignore
  74852. */
  74853. interface IGLTFValidationResults {
  74854. info: {
  74855. generator: string;
  74856. hasAnimations: boolean;
  74857. hasDefaultScene: boolean;
  74858. hasMaterials: boolean;
  74859. hasMorphTargets: boolean;
  74860. hasSkins: boolean;
  74861. hasTextures: boolean;
  74862. maxAttributesUsed: number;
  74863. primitivesCount: number
  74864. };
  74865. issues: {
  74866. messages: Array<string>;
  74867. numErrors: number;
  74868. numHints: number;
  74869. numInfos: number;
  74870. numWarnings: number;
  74871. truncated: boolean
  74872. };
  74873. mimeType: string;
  74874. uri: string;
  74875. validatedAt: string;
  74876. validatorVersion: string;
  74877. }
  74878. /**
  74879. * The glTF validation options
  74880. */
  74881. interface IGLTFValidationOptions {
  74882. /** Uri to use */
  74883. uri?: string;
  74884. /** Function used to load external resources */
  74885. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  74886. /** Boolean indicating that we need to validate accessor data */
  74887. validateAccessorData?: boolean;
  74888. /** max number of issues allowed */
  74889. maxIssues?: number;
  74890. /** Ignored issues */
  74891. ignoredIssues?: Array<string>;
  74892. /** Value to override severy settings */
  74893. severityOverrides?: Object;
  74894. }
  74895. /**
  74896. * The glTF validator object
  74897. * @ignore
  74898. */
  74899. interface IGLTFValidator {
  74900. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  74901. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  74902. }
  74903. }
  74904. declare module BABYLON {
  74905. /** @hidden */
  74906. export var cellPixelShader: {
  74907. name: string;
  74908. shader: string;
  74909. };
  74910. }
  74911. declare module BABYLON {
  74912. /** @hidden */
  74913. export var cellVertexShader: {
  74914. name: string;
  74915. shader: string;
  74916. };
  74917. }
  74918. declare module BABYLON {
  74919. export class CellMaterial extends BABYLON.PushMaterial {
  74920. private _diffuseTexture;
  74921. diffuseTexture: BABYLON.BaseTexture;
  74922. diffuseColor: BABYLON.Color3;
  74923. _computeHighLevel: boolean;
  74924. computeHighLevel: boolean;
  74925. private _disableLighting;
  74926. disableLighting: boolean;
  74927. private _maxSimultaneousLights;
  74928. maxSimultaneousLights: number;
  74929. private _renderId;
  74930. constructor(name: string, scene: BABYLON.Scene);
  74931. needAlphaBlending(): boolean;
  74932. needAlphaTesting(): boolean;
  74933. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74934. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74935. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74936. getAnimatables(): BABYLON.IAnimatable[];
  74937. getActiveTextures(): BABYLON.BaseTexture[];
  74938. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74939. dispose(forceDisposeEffect?: boolean): void;
  74940. getClassName(): string;
  74941. clone(name: string): CellMaterial;
  74942. serialize(): any;
  74943. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  74944. }
  74945. }
  74946. declare module BABYLON {
  74947. export class CustomShaderStructure {
  74948. FragmentStore: string;
  74949. VertexStore: string;
  74950. constructor();
  74951. }
  74952. export class ShaderSpecialParts {
  74953. constructor();
  74954. Fragment_Begin: string;
  74955. Fragment_Definitions: string;
  74956. Fragment_MainBegin: string;
  74957. Fragment_Custom_Diffuse: string;
  74958. Fragment_Before_Lights: string;
  74959. Fragment_Before_Fog: string;
  74960. Fragment_Custom_Alpha: string;
  74961. Fragment_Before_FragColor: string;
  74962. Vertex_Begin: string;
  74963. Vertex_Definitions: string;
  74964. Vertex_MainBegin: string;
  74965. Vertex_Before_PositionUpdated: string;
  74966. Vertex_Before_NormalUpdated: string;
  74967. Vertex_MainEnd: string;
  74968. }
  74969. export class CustomMaterial extends BABYLON.StandardMaterial {
  74970. static ShaderIndexer: number;
  74971. CustomParts: ShaderSpecialParts;
  74972. _isCreatedShader: boolean;
  74973. _createdShaderName: string;
  74974. _customUniform: string[];
  74975. _newUniforms: string[];
  74976. _newUniformInstances: any[];
  74977. _newSamplerInstances: BABYLON.Texture[];
  74978. FragmentShader: string;
  74979. VertexShader: string;
  74980. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  74981. ReviewUniform(name: string, arr: string[]): string[];
  74982. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  74983. constructor(name: string, scene: BABYLON.Scene);
  74984. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  74985. Fragment_Begin(shaderPart: string): CustomMaterial;
  74986. Fragment_Definitions(shaderPart: string): CustomMaterial;
  74987. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  74988. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  74989. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  74990. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  74991. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  74992. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  74993. Vertex_Begin(shaderPart: string): CustomMaterial;
  74994. Vertex_Definitions(shaderPart: string): CustomMaterial;
  74995. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  74996. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  74997. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  74998. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  74999. }
  75000. }
  75001. declare module BABYLON {
  75002. export class ShaderAlebdoParts {
  75003. constructor();
  75004. Fragment_Begin: string;
  75005. Fragment_Definitions: string;
  75006. Fragment_MainBegin: string;
  75007. Fragment_Custom_Albedo: string;
  75008. Fragment_Before_Lights: string;
  75009. Fragment_Custom_MetallicRoughness: string;
  75010. Fragment_Custom_MicroSurface: string;
  75011. Fragment_Before_Fog: string;
  75012. Fragment_Custom_Alpha: string;
  75013. Fragment_Before_FragColor: string;
  75014. Vertex_Begin: string;
  75015. Vertex_Definitions: string;
  75016. Vertex_MainBegin: string;
  75017. Vertex_Before_PositionUpdated: string;
  75018. Vertex_Before_NormalUpdated: string;
  75019. Vertex_MainEnd: string;
  75020. }
  75021. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  75022. static ShaderIndexer: number;
  75023. CustomParts: ShaderAlebdoParts;
  75024. _isCreatedShader: boolean;
  75025. _createdShaderName: string;
  75026. _customUniform: string[];
  75027. _newUniforms: string[];
  75028. _newUniformInstances: any[];
  75029. _newSamplerInstances: BABYLON.Texture[];
  75030. FragmentShader: string;
  75031. VertexShader: string;
  75032. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  75033. ReviewUniform(name: string, arr: string[]): string[];
  75034. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  75035. constructor(name: string, scene: BABYLON.Scene);
  75036. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  75037. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  75038. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  75039. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  75040. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  75041. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  75042. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  75043. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  75044. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  75045. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  75046. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  75047. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  75048. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  75049. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  75050. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  75051. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  75052. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  75053. }
  75054. }
  75055. declare module BABYLON {
  75056. /** @hidden */
  75057. export var firePixelShader: {
  75058. name: string;
  75059. shader: string;
  75060. };
  75061. }
  75062. declare module BABYLON {
  75063. /** @hidden */
  75064. export var fireVertexShader: {
  75065. name: string;
  75066. shader: string;
  75067. };
  75068. }
  75069. declare module BABYLON {
  75070. export class FireMaterial extends BABYLON.PushMaterial {
  75071. private _diffuseTexture;
  75072. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75073. private _distortionTexture;
  75074. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75075. private _opacityTexture;
  75076. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75077. diffuseColor: BABYLON.Color3;
  75078. speed: number;
  75079. private _scaledDiffuse;
  75080. private _renderId;
  75081. private _lastTime;
  75082. constructor(name: string, scene: BABYLON.Scene);
  75083. needAlphaBlending(): boolean;
  75084. needAlphaTesting(): boolean;
  75085. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75086. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75087. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75088. getAnimatables(): BABYLON.IAnimatable[];
  75089. getActiveTextures(): BABYLON.BaseTexture[];
  75090. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75091. getClassName(): string;
  75092. dispose(forceDisposeEffect?: boolean): void;
  75093. clone(name: string): FireMaterial;
  75094. serialize(): any;
  75095. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  75096. }
  75097. }
  75098. declare module BABYLON {
  75099. /** @hidden */
  75100. export var furPixelShader: {
  75101. name: string;
  75102. shader: string;
  75103. };
  75104. }
  75105. declare module BABYLON {
  75106. /** @hidden */
  75107. export var furVertexShader: {
  75108. name: string;
  75109. shader: string;
  75110. };
  75111. }
  75112. declare module BABYLON {
  75113. export class FurMaterial extends BABYLON.PushMaterial {
  75114. private _diffuseTexture;
  75115. diffuseTexture: BABYLON.BaseTexture;
  75116. private _heightTexture;
  75117. heightTexture: BABYLON.BaseTexture;
  75118. diffuseColor: BABYLON.Color3;
  75119. furLength: number;
  75120. furAngle: number;
  75121. furColor: BABYLON.Color3;
  75122. furOffset: number;
  75123. furSpacing: number;
  75124. furGravity: BABYLON.Vector3;
  75125. furSpeed: number;
  75126. furDensity: number;
  75127. furOcclusion: number;
  75128. furTexture: BABYLON.DynamicTexture;
  75129. private _disableLighting;
  75130. disableLighting: boolean;
  75131. private _maxSimultaneousLights;
  75132. maxSimultaneousLights: number;
  75133. highLevelFur: boolean;
  75134. _meshes: BABYLON.AbstractMesh[];
  75135. private _renderId;
  75136. private _furTime;
  75137. constructor(name: string, scene: BABYLON.Scene);
  75138. furTime: number;
  75139. needAlphaBlending(): boolean;
  75140. needAlphaTesting(): boolean;
  75141. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75142. updateFur(): void;
  75143. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75144. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75145. getAnimatables(): BABYLON.IAnimatable[];
  75146. getActiveTextures(): BABYLON.BaseTexture[];
  75147. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75148. dispose(forceDisposeEffect?: boolean): void;
  75149. clone(name: string): FurMaterial;
  75150. serialize(): any;
  75151. getClassName(): string;
  75152. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  75153. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  75154. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  75155. }
  75156. }
  75157. declare module BABYLON {
  75158. /** @hidden */
  75159. export var gradientPixelShader: {
  75160. name: string;
  75161. shader: string;
  75162. };
  75163. }
  75164. declare module BABYLON {
  75165. /** @hidden */
  75166. export var gradientVertexShader: {
  75167. name: string;
  75168. shader: string;
  75169. };
  75170. }
  75171. declare module BABYLON {
  75172. export class GradientMaterial extends BABYLON.PushMaterial {
  75173. private _maxSimultaneousLights;
  75174. maxSimultaneousLights: number;
  75175. topColor: BABYLON.Color3;
  75176. topColorAlpha: number;
  75177. bottomColor: BABYLON.Color3;
  75178. bottomColorAlpha: number;
  75179. offset: number;
  75180. scale: number;
  75181. smoothness: number;
  75182. private _disableLighting;
  75183. disableLighting: boolean;
  75184. private _renderId;
  75185. constructor(name: string, scene: BABYLON.Scene);
  75186. needAlphaBlending(): boolean;
  75187. needAlphaTesting(): boolean;
  75188. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75189. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75190. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75191. getAnimatables(): BABYLON.IAnimatable[];
  75192. dispose(forceDisposeEffect?: boolean): void;
  75193. clone(name: string): GradientMaterial;
  75194. serialize(): any;
  75195. getClassName(): string;
  75196. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  75197. }
  75198. }
  75199. declare module BABYLON {
  75200. /** @hidden */
  75201. export var gridPixelShader: {
  75202. name: string;
  75203. shader: string;
  75204. };
  75205. }
  75206. declare module BABYLON {
  75207. /** @hidden */
  75208. export var gridVertexShader: {
  75209. name: string;
  75210. shader: string;
  75211. };
  75212. }
  75213. declare module BABYLON {
  75214. /**
  75215. * The grid materials allows you to wrap any shape with a grid.
  75216. * Colors are customizable.
  75217. */
  75218. export class GridMaterial extends BABYLON.PushMaterial {
  75219. /**
  75220. * Main color of the grid (e.g. between lines)
  75221. */
  75222. mainColor: BABYLON.Color3;
  75223. /**
  75224. * Color of the grid lines.
  75225. */
  75226. lineColor: BABYLON.Color3;
  75227. /**
  75228. * The scale of the grid compared to unit.
  75229. */
  75230. gridRatio: number;
  75231. /**
  75232. * Allows setting an offset for the grid lines.
  75233. */
  75234. gridOffset: BABYLON.Vector3;
  75235. /**
  75236. * The frequency of thicker lines.
  75237. */
  75238. majorUnitFrequency: number;
  75239. /**
  75240. * The visibility of minor units in the grid.
  75241. */
  75242. minorUnitVisibility: number;
  75243. /**
  75244. * The grid opacity outside of the lines.
  75245. */
  75246. opacity: number;
  75247. /**
  75248. * Determine RBG output is premultiplied by alpha value.
  75249. */
  75250. preMultiplyAlpha: boolean;
  75251. private _opacityTexture;
  75252. opacityTexture: BABYLON.BaseTexture;
  75253. private _gridControl;
  75254. private _renderId;
  75255. /**
  75256. * constructor
  75257. * @param name The name given to the material in order to identify it afterwards.
  75258. * @param scene The scene the material is used in.
  75259. */
  75260. constructor(name: string, scene: BABYLON.Scene);
  75261. /**
  75262. * Returns wehter or not the grid requires alpha blending.
  75263. */
  75264. needAlphaBlending(): boolean;
  75265. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  75266. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75267. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75268. /**
  75269. * Dispose the material and its associated resources.
  75270. * @param forceDisposeEffect will also dispose the used effect when true
  75271. */
  75272. dispose(forceDisposeEffect?: boolean): void;
  75273. clone(name: string): GridMaterial;
  75274. serialize(): any;
  75275. getClassName(): string;
  75276. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  75277. }
  75278. }
  75279. declare module BABYLON {
  75280. /** @hidden */
  75281. export var lavaPixelShader: {
  75282. name: string;
  75283. shader: string;
  75284. };
  75285. }
  75286. declare module BABYLON {
  75287. /** @hidden */
  75288. export var lavaVertexShader: {
  75289. name: string;
  75290. shader: string;
  75291. };
  75292. }
  75293. declare module BABYLON {
  75294. export class LavaMaterial extends BABYLON.PushMaterial {
  75295. private _diffuseTexture;
  75296. diffuseTexture: BABYLON.BaseTexture;
  75297. noiseTexture: BABYLON.BaseTexture;
  75298. fogColor: BABYLON.Color3;
  75299. speed: number;
  75300. movingSpeed: number;
  75301. lowFrequencySpeed: number;
  75302. fogDensity: number;
  75303. private _lastTime;
  75304. diffuseColor: BABYLON.Color3;
  75305. private _disableLighting;
  75306. disableLighting: boolean;
  75307. private _unlit;
  75308. unlit: boolean;
  75309. private _maxSimultaneousLights;
  75310. maxSimultaneousLights: number;
  75311. private _scaledDiffuse;
  75312. private _renderId;
  75313. constructor(name: string, scene: BABYLON.Scene);
  75314. needAlphaBlending(): boolean;
  75315. needAlphaTesting(): boolean;
  75316. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75317. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75318. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75319. getAnimatables(): BABYLON.IAnimatable[];
  75320. getActiveTextures(): BABYLON.BaseTexture[];
  75321. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75322. dispose(forceDisposeEffect?: boolean): void;
  75323. clone(name: string): LavaMaterial;
  75324. serialize(): any;
  75325. getClassName(): string;
  75326. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  75327. }
  75328. }
  75329. declare module BABYLON {
  75330. /** @hidden */
  75331. export var mixPixelShader: {
  75332. name: string;
  75333. shader: string;
  75334. };
  75335. }
  75336. declare module BABYLON {
  75337. /** @hidden */
  75338. export var mixVertexShader: {
  75339. name: string;
  75340. shader: string;
  75341. };
  75342. }
  75343. declare module BABYLON {
  75344. export class MixMaterial extends BABYLON.PushMaterial {
  75345. /**
  75346. * Mix textures
  75347. */
  75348. private _mixTexture1;
  75349. mixTexture1: BABYLON.BaseTexture;
  75350. private _mixTexture2;
  75351. mixTexture2: BABYLON.BaseTexture;
  75352. /**
  75353. * Diffuse textures
  75354. */
  75355. private _diffuseTexture1;
  75356. diffuseTexture1: BABYLON.Texture;
  75357. private _diffuseTexture2;
  75358. diffuseTexture2: BABYLON.Texture;
  75359. private _diffuseTexture3;
  75360. diffuseTexture3: BABYLON.Texture;
  75361. private _diffuseTexture4;
  75362. diffuseTexture4: BABYLON.Texture;
  75363. private _diffuseTexture5;
  75364. diffuseTexture5: BABYLON.Texture;
  75365. private _diffuseTexture6;
  75366. diffuseTexture6: BABYLON.Texture;
  75367. private _diffuseTexture7;
  75368. diffuseTexture7: BABYLON.Texture;
  75369. private _diffuseTexture8;
  75370. diffuseTexture8: BABYLON.Texture;
  75371. /**
  75372. * Uniforms
  75373. */
  75374. diffuseColor: BABYLON.Color3;
  75375. specularColor: BABYLON.Color3;
  75376. specularPower: number;
  75377. private _disableLighting;
  75378. disableLighting: boolean;
  75379. private _maxSimultaneousLights;
  75380. maxSimultaneousLights: number;
  75381. private _renderId;
  75382. constructor(name: string, scene: BABYLON.Scene);
  75383. needAlphaBlending(): boolean;
  75384. needAlphaTesting(): boolean;
  75385. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75386. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75387. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75388. getAnimatables(): BABYLON.IAnimatable[];
  75389. getActiveTextures(): BABYLON.BaseTexture[];
  75390. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75391. dispose(forceDisposeEffect?: boolean): void;
  75392. clone(name: string): MixMaterial;
  75393. serialize(): any;
  75394. getClassName(): string;
  75395. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  75396. }
  75397. }
  75398. declare module BABYLON {
  75399. /** @hidden */
  75400. export var normalPixelShader: {
  75401. name: string;
  75402. shader: string;
  75403. };
  75404. }
  75405. declare module BABYLON {
  75406. /** @hidden */
  75407. export var normalVertexShader: {
  75408. name: string;
  75409. shader: string;
  75410. };
  75411. }
  75412. declare module BABYLON {
  75413. export class NormalMaterial extends BABYLON.PushMaterial {
  75414. private _diffuseTexture;
  75415. diffuseTexture: BABYLON.BaseTexture;
  75416. diffuseColor: BABYLON.Color3;
  75417. private _disableLighting;
  75418. disableLighting: boolean;
  75419. private _maxSimultaneousLights;
  75420. maxSimultaneousLights: number;
  75421. private _renderId;
  75422. constructor(name: string, scene: BABYLON.Scene);
  75423. needAlphaBlending(): boolean;
  75424. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  75425. needAlphaTesting(): boolean;
  75426. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75427. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75428. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75429. getAnimatables(): BABYLON.IAnimatable[];
  75430. getActiveTextures(): BABYLON.BaseTexture[];
  75431. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75432. dispose(forceDisposeEffect?: boolean): void;
  75433. clone(name: string): NormalMaterial;
  75434. serialize(): any;
  75435. getClassName(): string;
  75436. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  75437. }
  75438. }
  75439. declare module BABYLON {
  75440. /** @hidden */
  75441. export var shadowOnlyPixelShader: {
  75442. name: string;
  75443. shader: string;
  75444. };
  75445. }
  75446. declare module BABYLON {
  75447. /** @hidden */
  75448. export var shadowOnlyVertexShader: {
  75449. name: string;
  75450. shader: string;
  75451. };
  75452. }
  75453. declare module BABYLON {
  75454. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  75455. private _renderId;
  75456. private _activeLight;
  75457. constructor(name: string, scene: BABYLON.Scene);
  75458. shadowColor: BABYLON.Color3;
  75459. needAlphaBlending(): boolean;
  75460. needAlphaTesting(): boolean;
  75461. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75462. activeLight: BABYLON.IShadowLight;
  75463. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75464. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75465. clone(name: string): ShadowOnlyMaterial;
  75466. serialize(): any;
  75467. getClassName(): string;
  75468. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  75469. }
  75470. }
  75471. declare module BABYLON {
  75472. /** @hidden */
  75473. export var simplePixelShader: {
  75474. name: string;
  75475. shader: string;
  75476. };
  75477. }
  75478. declare module BABYLON {
  75479. /** @hidden */
  75480. export var simpleVertexShader: {
  75481. name: string;
  75482. shader: string;
  75483. };
  75484. }
  75485. declare module BABYLON {
  75486. export class SimpleMaterial extends BABYLON.PushMaterial {
  75487. private _diffuseTexture;
  75488. diffuseTexture: BABYLON.BaseTexture;
  75489. diffuseColor: BABYLON.Color3;
  75490. private _disableLighting;
  75491. disableLighting: boolean;
  75492. private _maxSimultaneousLights;
  75493. maxSimultaneousLights: number;
  75494. private _renderId;
  75495. constructor(name: string, scene: BABYLON.Scene);
  75496. needAlphaBlending(): boolean;
  75497. needAlphaTesting(): boolean;
  75498. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75499. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75500. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75501. getAnimatables(): BABYLON.IAnimatable[];
  75502. getActiveTextures(): BABYLON.BaseTexture[];
  75503. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75504. dispose(forceDisposeEffect?: boolean): void;
  75505. clone(name: string): SimpleMaterial;
  75506. serialize(): any;
  75507. getClassName(): string;
  75508. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  75509. }
  75510. }
  75511. declare module BABYLON {
  75512. /** @hidden */
  75513. export var skyPixelShader: {
  75514. name: string;
  75515. shader: string;
  75516. };
  75517. }
  75518. declare module BABYLON {
  75519. /** @hidden */
  75520. export var skyVertexShader: {
  75521. name: string;
  75522. shader: string;
  75523. };
  75524. }
  75525. declare module BABYLON {
  75526. /**
  75527. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  75528. * @see https://doc.babylonjs.com/extensions/sky
  75529. */
  75530. export class SkyMaterial extends BABYLON.PushMaterial {
  75531. /**
  75532. * Defines the overall luminance of sky in interval ]0, 1[.
  75533. */
  75534. luminance: number;
  75535. /**
  75536. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  75537. */
  75538. turbidity: number;
  75539. /**
  75540. * Defines the sky appearance (light intensity).
  75541. */
  75542. rayleigh: number;
  75543. /**
  75544. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  75545. */
  75546. mieCoefficient: number;
  75547. /**
  75548. * Defines the amount of haze particles following the Mie scattering theory.
  75549. */
  75550. mieDirectionalG: number;
  75551. /**
  75552. * Defines the distance of the sun according to the active scene camera.
  75553. */
  75554. distance: number;
  75555. /**
  75556. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  75557. * "inclined".
  75558. */
  75559. inclination: number;
  75560. /**
  75561. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  75562. * an object direction and a reference direction.
  75563. */
  75564. azimuth: number;
  75565. /**
  75566. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  75567. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  75568. */
  75569. sunPosition: BABYLON.Vector3;
  75570. /**
  75571. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  75572. * .sunPosition property.
  75573. */
  75574. useSunPosition: boolean;
  75575. /**
  75576. * Defines an offset vector used to get a horizon offset.
  75577. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  75578. */
  75579. cameraOffset: BABYLON.Vector3;
  75580. private _cameraPosition;
  75581. private _renderId;
  75582. /**
  75583. * Instantiates a new sky material.
  75584. * This material allows to create dynamic and texture free
  75585. * effects for skyboxes by taking care of the atmosphere state.
  75586. * @see https://doc.babylonjs.com/extensions/sky
  75587. * @param name Define the name of the material in the scene
  75588. * @param scene Define the scene the material belong to
  75589. */
  75590. constructor(name: string, scene: BABYLON.Scene);
  75591. /**
  75592. * Specifies if the material will require alpha blending
  75593. * @returns a boolean specifying if alpha blending is needed
  75594. */
  75595. needAlphaBlending(): boolean;
  75596. /**
  75597. * Specifies if this material should be rendered in alpha test mode
  75598. * @returns false as the sky material doesn't need alpha testing.
  75599. */
  75600. needAlphaTesting(): boolean;
  75601. /**
  75602. * Get the texture used for alpha test purpose.
  75603. * @returns null as the sky material has no texture.
  75604. */
  75605. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75606. /**
  75607. * Get if the submesh is ready to be used and all its information available.
  75608. * Child classes can use it to update shaders
  75609. * @param mesh defines the mesh to check
  75610. * @param subMesh defines which submesh to check
  75611. * @param useInstances specifies that instances should be used
  75612. * @returns a boolean indicating that the submesh is ready or not
  75613. */
  75614. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75615. /**
  75616. * Binds the submesh to this material by preparing the effect and shader to draw
  75617. * @param world defines the world transformation matrix
  75618. * @param mesh defines the mesh containing the submesh
  75619. * @param subMesh defines the submesh to bind the material to
  75620. */
  75621. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75622. /**
  75623. * Get the list of animatables in the material.
  75624. * @returns the list of animatables object used in the material
  75625. */
  75626. getAnimatables(): BABYLON.IAnimatable[];
  75627. /**
  75628. * Disposes the material
  75629. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75630. */
  75631. dispose(forceDisposeEffect?: boolean): void;
  75632. /**
  75633. * Makes a duplicate of the material, and gives it a new name
  75634. * @param name defines the new name for the duplicated material
  75635. * @returns the cloned material
  75636. */
  75637. clone(name: string): SkyMaterial;
  75638. /**
  75639. * Serializes this material in a JSON representation
  75640. * @returns the serialized material object
  75641. */
  75642. serialize(): any;
  75643. /**
  75644. * Gets the current class name of the material e.g. "SkyMaterial"
  75645. * Mainly use in serialization.
  75646. * @returns the class name
  75647. */
  75648. getClassName(): string;
  75649. /**
  75650. * Creates a sky material from parsed material data
  75651. * @param source defines the JSON representation of the material
  75652. * @param scene defines the hosting scene
  75653. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75654. * @returns a new sky material
  75655. */
  75656. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  75657. }
  75658. }
  75659. declare module BABYLON {
  75660. /** @hidden */
  75661. export var terrainPixelShader: {
  75662. name: string;
  75663. shader: string;
  75664. };
  75665. }
  75666. declare module BABYLON {
  75667. /** @hidden */
  75668. export var terrainVertexShader: {
  75669. name: string;
  75670. shader: string;
  75671. };
  75672. }
  75673. declare module BABYLON {
  75674. export class TerrainMaterial extends BABYLON.PushMaterial {
  75675. private _mixTexture;
  75676. mixTexture: BABYLON.BaseTexture;
  75677. private _diffuseTexture1;
  75678. diffuseTexture1: BABYLON.Texture;
  75679. private _diffuseTexture2;
  75680. diffuseTexture2: BABYLON.Texture;
  75681. private _diffuseTexture3;
  75682. diffuseTexture3: BABYLON.Texture;
  75683. private _bumpTexture1;
  75684. bumpTexture1: BABYLON.Texture;
  75685. private _bumpTexture2;
  75686. bumpTexture2: BABYLON.Texture;
  75687. private _bumpTexture3;
  75688. bumpTexture3: BABYLON.Texture;
  75689. diffuseColor: BABYLON.Color3;
  75690. specularColor: BABYLON.Color3;
  75691. specularPower: number;
  75692. private _disableLighting;
  75693. disableLighting: boolean;
  75694. private _maxSimultaneousLights;
  75695. maxSimultaneousLights: number;
  75696. private _renderId;
  75697. constructor(name: string, scene: BABYLON.Scene);
  75698. needAlphaBlending(): boolean;
  75699. needAlphaTesting(): boolean;
  75700. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75701. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75702. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75703. getAnimatables(): BABYLON.IAnimatable[];
  75704. getActiveTextures(): BABYLON.BaseTexture[];
  75705. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75706. dispose(forceDisposeEffect?: boolean): void;
  75707. clone(name: string): TerrainMaterial;
  75708. serialize(): any;
  75709. getClassName(): string;
  75710. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  75711. }
  75712. }
  75713. declare module BABYLON {
  75714. /** @hidden */
  75715. export var triplanarPixelShader: {
  75716. name: string;
  75717. shader: string;
  75718. };
  75719. }
  75720. declare module BABYLON {
  75721. /** @hidden */
  75722. export var triplanarVertexShader: {
  75723. name: string;
  75724. shader: string;
  75725. };
  75726. }
  75727. declare module BABYLON {
  75728. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  75729. mixTexture: BABYLON.BaseTexture;
  75730. private _diffuseTextureX;
  75731. diffuseTextureX: BABYLON.BaseTexture;
  75732. private _diffuseTextureY;
  75733. diffuseTextureY: BABYLON.BaseTexture;
  75734. private _diffuseTextureZ;
  75735. diffuseTextureZ: BABYLON.BaseTexture;
  75736. private _normalTextureX;
  75737. normalTextureX: BABYLON.BaseTexture;
  75738. private _normalTextureY;
  75739. normalTextureY: BABYLON.BaseTexture;
  75740. private _normalTextureZ;
  75741. normalTextureZ: BABYLON.BaseTexture;
  75742. tileSize: number;
  75743. diffuseColor: BABYLON.Color3;
  75744. specularColor: BABYLON.Color3;
  75745. specularPower: number;
  75746. private _disableLighting;
  75747. disableLighting: boolean;
  75748. private _maxSimultaneousLights;
  75749. maxSimultaneousLights: number;
  75750. private _renderId;
  75751. constructor(name: string, scene: BABYLON.Scene);
  75752. needAlphaBlending(): boolean;
  75753. needAlphaTesting(): boolean;
  75754. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75755. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75756. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75757. getAnimatables(): BABYLON.IAnimatable[];
  75758. getActiveTextures(): BABYLON.BaseTexture[];
  75759. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75760. dispose(forceDisposeEffect?: boolean): void;
  75761. clone(name: string): TriPlanarMaterial;
  75762. serialize(): any;
  75763. getClassName(): string;
  75764. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  75765. }
  75766. }
  75767. declare module BABYLON {
  75768. /** @hidden */
  75769. export var waterPixelShader: {
  75770. name: string;
  75771. shader: string;
  75772. };
  75773. }
  75774. declare module BABYLON {
  75775. /** @hidden */
  75776. export var waterVertexShader: {
  75777. name: string;
  75778. shader: string;
  75779. };
  75780. }
  75781. declare module BABYLON {
  75782. export class WaterMaterial extends BABYLON.PushMaterial {
  75783. renderTargetSize: BABYLON.Vector2;
  75784. private _bumpTexture;
  75785. bumpTexture: BABYLON.BaseTexture;
  75786. diffuseColor: BABYLON.Color3;
  75787. specularColor: BABYLON.Color3;
  75788. specularPower: number;
  75789. private _disableLighting;
  75790. disableLighting: boolean;
  75791. private _maxSimultaneousLights;
  75792. maxSimultaneousLights: number;
  75793. /**
  75794. * @param {number}: Represents the wind force
  75795. */
  75796. windForce: number;
  75797. /**
  75798. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  75799. */
  75800. windDirection: BABYLON.Vector2;
  75801. /**
  75802. * @param {number}: Wave height, represents the height of the waves
  75803. */
  75804. waveHeight: number;
  75805. /**
  75806. * @param {number}: Bump height, represents the bump height related to the bump map
  75807. */
  75808. bumpHeight: number;
  75809. /**
  75810. * @param {boolean}: Add a smaller moving bump to less steady waves.
  75811. */
  75812. private _bumpSuperimpose;
  75813. bumpSuperimpose: boolean;
  75814. /**
  75815. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  75816. */
  75817. private _fresnelSeparate;
  75818. fresnelSeparate: boolean;
  75819. /**
  75820. * @param {boolean}: bump Waves modify the reflection.
  75821. */
  75822. private _bumpAffectsReflection;
  75823. bumpAffectsReflection: boolean;
  75824. /**
  75825. * @param {number}: The water color blended with the refraction (near)
  75826. */
  75827. waterColor: BABYLON.Color3;
  75828. /**
  75829. * @param {number}: The blend factor related to the water color
  75830. */
  75831. colorBlendFactor: number;
  75832. /**
  75833. * @param {number}: The water color blended with the reflection (far)
  75834. */
  75835. waterColor2: BABYLON.Color3;
  75836. /**
  75837. * @param {number}: The blend factor related to the water color (reflection, far)
  75838. */
  75839. colorBlendFactor2: number;
  75840. /**
  75841. * @param {number}: Represents the maximum length of a wave
  75842. */
  75843. waveLength: number;
  75844. /**
  75845. * @param {number}: Defines the waves speed
  75846. */
  75847. waveSpeed: number;
  75848. /**
  75849. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  75850. * will avoid calculating useless pixels in the pixel shader of the water material.
  75851. */
  75852. disableClipPlane: boolean;
  75853. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  75854. private _mesh;
  75855. private _refractionRTT;
  75856. private _reflectionRTT;
  75857. private _reflectionTransform;
  75858. private _lastTime;
  75859. private _lastDeltaTime;
  75860. private _renderId;
  75861. private _useLogarithmicDepth;
  75862. private _waitingRenderList;
  75863. private _imageProcessingConfiguration;
  75864. private _imageProcessingObserver;
  75865. /**
  75866. * Gets a boolean indicating that current material needs to register RTT
  75867. */
  75868. readonly hasRenderTargetTextures: boolean;
  75869. /**
  75870. * Constructor
  75871. */
  75872. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  75873. useLogarithmicDepth: boolean;
  75874. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  75875. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  75876. addToRenderList(node: any): void;
  75877. enableRenderTargets(enable: boolean): void;
  75878. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  75879. readonly renderTargetsEnabled: boolean;
  75880. needAlphaBlending(): boolean;
  75881. needAlphaTesting(): boolean;
  75882. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75883. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75884. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75885. private _createRenderTargets;
  75886. getAnimatables(): BABYLON.IAnimatable[];
  75887. getActiveTextures(): BABYLON.BaseTexture[];
  75888. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75889. dispose(forceDisposeEffect?: boolean): void;
  75890. clone(name: string): WaterMaterial;
  75891. serialize(): any;
  75892. getClassName(): string;
  75893. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  75894. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  75895. }
  75896. }
  75897. declare module BABYLON {
  75898. /** @hidden */
  75899. export var asciiartPixelShader: {
  75900. name: string;
  75901. shader: string;
  75902. };
  75903. }
  75904. declare module BABYLON {
  75905. /**
  75906. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  75907. *
  75908. * It basically takes care rendering the font front the given font size to a texture.
  75909. * This is used later on in the postprocess.
  75910. */
  75911. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  75912. private _font;
  75913. private _text;
  75914. private _charSize;
  75915. /**
  75916. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  75917. */
  75918. readonly charSize: number;
  75919. /**
  75920. * Create a new instance of the Ascii Art FontTexture class
  75921. * @param name the name of the texture
  75922. * @param font the font to use, use the W3C CSS notation
  75923. * @param text the caracter set to use in the rendering.
  75924. * @param scene the scene that owns the texture
  75925. */
  75926. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  75927. /**
  75928. * Gets the max char width of a font.
  75929. * @param font the font to use, use the W3C CSS notation
  75930. * @return the max char width
  75931. */
  75932. private getFontWidth;
  75933. /**
  75934. * Gets the max char height of a font.
  75935. * @param font the font to use, use the W3C CSS notation
  75936. * @return the max char height
  75937. */
  75938. private getFontHeight;
  75939. /**
  75940. * Clones the current AsciiArtTexture.
  75941. * @return the clone of the texture.
  75942. */
  75943. clone(): AsciiArtFontTexture;
  75944. /**
  75945. * Parses a json object representing the texture and returns an instance of it.
  75946. * @param source the source JSON representation
  75947. * @param scene the scene to create the texture for
  75948. * @return the parsed texture
  75949. */
  75950. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  75951. }
  75952. /**
  75953. * Option available in the Ascii Art Post Process.
  75954. */
  75955. export interface IAsciiArtPostProcessOptions {
  75956. /**
  75957. * The font to use following the w3c font definition.
  75958. */
  75959. font?: string;
  75960. /**
  75961. * The character set to use in the postprocess.
  75962. */
  75963. characterSet?: string;
  75964. /**
  75965. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  75966. * This number is defined between 0 and 1;
  75967. */
  75968. mixToTile?: number;
  75969. /**
  75970. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  75971. * This number is defined between 0 and 1;
  75972. */
  75973. mixToNormal?: number;
  75974. }
  75975. /**
  75976. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  75977. *
  75978. * Simmply add it to your scene and let the nerd that lives in you have fun.
  75979. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  75980. */
  75981. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  75982. /**
  75983. * The font texture used to render the char in the post process.
  75984. */
  75985. private _asciiArtFontTexture;
  75986. /**
  75987. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  75988. * This number is defined between 0 and 1;
  75989. */
  75990. mixToTile: number;
  75991. /**
  75992. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  75993. * This number is defined between 0 and 1;
  75994. */
  75995. mixToNormal: number;
  75996. /**
  75997. * Instantiates a new Ascii Art Post Process.
  75998. * @param name the name to give to the postprocess
  75999. * @camera the camera to apply the post process to.
  76000. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  76001. */
  76002. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  76003. }
  76004. }
  76005. declare module BABYLON {
  76006. /** @hidden */
  76007. export var digitalrainPixelShader: {
  76008. name: string;
  76009. shader: string;
  76010. };
  76011. }
  76012. declare module BABYLON {
  76013. /**
  76014. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  76015. *
  76016. * It basically takes care rendering the font front the given font size to a texture.
  76017. * This is used later on in the postprocess.
  76018. */
  76019. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  76020. private _font;
  76021. private _text;
  76022. private _charSize;
  76023. /**
  76024. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  76025. */
  76026. readonly charSize: number;
  76027. /**
  76028. * Create a new instance of the Digital Rain FontTexture class
  76029. * @param name the name of the texture
  76030. * @param font the font to use, use the W3C CSS notation
  76031. * @param text the caracter set to use in the rendering.
  76032. * @param scene the scene that owns the texture
  76033. */
  76034. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  76035. /**
  76036. * Gets the max char width of a font.
  76037. * @param font the font to use, use the W3C CSS notation
  76038. * @return the max char width
  76039. */
  76040. private getFontWidth;
  76041. /**
  76042. * Gets the max char height of a font.
  76043. * @param font the font to use, use the W3C CSS notation
  76044. * @return the max char height
  76045. */
  76046. private getFontHeight;
  76047. /**
  76048. * Clones the current DigitalRainFontTexture.
  76049. * @return the clone of the texture.
  76050. */
  76051. clone(): DigitalRainFontTexture;
  76052. /**
  76053. * Parses a json object representing the texture and returns an instance of it.
  76054. * @param source the source JSON representation
  76055. * @param scene the scene to create the texture for
  76056. * @return the parsed texture
  76057. */
  76058. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  76059. }
  76060. /**
  76061. * Option available in the Digital Rain Post Process.
  76062. */
  76063. export interface IDigitalRainPostProcessOptions {
  76064. /**
  76065. * The font to use following the w3c font definition.
  76066. */
  76067. font?: string;
  76068. /**
  76069. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  76070. * This number is defined between 0 and 1;
  76071. */
  76072. mixToTile?: number;
  76073. /**
  76074. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  76075. * This number is defined between 0 and 1;
  76076. */
  76077. mixToNormal?: number;
  76078. }
  76079. /**
  76080. * DigitalRainPostProcess helps rendering everithing in digital rain.
  76081. *
  76082. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76083. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  76084. */
  76085. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  76086. /**
  76087. * The font texture used to render the char in the post process.
  76088. */
  76089. private _digitalRainFontTexture;
  76090. /**
  76091. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  76092. * This number is defined between 0 and 1;
  76093. */
  76094. mixToTile: number;
  76095. /**
  76096. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  76097. * This number is defined between 0 and 1;
  76098. */
  76099. mixToNormal: number;
  76100. /**
  76101. * Instantiates a new Digital Rain Post Process.
  76102. * @param name the name to give to the postprocess
  76103. * @camera the camera to apply the post process to.
  76104. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  76105. */
  76106. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  76107. }
  76108. }
  76109. declare module BABYLON {
  76110. /** @hidden */
  76111. export var oceanPostProcessPixelShader: {
  76112. name: string;
  76113. shader: string;
  76114. };
  76115. }
  76116. declare module BABYLON {
  76117. /**
  76118. * Option available in the Ocean Post Process.
  76119. */
  76120. export interface IOceanPostProcessOptions {
  76121. /**
  76122. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  76123. */
  76124. reflectionSize?: number | {
  76125. width: number;
  76126. height: number;
  76127. } | {
  76128. ratio: number;
  76129. };
  76130. /**
  76131. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  76132. */
  76133. refractionSize?: number | {
  76134. width: number;
  76135. height: number;
  76136. } | {
  76137. ratio: number;
  76138. };
  76139. }
  76140. /**
  76141. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  76142. *
  76143. * Simmply add it to your scene and let the nerd that lives in you have fun.
  76144. * Example usage:
  76145. * var pp = new OceanPostProcess("myOcean", camera);
  76146. * pp.reflectionEnabled = true;
  76147. * pp.refractionEnabled = true;
  76148. */
  76149. export class OceanPostProcess extends BABYLON.PostProcess {
  76150. /**
  76151. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  76152. */
  76153. /**
  76154. * Sets weither or not the real-time reflection is enabled on the ocean.
  76155. * Is set to true, the reflection mirror texture will be used as reflection texture.
  76156. */
  76157. reflectionEnabled: boolean;
  76158. /**
  76159. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  76160. */
  76161. /**
  76162. * Sets weither or not the real-time refraction is enabled on the ocean.
  76163. * Is set to true, the refraction render target texture will be used as refraction texture.
  76164. */
  76165. refractionEnabled: boolean;
  76166. /**
  76167. * Gets wether or not the post-processes is supported by the running hardware.
  76168. * This requires draw buffer supports.
  76169. */
  76170. readonly isSupported: boolean;
  76171. /**
  76172. * This is the reflection mirror texture used to display reflections on the ocean.
  76173. * By default, render list is empty.
  76174. */
  76175. reflectionTexture: BABYLON.MirrorTexture;
  76176. /**
  76177. * This is the refraction render target texture used to display refraction on the ocean.
  76178. * By default, render list is empty.
  76179. */
  76180. refractionTexture: BABYLON.RenderTargetTexture;
  76181. private _time;
  76182. private _cameraRotation;
  76183. private _cameraViewMatrix;
  76184. private _reflectionEnabled;
  76185. private _refractionEnabled;
  76186. private _geometryRenderer;
  76187. /**
  76188. * Instantiates a new Ocean Post Process.
  76189. * @param name the name to give to the postprocess.
  76190. * @camera the camera to apply the post process to.
  76191. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  76192. */
  76193. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  76194. /**
  76195. * Returns the appropriate defines according to the current configuration.
  76196. */
  76197. private _getDefines;
  76198. /**
  76199. * Computes the current camera rotation as the shader requires a camera rotation.
  76200. */
  76201. private _computeCameraRotation;
  76202. }
  76203. }
  76204. declare module BABYLON {
  76205. /** @hidden */
  76206. export var brickProceduralTexturePixelShader: {
  76207. name: string;
  76208. shader: string;
  76209. };
  76210. }
  76211. declare module BABYLON {
  76212. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  76213. private _numberOfBricksHeight;
  76214. private _numberOfBricksWidth;
  76215. private _jointColor;
  76216. private _brickColor;
  76217. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76218. updateShaderUniforms(): void;
  76219. numberOfBricksHeight: number;
  76220. numberOfBricksWidth: number;
  76221. jointColor: BABYLON.Color3;
  76222. brickColor: BABYLON.Color3;
  76223. /**
  76224. * Serializes this brick procedural texture
  76225. * @returns a serialized brick procedural texture object
  76226. */
  76227. serialize(): any;
  76228. /**
  76229. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  76230. * @param parsedTexture defines parsed texture data
  76231. * @param scene defines the current scene
  76232. * @param rootUrl defines the root URL containing brick procedural texture information
  76233. * @returns a parsed Brick Procedural BABYLON.Texture
  76234. */
  76235. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  76236. }
  76237. }
  76238. declare module BABYLON {
  76239. /** @hidden */
  76240. export var cloudProceduralTexturePixelShader: {
  76241. name: string;
  76242. shader: string;
  76243. };
  76244. }
  76245. declare module BABYLON {
  76246. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  76247. private _skyColor;
  76248. private _cloudColor;
  76249. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76250. updateShaderUniforms(): void;
  76251. skyColor: BABYLON.Color4;
  76252. cloudColor: BABYLON.Color4;
  76253. /**
  76254. * Serializes this cloud procedural texture
  76255. * @returns a serialized cloud procedural texture object
  76256. */
  76257. serialize(): any;
  76258. /**
  76259. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  76260. * @param parsedTexture defines parsed texture data
  76261. * @param scene defines the current scene
  76262. * @param rootUrl defines the root URL containing cloud procedural texture information
  76263. * @returns a parsed Cloud Procedural BABYLON.Texture
  76264. */
  76265. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  76266. }
  76267. }
  76268. declare module BABYLON {
  76269. /** @hidden */
  76270. export var fireProceduralTexturePixelShader: {
  76271. name: string;
  76272. shader: string;
  76273. };
  76274. }
  76275. declare module BABYLON {
  76276. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  76277. private _time;
  76278. private _speed;
  76279. private _autoGenerateTime;
  76280. private _fireColors;
  76281. private _alphaThreshold;
  76282. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76283. updateShaderUniforms(): void;
  76284. render(useCameraPostProcess?: boolean): void;
  76285. static readonly PurpleFireColors: BABYLON.Color3[];
  76286. static readonly GreenFireColors: BABYLON.Color3[];
  76287. static readonly RedFireColors: BABYLON.Color3[];
  76288. static readonly BlueFireColors: BABYLON.Color3[];
  76289. autoGenerateTime: boolean;
  76290. fireColors: BABYLON.Color3[];
  76291. time: number;
  76292. speed: BABYLON.Vector2;
  76293. alphaThreshold: number;
  76294. /**
  76295. * Serializes this fire procedural texture
  76296. * @returns a serialized fire procedural texture object
  76297. */
  76298. serialize(): any;
  76299. /**
  76300. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  76301. * @param parsedTexture defines parsed texture data
  76302. * @param scene defines the current scene
  76303. * @param rootUrl defines the root URL containing fire procedural texture information
  76304. * @returns a parsed Fire Procedural BABYLON.Texture
  76305. */
  76306. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  76307. }
  76308. }
  76309. declare module BABYLON {
  76310. /** @hidden */
  76311. export var grassProceduralTexturePixelShader: {
  76312. name: string;
  76313. shader: string;
  76314. };
  76315. }
  76316. declare module BABYLON {
  76317. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  76318. private _grassColors;
  76319. private _groundColor;
  76320. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76321. updateShaderUniforms(): void;
  76322. grassColors: BABYLON.Color3[];
  76323. groundColor: BABYLON.Color3;
  76324. /**
  76325. * Serializes this grass procedural texture
  76326. * @returns a serialized grass procedural texture object
  76327. */
  76328. serialize(): any;
  76329. /**
  76330. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  76331. * @param parsedTexture defines parsed texture data
  76332. * @param scene defines the current scene
  76333. * @param rootUrl defines the root URL containing grass procedural texture information
  76334. * @returns a parsed Grass Procedural BABYLON.Texture
  76335. */
  76336. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  76337. }
  76338. }
  76339. declare module BABYLON {
  76340. /** @hidden */
  76341. export var marbleProceduralTexturePixelShader: {
  76342. name: string;
  76343. shader: string;
  76344. };
  76345. }
  76346. declare module BABYLON {
  76347. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  76348. private _numberOfTilesHeight;
  76349. private _numberOfTilesWidth;
  76350. private _amplitude;
  76351. private _jointColor;
  76352. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76353. updateShaderUniforms(): void;
  76354. numberOfTilesHeight: number;
  76355. amplitude: number;
  76356. numberOfTilesWidth: number;
  76357. jointColor: BABYLON.Color3;
  76358. /**
  76359. * Serializes this marble procedural texture
  76360. * @returns a serialized marble procedural texture object
  76361. */
  76362. serialize(): any;
  76363. /**
  76364. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  76365. * @param parsedTexture defines parsed texture data
  76366. * @param scene defines the current scene
  76367. * @param rootUrl defines the root URL containing marble procedural texture information
  76368. * @returns a parsed Marble Procedural BABYLON.Texture
  76369. */
  76370. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  76371. }
  76372. }
  76373. declare module BABYLON {
  76374. /** @hidden */
  76375. export var normalMapProceduralTexturePixelShader: {
  76376. name: string;
  76377. shader: string;
  76378. };
  76379. }
  76380. declare module BABYLON {
  76381. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  76382. private _baseTexture;
  76383. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76384. updateShaderUniforms(): void;
  76385. render(useCameraPostProcess?: boolean): void;
  76386. resize(size: any, generateMipMaps: any): void;
  76387. baseTexture: BABYLON.Texture;
  76388. /**
  76389. * Serializes this normal map procedural texture
  76390. * @returns a serialized normal map procedural texture object
  76391. */
  76392. serialize(): any;
  76393. /**
  76394. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  76395. * @param parsedTexture defines parsed texture data
  76396. * @param scene defines the current scene
  76397. * @param rootUrl defines the root URL containing normal map procedural texture information
  76398. * @returns a parsed Normal Map Procedural BABYLON.Texture
  76399. */
  76400. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  76401. }
  76402. }
  76403. declare module BABYLON {
  76404. /** @hidden */
  76405. export var perlinNoiseProceduralTexturePixelShader: {
  76406. name: string;
  76407. shader: string;
  76408. };
  76409. }
  76410. declare module BABYLON {
  76411. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  76412. time: number;
  76413. timeScale: number;
  76414. translationSpeed: number;
  76415. private _currentTranslation;
  76416. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76417. updateShaderUniforms(): void;
  76418. render(useCameraPostProcess?: boolean): void;
  76419. resize(size: any, generateMipMaps: any): void;
  76420. /**
  76421. * Serializes this perlin noise procedural texture
  76422. * @returns a serialized perlin noise procedural texture object
  76423. */
  76424. serialize(): any;
  76425. /**
  76426. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  76427. * @param parsedTexture defines parsed texture data
  76428. * @param scene defines the current scene
  76429. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  76430. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  76431. */
  76432. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  76433. }
  76434. }
  76435. declare module BABYLON {
  76436. /** @hidden */
  76437. export var roadProceduralTexturePixelShader: {
  76438. name: string;
  76439. shader: string;
  76440. };
  76441. }
  76442. declare module BABYLON {
  76443. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  76444. private _roadColor;
  76445. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76446. updateShaderUniforms(): void;
  76447. roadColor: BABYLON.Color3;
  76448. /**
  76449. * Serializes this road procedural texture
  76450. * @returns a serialized road procedural texture object
  76451. */
  76452. serialize(): any;
  76453. /**
  76454. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  76455. * @param parsedTexture defines parsed texture data
  76456. * @param scene defines the current scene
  76457. * @param rootUrl defines the root URL containing road procedural texture information
  76458. * @returns a parsed Road Procedural BABYLON.Texture
  76459. */
  76460. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  76461. }
  76462. }
  76463. declare module BABYLON {
  76464. /** @hidden */
  76465. export var starfieldProceduralTexturePixelShader: {
  76466. name: string;
  76467. shader: string;
  76468. };
  76469. }
  76470. declare module BABYLON {
  76471. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  76472. private _time;
  76473. private _alpha;
  76474. private _beta;
  76475. private _zoom;
  76476. private _formuparam;
  76477. private _stepsize;
  76478. private _tile;
  76479. private _brightness;
  76480. private _darkmatter;
  76481. private _distfading;
  76482. private _saturation;
  76483. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76484. updateShaderUniforms(): void;
  76485. time: number;
  76486. alpha: number;
  76487. beta: number;
  76488. formuparam: number;
  76489. stepsize: number;
  76490. zoom: number;
  76491. tile: number;
  76492. brightness: number;
  76493. darkmatter: number;
  76494. distfading: number;
  76495. saturation: number;
  76496. /**
  76497. * Serializes this starfield procedural texture
  76498. * @returns a serialized starfield procedural texture object
  76499. */
  76500. serialize(): any;
  76501. /**
  76502. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  76503. * @param parsedTexture defines parsed texture data
  76504. * @param scene defines the current scene
  76505. * @param rootUrl defines the root URL containing startfield procedural texture information
  76506. * @returns a parsed Starfield Procedural BABYLON.Texture
  76507. */
  76508. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  76509. }
  76510. }
  76511. declare module BABYLON {
  76512. /** @hidden */
  76513. export var woodProceduralTexturePixelShader: {
  76514. name: string;
  76515. shader: string;
  76516. };
  76517. }
  76518. declare module BABYLON {
  76519. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  76520. private _ampScale;
  76521. private _woodColor;
  76522. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  76523. updateShaderUniforms(): void;
  76524. ampScale: number;
  76525. woodColor: BABYLON.Color3;
  76526. /**
  76527. * Serializes this wood procedural texture
  76528. * @returns a serialized wood procedural texture object
  76529. */
  76530. serialize(): any;
  76531. /**
  76532. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  76533. * @param parsedTexture defines parsed texture data
  76534. * @param scene defines the current scene
  76535. * @param rootUrl defines the root URL containing wood procedural texture information
  76536. * @returns a parsed Wood Procedural BABYLON.Texture
  76537. */
  76538. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  76539. }
  76540. }